/* =========================================================
   FEZEKA SSO — Layout
   Authenticated app shell (sidebar, topbar, app frame) plus
   the shared content scaffolding (admin container/header).
   Loaded on every page via _Layout.
   ========================================================= */

/* =========================================================
   ADMIN CONTENT SCAFFOLDING
   ========================================================= */

.admin-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 0;
}

    .admin-container.narrow {
        max-width: 700px;
    }

    .admin-container.details-page {
        max-width: 800px;
    }

.admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2rem;
}

    .admin-header h1 {
        margin-bottom: .25rem;
        font-size: 2rem;
    }

    .admin-header p {
        margin: 0;
        font-size: .95rem;
    }

    .admin-header .btn {
        margin-top: .5rem;
        white-space: nowrap;
    }

.page-title {
    margin-bottom: .25rem;
    font-size: 2rem;
}

.page-subtitle {
    margin: 0;
    font-size: .95rem;
    color: var(--text-light);
}

/* =========================================================
   APP SHELL — SIDEBAR + TOPBAR
   ========================================================= */

.app-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(15, 8, 14, .45);

}

    .app-overlay.show {
        display: block;
    }

.app-shell-body {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1050;
    width: 270px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #1a0a14 0%, #2b0d22 30%, #3d1530 100%);
    color: #d9c2cf;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(255, 255, 255, .06);
}

    .sidebar::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        width: 1px;
        height: 100%;
        background: linear-gradient(180deg, rgba(184, 90, 143, .3) 0%, transparent 50%, rgba(184, 90, 143, .15) 100%);
        pointer-events: none;
    }

.app-shell {
    flex: 1;
    margin-left: 270px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.sidebar-collapse-btn {
    width: 100%;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .5);
    cursor: pointer;
    transition: all .2s ease;
    flex-shrink: 0;
}

    .sidebar-collapse-btn:hover {
        background: rgba(255, 255, 255, .12);
        color: #fff;
        border-color: rgba(255, 255, 255, .18);
    }

    .sidebar-collapse-btn svg {
        transition: transform .2s ease;
    }

.sidebar.collapsed {
    width: 72px;
}

    .sidebar.collapsed .sidebar-header {
        justify-content: center;
        padding: 18px 0;
    }

    .sidebar.collapsed .sidebar-logo {
        justify-content: center;
        gap: 0;
    }

    .sidebar.collapsed .sidebar-logo-icon,
    .sidebar.collapsed .sidebar-logo-icon img {
        width: 60px;
        height: 60px;
    }

    .sidebar.collapsed .sidebar-logo-text,
    .sidebar.collapsed .sidebar-section-label,
    .sidebar.collapsed .sidebar-divider,
    .sidebar.collapsed .sidebar-footer-card {
        display: none;
    }

    .sidebar.collapsed .sidebar-link {
        justify-content: center;
        gap: 0;
        padding: 12px 0;
        font-size: 0;
        white-space: nowrap;
        overflow: hidden;
    }

    .sidebar.collapsed .sidebar-collapse-btn {
        width: 40px;
        height: 40px;
        margin: 0 auto;
        border-radius: 12px;
        background: rgba(255, 255, 255, .08);
        border-color: rgba(255, 255, 255, .12);
    }

        .sidebar.collapsed .sidebar-collapse-btn:hover {
            background: var(--primary);
            border-color: var(--primary);
        }

    .sidebar.collapsed .sidebar-collapse-btn svg {
        transform: rotate(180deg);
    }

    .sidebar.collapsed .sidebar-footer {
        gap: 10px;
    }

.app-shell.sidebar-collapsed {
    margin-left: 72px;
}

.sidebar.collapsed + .app-shell {
    margin-left: 72px;
}

.sidebar-logo-icon {
    width: 75px;
    height: 75px;
    display: grid;
    place-items: center;
    background: transparent;
    box-shadow: none;
    flex-shrink: 0;
}

.sidebar-logo-icon svg {
    display: none;
}

.sidebar-logo-icon img {
    width: 75px;
    height: 75px;
    object-fit: contain;
    display: block;
}

