/* =====================================================
   layout.css
   APPLICATION SHELL: sidebar, header, content area, online-users
   panel, responsive drawer, shared card/form contract.
   Loaded right after theme.css.
   ===================================================== */

.v2-credit,
.v2-color-credit { color: var(--v2-credit) !important; }
.v2-debit,
.v2-color-debit { color: var(--v2-debit) !important; }
.v2-balance-positive { color: var(--v2-positive) !important; }
.v2-balance-negative { color: var(--v2-negative) !important; }
.v2-balance-zero { color: var(--v2-zero) !important; }
.v2-credit-border { border-color: var(--v2-credit) !important; }
.v2-debit-border { border-color: var(--v2-debit) !important; }
.v2-credit-bg { background: var(--v2-credit-bg) !important; }
.v2-debit-bg { background: var(--v2-debit-bg) !important; }

/* One application-wide control/card contract. */
.v2-shell .card {
    background: var(--v2-card-bg);
    color: var(--v2-text);
    border-color: var(--v2-card-border);
}

.v2-shell .card-header,
.v2-shell .card-footer {
    background: var(--v2-table-head-bg);
    color: var(--v2-text);
    border-color: var(--v2-card-border);
}

.v2-shell .form-control,
.v2-shell .form-select {
    background-color: var(--v2-input-bg);
    color: var(--v2-text);
    border-color: var(--v2-card-border);
}

.v2-shell .form-control::placeholder {
    color: var(--v2-muted);
    opacity: 1;
}

.v2-shell .form-control:focus,
.v2-shell .form-select:focus {
    background-color: var(--v2-input-bg);
    color: var(--v2-text);
    border-color: var(--v2-focus);
    box-shadow: 0 0 0 .18rem var(--v2-focus-ring);
}

.v2-shell .text-muted { color: var(--v2-muted) !important; }


/* =====================================================
           SHELL
           ===================================================== */

.v2-shell {
    min-height: 100vh;
    background: var(--v2-body-bg);
    color: var(--v2-text);
}


/* =====================================================
           MAIN CONTENT
           No shared title/header.
           ===================================================== */

.v2-main {
    min-height: 100vh;
    margin-right: var(--v2-sidebar-width);
    transition: margin-right .2s ease;
}


.v2-content {
    padding: 24px;
    min-height: 100vh;
}


/* =====================================================
           ONLINE USERS PANEL
           ADMIN ONLY
           Dashboard / Home only
           ===================================================== */

.v2-content {
    position: relative;
}

.v2-online-users-panel {
    position: absolute;
    top: 12px;
    left: 24px;
    z-index: 20;
    width: 250px;
    max-width: calc(100% - 48px);
    border: 1px solid var(--v2-card-border);
    border-radius: 12px;
    background: var(--v2-card-bg);
    color: var(--v2-text);
    box-shadow: var(--v2-shadow);
    overflow: hidden;
}

.v2-online-users-header {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--v2-card-border);
    background: var(--v2-sidebar-hover);
}

.v2-online-users-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.v2-online-users-status-dot,
.v2-online-user-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.v2-online-users-title {
    color: var(--v2-text);
    font-size: 12.5px;
    font-weight: 800;
    white-space: nowrap;
}

.v2-online-users-count {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
    font-size: 11px;
    font-weight: 800;
}

.v2-online-users-list {
    max-height: 240px;
    overflow-y: auto;
}

.v2-online-user-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--v2-card-border);
}

.v2-online-user-row:last-child {
    border-bottom: 0;
}

.v2-online-user-row:hover {
    background: var(--v2-sidebar-hover);
}

.v2-online-user-info {
    min-width: 0;
}

.v2-online-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--v2-text);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.45;
}

.v2-online-user-role {
    margin-top: 1px;
    color: var(--v2-muted);
    font-size: 10.5px;
    line-height: 1.4;
}

.v2-online-users-empty {
    padding: 12px 10px;
    color: var(--v2-muted);
    font-size: 11.5px;
    text-align: center;
}

body.v2-theme-dark .v2-online-users-count,
body.v2-theme-smart .v2-online-users-count {
    color: #86efac;
    background: rgba(34, 197, 94, 0.16);
}

