/**
 * Mobikey layout fixes on top of Portal (Bootstrap 5) + DataTables + SweetAlert2
 */

/* ---- Sidebar: category headings (all dashboards) ---- */
.app-nav .app-menu .nav-section {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9fa7b5;
    user-select: none;
}

.app-nav .app-menu .nav-section:first-child {
    margin-top: 0.25rem;
}

.app-nav .app-menu .nav-section + .nav-item .nav-link {
    margin-top: 0;
}

/* ---- Global loader overlay (all pages) ---- */
.mk-loader {
    position: fixed;
    inset: 0;
    z-index: 20040; /* below SweetAlert2 (20050) */
    display: none;
}

.mk-loader.is-active {
    display: block;
}

.mk-loader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(2px);
}

.mk-loader-card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.22);
    color: #0f172a;
}

.mk-loader-text {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.mk-loader .spinner-border {
    width: 1.25rem;
    height: 1.25rem;
    border-width: 0.15rem;
}

/* ---- Sidepanel footer: logout (all dashboards) — icon + readable tap target ---- */
.app-sidepanel-footer .footer-logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3rem;
    padding: 0.75rem 1rem;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.35;
    border-radius: 0.35rem;
}

.app-sidepanel-footer .footer-logout-btn:hover {
    color: #15a362;
    background-color: rgba(21, 163, 98, 0.08);
}

.app-sidepanel-footer .footer-logout-icon {
    position: static !important;
    left: auto !important;
    top: auto !important;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
}

.app-sidepanel-footer .footer-logout-icon svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
}

.app-sidepanel-footer .footer-logout-label {
    flex: 1;
    min-width: 0;
}

/* ---- Guest / login: no superadmin header — remove .app top padding ---- */
body.app.app-login {
    padding-top: 0;
}

.app-login .app-auth-wrapper {
    min-height: 100vh;
    height: auto;
    display: flex;
    align-items: center;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    box-sizing: border-box;
}

/* ---- Page titles: single .app-page-title on h1 only ---- */
.page-heading .app-page-title {
    margin-bottom: 0.35rem;
    font-size: 1.5rem;
}

.page-heading-sub {
    font-size: 0.9375rem;
    line-height: 1.45;
    color: #9fa7b5;
}

/* ---- Main shell: Portal adds margin-left:250px on .app-wrapper (xl+).
     width:100% + that margin = content wider than viewport → right side cut off.
     Constrain wrapper to remaining width. ---- */
body.app {
    overflow-x: hidden;
    max-width: 100%;
}

.app .app-wrapper {
    box-sizing: border-box;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: visible;
}

@media (min-width: 1200px) {
    .app .app-wrapper {
        width: calc(100% - 250px);
        max-width: calc(100% - 250px);
        margin-left: 250px;
    }
}

@media (max-width: 1199.98px) {
    .app .app-wrapper {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
    }
}

.app-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    /* Allow dropdowns/overlays (Choices.js) to escape cards */
    overflow: visible !important;
    padding-bottom: 3rem;
}