.sidebar-section-label {
    padding: 8px 24px 4px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, .35);
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

    .sidebar-logo-text strong {
        color: var(--white);
        font-size: 16.5px;
        font-weight: 700;
        letter-spacing: .3px;
    }

    .sidebar-logo-text span {
        color: rgba(255, 255, 255, .55);
        font-size: 13px;
        font-weight: 400;
    }

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 14px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, .6);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: all .2s ease;
    cursor: pointer;
    user-select: none;
    position: relative;
}

    .sidebar-link:hover {
        background: rgba(255, 255, 255, .06);
        color: rgba(255, 255, 255, .95);
        text-decoration: none;
    }

    .sidebar-link.active {
        background: rgba(255, 255, 255, .06);
        color: var(--white);
    }

        .sidebar-link.active::before {
            content: "";
            position: absolute;
            left: -14px;
            top: 50%;
            transform: translateY(-50%);
            width: 3px;
            height: 24px;
            border-radius: 0 3px 3px 0;
            background: linear-gradient(180deg, #5ce65a, #28db2a);
            box-shadow: 0 0 10px rgba(40, 219, 42, .5);
        }

    .sidebar-link.disabled {
        cursor: not-allowed;
        opacity: .5;
    }

        .sidebar-link.disabled:hover {
            background: transparent;
            color: rgba(255, 255, 255, .7);
        }

.sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 2;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, .08);
    margin: 8px 0;
}

.sidebar-spacer {
    flex: 1;
}

.sidebar-logout {
    color: #ffd1e6;
}

    .sidebar-logout:hover {
        background: rgba(231, 76, 60, .18);
        color: #fff;
    }

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-footer-logout-icon {
    display: none;
    width: 40px;
    height: 40px;
    margin: 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(231, 76, 60, .12);
    border: 1px solid rgba(231, 76, 60, .2);
    color: #ff9b9b;
    transition: all .2s ease;
}

    .sidebar-footer-logout-icon:hover {
        background: rgba(231, 76, 60, .25);
        border-color: rgba(231, 76, 60, .35);
        color: #fff;
        box-shadow: 0 4px 12px rgba(231, 76, 60, .2);
        text-decoration: none;
    }

.sidebar.collapsed .sidebar-footer-logout-icon {
    display: flex;
}

.sidebar-footer-card {
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 14px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}

.sidebar-footer-shield {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(148, 53, 111, .2);
    color: var(--primary-light);
    box-shadow: 0 0 20px rgba(148, 53, 111, .15);
}

.sidebar-footer-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

    .sidebar-footer-text strong {
        color: rgba(255, 255, 255, .85);
        font-size: 12.5px;
        font-weight: 600;
        letter-spacing: .02em;
    }

    .sidebar-footer-text span {
        color: rgba(255, 255, 255, .4);
        font-size: 10.5px;
    }

.sidebar-footer-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(231, 76, 60, .12);
    border: 1px solid rgba(231, 76, 60, .2);
    color: #ff9b9b;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all .2s ease;
    cursor: pointer;
}

    .sidebar-footer-logout:hover {
        background: rgba(231, 76, 60, .25);
        border-color: rgba(231, 76, 60, .35);
        color: #fff;
        text-decoration: none;
        box-shadow: 0 4px 12px rgba(231, 76, 60, .2);
    }

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 28px;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

.topbar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.topbar-search {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    background: rgba(0, 0, 0, .03);
    border: 1px solid rgba(0, 0, 0, .06);
    border-radius: 12px;
    transition: all .2s ease;
}

    .topbar-search:focus-within {
        background: var(--white);
        border-color: rgba(148, 53, 111, .3);
        box-shadow: 0 0 0 3px rgba(148, 53, 111, .08), 0 2px 8px rgba(0, 0, 0, .06);
    }

.topbar-search-icon {
    color: var(--text-light);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.topbar-search input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 10px 0;
    font: inherit;
    font-size: 14px;
    color: var(--text);
}

    .topbar-search input::placeholder {
        color: var(--text-muted);
    }

.topbar-search.search-disabled {
    opacity: .5;
}

    .topbar-search.search-disabled input {
        cursor: not-allowed;
    }

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-bell {
    position: relative;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--white);
    color: var(--text-light);
    cursor: pointer;
    transition: all .2s ease;
}

    .topbar-bell:hover {
        background: var(--gray-100);
    }