@media (max-width: 991.98px) {

    .v2-online-users-panel {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        max-width: none;
        margin: 0 0 14px 0;
    }
}


/* =====================================================
           MOBILE MENU BUTTON
           Only visible on mobile/tablet.
           There is no shared title bar.
           ===================================================== */

.v2-mobile-menu-button {
    width: 44px;
    height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--v2-card-border);
    border-radius: 10px;
    background: var(--v2-card-bg);
    color: var(--v2-text);
    cursor: pointer;
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1030;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}


    .v2-mobile-menu-button:hover {
        background: var(--v2-sidebar-hover);
        color: var(--v2-text);
    }


/* =====================================================
           SIDEBAR
           ===================================================== */

.v2-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--v2-sidebar-width);
    background: var(--v2-sidebar-bg);
    border-left: 1px solid var(--v2-sidebar-border);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.06);
}


/* =====================================================
           SIDEBAR BRAND
           ===================================================== */

.v2-sidebar-brand {
    min-height: 90px;
    padding: 20px 22px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--v2-sidebar-border);
}


.v2-sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--v2-sidebar-text);
    width: 100%;
}


.v2-sidebar-brand-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--v2-primary), var(--v2-primary-dark));
    color: #ffffff;
}


.v2-sidebar-brand-name {
    font-size: 1.05rem;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


.v2-sidebar-content {
    flex: 1;
    padding: 16px 14px;
}


/* =====================================================
           MENU GROUP
           ===================================================== */

.v2-menu-group {
    margin-bottom: 8px;
}


.v2-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border-radius: 11px;
    color: var(--v2-sidebar-text);
    background: transparent;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 800;
    border: 0;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}


    .v2-group-header:hover {
        background: var(--v2-sidebar-hover);
        color: var(--v2-sidebar-text);
        transform: translateX(-2px);
    }


    .v2-group-header.active {
        background: linear-gradient(135deg, var(--v2-sidebar-active), var(--v2-sidebar-active-2));
        color: var(--v2-sidebar-active-text);
        box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
    }


.v2-group-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--v2-sidebar-hover);
    color: var(--v2-sidebar-text);
}


.v2-group-header.active
.v2-group-icon {
    background: rgba(255,255,255,.18);
    color: #ffffff;
}


.v2-group-title {
    flex: 1;
    text-align: right;
}


.v2-group-arrow {
    transition: transform .2s ease;
    opacity: .75;
}


details[open] > summary
.v2-group-arrow {
    transform: rotate(180deg);
}


.v2-submenu {
    padding: 5px 0 7px 0;
}


.v2-submenu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 43px;
    padding: 9px 17px 9px 12px;
    margin: 2px 0;
    border-radius: 9px;
    text-decoration: none;
    color: var(--v2-sidebar-text);
    font-size: 1rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}


    .v2-submenu-link:hover {
        background: var(--v2-sidebar-hover);
        color: var(--v2-sidebar-text);
    }


    .v2-submenu-link.active {
        background: rgba(37,99,235,.12);
        color: var(--v2-primary);
        font-weight: 700;
    }


body.v2-theme-dark
.v2-submenu-link.active {
    background: rgba(59,130,246,.18);
    color: #93c5fd;
}


.v2-submenu-icon {
    width: 22px;
    text-align: center;
    opacity: .8;
}


/* =====================================================
           DASHBOARD
           ===================================================== */

.v2-dashboard-link {
    text-decoration: none;
}


    .v2-dashboard-link:hover {
        background: var(--v2-sidebar-hover);
        color: var(--v2-sidebar-text);
        transform: none;
    }


    .v2-dashboard-link.active {
        background: linear-gradient(135deg, var(--v2-sidebar-active) 0%, var(--v2-sidebar-active-2) 100%);
        color: var(--v2-sidebar-active-text);
        font-weight: 700;
        box-shadow: 0 8px 18px rgba(37,99,235,.28);
    }


        .v2-dashboard-link.active
        .v2-group-icon {
            background: rgba(255,255,255,.18);
            color: #ffffff;
        }


/* =====================================================
           USER FOOTER
           ===================================================== */