.app-content > .container-xl {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* ---- DataTables: no Bootstrap .row bleed, toolbar uses flex (see datatables-bundle dom) ---- */
.dataTables_wrapper {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.dataTables_wrapper .dt-toolbar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    /* was justify-content-between — search pushed past viewport */
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 0.75rem 1rem !important;
    row-gap: 0.75rem !important;
}

/* Toolbar: search stays compact (no flex-grow — avoids full-width input) */
.dataTables_wrapper .dt-toolbar .dataTables_filter {
    margin-left: auto !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: 100%;
}

.dataTables_wrapper .dt-toolbar .dataTables_filter label {
    width: auto !important;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.dataTables_wrapper .dt-toolbar .dataTables_filter input[type="search"] {
    flex: 0 0 auto !important;
    width: 12rem !important;
    max-width: min(100%, 14rem) !important;
    min-width: 0;
    box-sizing: border-box;
}

/* If any DT child still uses .row (plugins), kill negative margins */
.dataTables_wrapper .row {
    --bs-gutter-x: 0.75rem;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100%;
}

.dataTables_wrapper .row > [class*="col-"] {
    max-width: 100%;
}

.app-card {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.app-card .app-card-body {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* ---- Choices.js (searchable selects): prevent dropdown clipping ---- */
.mk-filter-card,
.mk-filter-card .app-card-body {
    overflow: visible !important;
}

/* Ensure Choices dropdown stacks above cards/tables */
.choices__list--dropdown,
.choices__list[aria-expanded] {
    z-index: 20060 !important; /* above app shell + cards, below loader (20040) and SweetAlert (20050) */
}

/* Choices sizing: dropdown and search should not be tiny/cut */
.choices {
    width: 100% !important;
}

.choices__inner {
    width: 100% !important;
}

.choices__list--dropdown,
.choices__list[aria-expanded] {
    width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box;
}

.choices__list--dropdown .choices__input,
.choices__input--cloned {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

/* Some layouts can accidentally block clicks inside the dropdown */
.choices__list--dropdown,
.choices__list--dropdown * {
    pointer-events: auto;
}

.choices__list--dropdown .choices__input {
    position: relative;
    z-index: 1;
}

/* Scroll table area only inside the card, not the whole page */
.app-card .dataTables_wrapper {
    padding: 1rem 1rem 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.app-card .dataTables_wrapper .table.dataTable {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

table.dataTable {
    width: 100% !important;
    max-width: 100%;
    table-layout: auto;
}

.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    font-weight: normal;
    flex-wrap: wrap;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #e7e9ed;
    border-radius: 0.25rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.875rem;
    min-width: 0;
    max-width: 100%;
}

.dataTables_wrapper .dataTables_length label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid #e7e9ed;
    border-radius: 0.25rem;
    padding: 0.25rem 1.75rem 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.dataTables_wrapper div.dt-buttons {
    float: none !important;
    display: inline-flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

/* Buttons extension: default CSS uses background sprites; Portal/Bootstrap can hide label text */
.dataTables_wrapper .dt-buttons .dt-button,
.dataTables_wrapper .dt-buttons button.dt-button {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 2rem;
    min-width: 3.5rem;
    padding: 0.375rem 0.65rem !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    text-indent: 0 !important;
    overflow: visible !important;
    background-image: none !important;
    box-shadow: none !important;
    color: #fff !important;
    background-color: #15a362 !important;
    border: 1px solid #15a362 !important;
    border-radius: 0.25rem !important;
}

.dataTables_wrapper .dt-buttons .dt-button:hover,
.dataTables_wrapper .dt-buttons button.dt-button:hover {
    color: #fff !important;
    background-color: #128c54 !important;
    border-color: #128c54 !important;
}

.dataTables_wrapper .dataTables_info {
    padding-top: 0.75rem;
    font-size: 0.875rem;
    color: #9fa7b5;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 0.5rem;
}

.dataTables_wrapper .pagination {
    margin-bottom: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ---- SweetAlert2 above fixed header / sidepanel ---- */
.swal2-container {
    z-index: 20050;
}

/* ---- Login (attractive)
   Portal theme sets .app-auth-wrapper { background: white } which hides the gradient — override here. ---- */
body.mk-login-page {
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(20, 184, 166, 0.22) 0%, transparent 55%),
        radial-gradient(90% 60% at 0% 100%, rgba(59, 130, 246, 0.12) 0%, transparent 50%),
        linear-gradient(168deg, #0f172a 0%, #134e4a 38%, #0b1220 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: #e2e8f0;
}

body.mk-login-page .app-auth-wrapper {
    background: transparent !important;
    min-height: 100vh;
    height: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    box-sizing: border-box;
}

body.mk-login-page .app-auth-wrapper > .container-xl {
    width: 100%;
    max-width: 100%;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

.mk-login-logo {
    width: 3rem;
    height: 3rem;
    font-size: 1.125rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)) !important;
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.2);
}

.mk-login-logo i {
    color: #5eead4 !important;
}

.mk-login-card {
    border-radius: 0.75rem;
    overflow: hidden;
    background: #fff;
    color: #252930;
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow:
        0 0.25rem 0.5rem rgba(15, 23, 42, 0.04),
        0 1rem 2.5rem rgba(15, 23, 42, 0.12) !important;
}

.mk-login-card .mk-login-card-head {
    height: 0.28rem;
    background: linear-gradient(90deg, #0d9488, #14b8a6, #0ea5e9);
}

.mk-login-card .form-label {
    color: #475569;
    font-weight: 500;
}

.mk-login-card .form-control {
    border-color: #e2e8f0;
}

.mk-login-card .form-control:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 0.2rem rgba(13, 148, 136, 0.18);
}

.mk-login-card .form-check-label {
    color: #64748b;
}

.mk-login-password-wrap .form-control {
    padding-right: 2.75rem;
}

.mk-login-password-toggle {
    position: absolute;
    right: 0.2rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    border: 0;
    border-radius: 0.35rem;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    pointer-events: auto;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.mk-login-password-toggle .mk-pw-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.mk-login-password-toggle:hover {
    color: #0d9488;
    background-color: rgba(13, 148, 136, 0.08);
}

.mk-login-password-toggle:focus-visible {
    outline: 2px solid rgba(13, 148, 136, 0.45);
    outline-offset: 2px;
}

.mk-login-submit {
    font-weight: 600;
    letter-spacing: 0.02em;
    border: none;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%);
    color: #fff !important;
    box-shadow: 0 0.35rem 0.85rem rgba(13, 148, 136, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.mk-login-submit:hover {
    background: linear-gradient(180deg, #2dd4bf 0%, #0f766e 100%);
    color: #fff !important;
    box-shadow: 0 0.45rem 1rem rgba(13, 148, 136, 0.45);
}

.mk-login-submit:active {
    transform: translateY(1px);
}

.mk-login-brand .text-white-50 {
    color: rgba(226, 232, 240, 0.72) !important;
}

.mk-login-foot {
    font-size: 0.8125rem;
    color: rgba(226, 232, 240, 0.55);
}

/* ---- Dashboard stat tiles ---- */
.mk-stat-tile {
    border-radius: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    min-height: 5.25rem;
}

.mk-stat-tile-inner {
    min-height: 5rem;
}

.mk-stat-tile .mk-stat-label {
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: #6c757d;
}

.mk-stat-tile .mk-stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
    color: #252930;
}

.mk-stat-tile-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.5rem;
    background: rgba(21, 163, 98, 0.12);
    color: #15a362;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.35rem;
}

/* Info strip cards on dashboards */
.mk-dashboard-panel {
    border-radius: 0.5rem;
}

.mk-dashboard-panel .mk-dashboard-panel-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: #252930;
}

.mk-dashboard-panel .mk-dashboard-panel-body {
    font-size: 0.9375rem;
    line-height: 1.55;
    color: #5d6778;
}