.bell-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: 50px;
    background: #e74c3c;
    border: 2px solid var(--white);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.bell-wrap {
    position: relative;
}

.bell-panel {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: min(340px, calc(100vw - 24px));
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    overflow: hidden;
}

    .bell-panel.open {
        display: block;
    }

.bell-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
}

    .bell-head strong {
        font-size: 14px;
        font-weight: 700;
        color: var(--text);
    }

.bell-mark-read {
    border: 0;
    background: transparent;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background .15s ease;
}

    .bell-mark-read:hover {
        background: rgba(148, 53, 111, .08);
    }

.bell-list {
    max-height: 340px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.bell-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 13px 16px;
    border: 0;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease;
    position: relative;
}

    .bell-item:hover {
        background: var(--gray-50);
    }

    .bell-item.is-unread {
        background: rgba(148, 53, 111, .04);
    }

        .bell-item.is-unread::after {
            content: '';
            position: absolute;
            right: 14px;
            top: 18px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--primary);
        }

.bell-item-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    margin-top: 1px;
}

    .bell-item-icon.type-ticket {
        background: rgba(148, 53, 111, .1);
        color: var(--primary);
    }

    .bell-item-icon.type-app {
        background: rgba(16, 129, 110, .1);
        color: #10816e;
    }

.bell-item-body {
    min-width: 0;
    flex: 1;
}

    .bell-item-body strong {
        display: block;
        font-size: 13px;
        font-weight: 600;
        color: var(--text);
        line-height: 1.3;
    }

    .bell-item-body p {
        margin: 3px 0 0;
        font-size: 12px;
        color: var(--text-light);
        line-height: 1.4;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .bell-item-body time {
        display: block;
        margin-top: 4px;
        font-size: 11px;
        color: var(--text-muted);
    }

.bell-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.user-menu {
    position: relative;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px 5px 5px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s ease;
}

    .user-chip:hover {
        background: var(--gray-100);
    }

.user-avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: var(--white);
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.25;
}

    .user-meta strong {
        color: var(--text);
        font-size: 13.5px;
        font-weight: 600;
    }

    .user-meta small {
        color: var(--text-light);
        font-size: 11px;
        margin: 0;
    }

.user-chevron {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: transform .2s ease;
}

.user-menu.open .user-chevron {
    transform: rotate(180deg);
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 210px;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
}

    .user-dropdown.open {
        display: block;
    }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 13.5px;
    text-align: left;
    text-decoration: none;
    transition: background .15s ease;
}

    .dropdown-item:hover {
        background: var(--gray-100);
        color: var(--text);
        text-decoration: none;
    }

    .dropdown-item.disabled {
        color: var(--text-muted);
        cursor: not-allowed;
    }

        .dropdown-item.disabled:hover {
            background: transparent;
        }

.dropdown-divider {
    border: 0;
    border-top: 1px solid var(--border-light);
    margin: 4px 0;
}

.app-main {
    min-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(148, 53, 111, .02) 0%, transparent 60%),
        var(--bg);
}

    .app-main .page-wrapper {
        flex: 1;
        max-width: 1280px;
        width: 100%;
        margin: 0 auto;
        padding: 32px 28px 48px;
    }

.app-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: linear-gradient(180deg, rgba(248, 249, 250, .95) 0%, rgba(240, 241, 243, .98) 100%);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-light);
    padding: 0 28px;
}

    .app-footer .security-banner {
        max-width: 1280px;
        margin: 0 auto;
        border-radius: 0;
        margin-top: 0;
        padding: 18px 0;
        background: transparent;
        border: 0;
        box-shadow: none;
        gap: 16px;
    }

/* =========================================================
   RESPONSIVE — APP SHELL & ADMIN SCAFFOLDING
   ========================================================= */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
    }

        .sidebar.open {
            transform: translateX(0);
            box-shadow: var(--shadow-xl);
        }

    .app-shell {
        margin-left: 0;
    }

    .topbar-toggle {
        display: flex;
    }

    .sidebar-collapse-btn {
        display: none;
    }

    .app-main .page-wrapper {
        padding: 20px 16px 32px;
    }
}