.v2-sidebar-user {
    padding: 14px;
    border-top: 1px solid var(--v2-sidebar-border);
    background: var(--v2-sidebar-bg);
}


.v2-user-card {
    padding: 13px;
    border: 1px solid var(--v2-sidebar-border);
    border-radius: 12px;
    background: var(--v2-sidebar-hover);
}


.v2-user-name {
    font-weight: 800;
    color: var(--v2-sidebar-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


.v2-user-role {
    margin-top: 3px;
    color: var(--v2-sidebar-muted);
    font-size: .85rem;
}


.v2-logout-button {
    width: 100%;
    margin-top: 10px;
    border: 1px solid rgba(220,38,38,.25);
    border-radius: 9px;
    background: transparent;
    color: var(--v2-danger);
    padding: 9px 12px;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
}


    .v2-logout-button:hover {
        background: rgba(220,38,38,.08);
        color: var(--v2-danger);
    }


/* =====================================================
           MOBILE DRAWER
           ===================================================== */

.v2-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.55);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}


    .v2-mobile-backdrop.show {
        opacity: 1;
        visibility: visible;
    }


.v2-sidebar-close {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--v2-sidebar-border);
    border-radius: 9px;
    background: var(--v2-sidebar-hover);
    color: var(--v2-sidebar-text);
    cursor: pointer;
}


/* =====================================================
           RESPONSIVE
           ===================================================== */

@media (max-width: 991.98px) {

    /* Mobile menu button */

    .v2-mobile-menu-button {
        display: inline-flex;
    }

    /* Sidebar becomes a drawer */

    .v2-sidebar {
        transform: translateX(105%);
        transition: transform .25s ease;
    }


        .v2-sidebar.show {
            transform: translateX(0);
        }


    .v2-sidebar-close {
        display: inline-flex;
    }

    /* Main content uses full width */

    .v2-main {
        margin-right: 0;
    }

    /*
     * Extra top space because there is no shared header.
     * This prevents the fixed mobile menu button from
     * covering the page's own title.
     */

    .v2-content {
        padding: 64px 18px 18px 18px;
        min-height: 100vh;
    }
}


@media (min-width: 992px) {

    /*
     * Desktop:
     * sidebar is permanently visible.
     * No shared header.
     * No mobile menu button.
     */

    .v2-mobile-menu-button {
        display: none;
    }


    .v2-mobile-backdrop {
        display: none;
    }


    .v2-content {
        min-height: 100vh;
    }
}


@media (max-width: 575.98px) {

    .v2-content {
        padding: 62px 12px 12px 12px;
    }


    .v2-sidebar {
        width: min(88vw, 320px);
    }


    .v2-mobile-menu-button {
        width: 42px;
        height: 42px;
        top: 10px;
        right: 10px;
    }
}


@media (min-width: 576px) and (max-width: 991.98px) {

    .v2-content {
        padding-top: 66px;
    }
}


/* =====================================================
           GLOBAL RESPONSIVE SAFETY
           Prevent page-level horizontal overflow while
           allowing wide data tables to scroll inside their
           own responsive containers.
           ===================================================== */

.v2-main,
.v2-content,
.v2-content > *,
.v2-content .row,
.v2-content [class*="col-"] {
    min-width: 0;
    max-width: 100%;
}

.v2-content img,
.v2-content svg,
.v2-content video,
.v2-content canvas {
    max-width: 100%;
}

.v2-content input,
.v2-content select,
.v2-content textarea,
.v2-content button {
    max-width: 100%;
}

.v2-content .table-responsive,
.v2-content [class*="table-wrap"] {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.v2-content .table-responsive > .table,
.v2-content [class*="table-wrap"] > .table {
    max-width: none;
}

@media (max-width: 575.98px) {
    .v2-content {
        overflow-x: hidden;
    }

    .v2-content .container,
    .v2-content .container-fluid {
        padding-left: 0;
        padding-right: 0;
        max-width: 100%;
    }

    .v2-content .row {
        --bs-gutter-x: .75rem;
    }

    .v2-content .card,
    .v2-content .modal-content,
    .v2-content .dropdown-menu {
        max-width: 100%;
    }

    .v2-online-users-panel {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }
}