@media (max-width: 768px) {
    .admin-container {
        padding: 1rem;
    }

    .admin-header {
        flex-direction: column;
    }

        .admin-header h1 {
            font-size: 1.6rem;
        }

        .admin-header .btn {
            width: 100%;
        }

    .topbar {
        padding: 10px 14px;
        gap: 10px;
    }

    .topbar-search {
        max-width: none;
    }

    .user-meta {
        display: none;
    }

    .user-chip {
        padding: 5px;
    }
}

@media (max-width: 480px) {
    .topbar-actions {
        gap: 6px;
    }

    .topbar-search {
        padding: 0 10px;
    }
}

@media (min-width: 1400px) {
    .app-main .page-wrapper {
        max-width: 1400px;
        padding: 32px 32px 48px;
    }
}

@media (min-width: 1600px) {
    .app-main .page-wrapper {
        max-width: 1600px;
        padding: 40px 40px 56px;
    }

    .admin-container {
        max-width: 1600px;
    }

    .app-footer .security-banner {
        max-width: 1600px;
    }
}

@media (min-width: 1920px) {
    .app-main .page-wrapper {
        max-width: 1800px;
    }

    .admin-container {
        max-width: 1800px;
    }

    .admin-container.narrow {
        max-width: 800px;
    }

    .admin-container.details-page {
        max-width: 960px;
    }

    .app-footer .security-banner {
        max-width: 1800px;
    }
}

@media (min-width: 2560px) {
    /* ── Sidebar scales up ── */
    .sidebar {
        width: 320px;
    }

    .app-shell {
        margin-left: 320px;
    }

    .sidebar-logo {
        padding: 28px 28px;
    }

    .sidebar-logo .logo-icon {
        width: 50px;
        height: 50px;
        font-size: 17px;
        border-radius: 14px;
    }

    .sidebar-logo-icon {
        width: 75px;
        height: 75px;
        background: transparent;
        box-shadow: none;
    }

        .sidebar-logo-icon img {
            width: 75px;
            height: 75px;
        }

    .sidebar-logo-text strong {
        font-size: 18px;
    }

    .sidebar-logo-text span {
        font-size: 14px;
    }

    .sidebar-nav {
        padding: 22px 18px;
        gap: 6px;
    }

    .sidebar-link {
        padding: 13px 16px;
        font-size: 15.5px;
        border-radius: 12px;
    }

    .sidebar-icon {
        font-size: 17px;
    }

    .sidebar-footer {
        padding: 20px;
    }

    .sidebar-footer-card {
        padding: 24px 18px;
    }

    .sidebar-footer-shield {
        width: 48px;
        height: 48px;
    }

    .sidebar-footer-text strong {
        font-size: 14px;
    }

    .sidebar-footer-text span {
        font-size: 12px;
    }

    .sidebar-footer-logout {
        padding: 11px 18px;
        font-size: 13.5px;
    }

    /* ── Topbar scales up ── */
    .topbar {
        padding: 14px 32px;
    }

    .topbar-search {
        max-width: 520px;
        padding: 0 18px;
    }

    .topbar-search input {
        font-size: 15px;
    }

    .topbar-search-icon {
        font-size: 16px;
    }

    .topbar-bell {
        width: 46px;
        height: 46px;
        font-size: 20px;
        border-radius: 12px;
    }

    .user-avatar {
        width: 44px;
        height: 44px;
        font-size: 17px;
    }

    .user-meta strong {
        font-size: 15px;
    }

    .user-meta small {
        font-size: 12px;
    }

    /* ── Content scales up ── */
    .app-main .page-wrapper {
        max-width: 2200px;
        padding: 44px 48px 64px;
    }

    /* ── Admin pages scale up ── */
    .admin-container {
        max-width: 2200px;
    }

    .admin-container.narrow {
        max-width: 900px;
    }

    .admin-container.details-page {
        max-width: 1100px;
    }

    .app-footer .security-banner {
        max-width: 2200px;
    }

    .admin-header h1,
    .page-title {
        font-size: 2.25rem;
    }
}