/* ========================================================================
   LAYOUT — Sidebar, Navbar, Main Content, RTL Support
   ======================================================================== */

/* ---------- Page Wrapper ---------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    min-width: 0;
    width: 100%;
    /* clip avoids creating a scroll container (unlike overflow-x:hidden), so sticky headers work */
    overflow-x: clip;
    position: relative;
}

/* ========================================================================
   SIDEBAR
   ======================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-slow), transform var(--transition-slow);
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: var(--space-5) var(--space-5);
    min-height: var(--navbar-height);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: var(--space-3);
    flex-shrink: 0;
}

.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-white);
    font-size: var(--fs-lg);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.sidebar-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: var(--radius);
}

.sidebar-brand {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--transition);
}

/* Menu search — filters the already rendered sidebar, no navigation */
.sidebar-menu-search {
    flex-shrink: 0;
    min-width: 0;
    padding: var(--space-3) var(--space-4) var(--space-2);
}

.sidebar-menu-search-field {
    position: relative;
}

.sidebar-menu-search-icon {
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.95rem;
    line-height: 1;
    pointer-events: none;
}

.sidebar-menu-search-input {
    width: 100%;
    height: 38px;
    padding-block: 0;
    padding-inline: 2.25rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-white);
    font-size: var(--fs-sm);
    font-family: inherit;
    text-align: start;
    outline: none;
    transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.sidebar-menu-search-input::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

.sidebar-menu-search-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.25);
}

.sidebar-menu-search-input::-webkit-search-cancel-button,
.sidebar-menu-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.sidebar-menu-search-clear {
    position: absolute;
    inset-inline-end: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sidebar-menu-search-clear:hover,
.sidebar-menu-search-clear:focus-visible {
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.sidebar-menu-search-clear[hidden] {
    display: none !important;
}

.sidebar-menu-search-empty {
    margin: var(--space-2) 0 0;
    padding: var(--space-2) var(--space-2);
    font-size: var(--fs-sm);
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
}

.sidebar-menu-search-empty[hidden] {
    display: none !important;
}

.sidebar-search-hidden {
    display: none !important;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    min-height: 0; /* required for flex child overflow scrolling */
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4) 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
}

.nav-section-title {
    padding: var(--space-3) var(--space-5);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    opacity: 0.5;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item {
    padding: 0 var(--space-3);
    margin-bottom: var(--space-1);
}

.nav-link {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    color: var(--sidebar-text);
    border-radius: var(--radius);
    font-size: var(--fs-base);
    font-weight: 500;
    gap: var(--space-3);
    white-space: nowrap;
    transition: all var(--transition-fast);
    text-decoration: none;
    position: relative;
}

.nav-link:hover {
    color: var(--text-white);
    background: var(--sidebar-hover);
}

.nav-link.active {
    color: var(--text-white);
    background: var(--sidebar-active);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-link i,
.nav-group-icon {
    font-size: var(--fs-lg);
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.nav-link-text {
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--transition);
}

/* Long navigation titles — wrap only when the sidebar is fully expanded (desktop) or open as mobile drawer.
   Scoped to ≥1201px so the 1025–1200px icon-rail does not inherit flex-start / icon margin offsets. */
@media (min-width: 1201px) {
    .sidebar:not(.collapsed) .nav-link,
    .sidebar:not(.collapsed) .nav-group-toggle {
        white-space: normal;
        align-items: center;
        line-height: 1.4;
    }

    .sidebar:not(.collapsed) .nav-link-text,
    .sidebar:not(.collapsed) .nav-section-title {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.4;
        flex: 1;
        min-width: 0;
    }
}

.sidebar.mobile-open .nav-link,
.sidebar.mobile-open .nav-group-toggle {
    white-space: normal;
    align-items: center;
    line-height: 1.4;
}

.sidebar.mobile-open .nav-link-text,
.sidebar.mobile-open .nav-section-title {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
}

.nav-link .badge,
.nav-group-toggle .nav-notif-badge {
    margin-inline-start: auto;
    font-size: var(--fs-xs);
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 6px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: #fff;
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    z-index: 2;
}

.nav-group-toggle .nav-group-chevron {
    margin-inline-start: 0;
}

.nav-group-toggle .nav-notif-badge:not([hidden]) + .nav-group-chevron {
    margin-inline-start: var(--space-2);
}

.nav-notif-badge[hidden] {
    display: none !important;
}

/* Collapsible nav groups */
.nav-group {
    margin-bottom: var(--space-1);
    padding: 0 var(--space-3);
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--sidebar-text);
    font-size: var(--fs-base);
    font-weight: 600;
    text-align: start;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.nav-group-toggle:hover,
.nav-group.has-active .nav-group-toggle {
    color: var(--text-white);
    background: var(--sidebar-hover);
}

.nav-group-chevron {
    margin-inline-start: auto;
    font-size: var(--fs-sm);
    opacity: 0.7;
    transition: transform var(--transition-fast);
}

.nav-group.is-open .nav-group-chevron {
    transform: rotate(180deg);
}

.nav-group-items {
    display: none;
    overflow: hidden;
    padding-block-start: var(--space-1);
}

.nav-group.is-open .nav-group-items {
    display: block;
}

.nav-item--child {
    padding-inline-start: var(--space-2);
}

.nav-link--child {
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-sm);
    font-weight: 500;
}

.nav-link--child i {
    font-size: var(--fs-base);
    width: 24px;
    height: 24px;
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: var(--space-4) var(--space-3);
}

/* ========================================================================
   SIDEBAR COLLAPSED (desktop icon rail)
   Labels/chevrons leave the flex flow; badges are absolutely positioned
   at the icon corner so they never shift icon centering (LTR + RTL).
   ======================================================================== */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    align-items: center;
    padding: var(--space-4) var(--space-2);
    gap: 0;
}

.sidebar.collapsed .sidebar-logo {
    width: 40px;
    height: 40px;
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-link-text,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-group-chevron,
.sidebar.collapsed .nav-group-items,
.sidebar.collapsed .sidebar-menu-search {
    display: none !important;
}

.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-group {
    padding: 0 var(--space-2);
    margin-bottom: var(--space-1);
}

.sidebar.collapsed .nav-item--child {
    padding-inline-start: 0;
}

.sidebar.collapsed .nav-link,
.sidebar.collapsed .nav-group-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    height: 44px;
    padding: 0;
    gap: 0;
    white-space: nowrap;
    line-height: 1;
    text-align: center;
}

.sidebar.collapsed .nav-link i,
.sidebar.collapsed .nav-group-icon {
    width: 24px;
    min-width: 24px;
    height: 24px;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-lg);
    line-height: 1;
    text-align: center;
    flex-shrink: 0;
}

.sidebar.collapsed .nav-link .badge,
.sidebar.collapsed .nav-group-toggle .nav-notif-badge {
    position: absolute;
    top: 4px;
    inset-inline-start: calc(50% + 2px);
    margin: 0;
    opacity: 1;
    width: auto;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
    line-height: 16px;
    border-radius: var(--radius-full);
    z-index: 3;
    pointer-events: auto;
}

.sidebar.collapsed .nav-notif-badge[hidden] {
    display: none !important;
}

.sidebar.collapsed .sidebar-footer {
    padding: var(--space-3) var(--space-2);
}

.sidebar.collapsed .sidebar-footer .nav-item {
    padding: 0 var(--space-2);
}

/* ========================================================================
   TOP NAVBAR
   ======================================================================== */
.top-navbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 1030;
    height: var(--navbar-height);
    background: var(--navbar-bg);
    box-shadow: var(--navbar-shadow);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    padding-inline-start: max(var(--space-6), env(safe-area-inset-left, 0px));
    padding-inline-end: max(var(--space-6), env(safe-area-inset-right, 0px));
    gap: var(--space-4);
    min-width: 0;
    transition: left var(--transition-slow), right var(--transition-slow),
                background-color var(--transition), box-shadow var(--transition);
}

.sidebar.collapsed ~ .main-wrapper .top-navbar {
    left: var(--sidebar-collapsed);
}

.navbar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--fs-xl);
    transition: all var(--transition-fast);
}

.navbar-toggle:hover {
    background: var(--surface);
    color: var(--text-primary);
}

/* Search bar in navbar */
.navbar-search {
    flex: 1;
    max-width: 640px;
    position: relative;
    min-width: 0;
}

.navbar-search-row {
    display: flex;
    align-items: stretch;
    gap: var(--space-2);
    width: 100%;
}

.navbar-search-scope {
    flex: 0 0 auto;
    min-width: 7.5rem;
    max-width: 11rem;
    height: 42px;
    padding: 0 var(--space-3);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    font-family: var(--font-family);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
}

.navbar-search-scope:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.navbar-search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.navbar-search input {
    width: 100%;
    height: 42px;
    padding: 0 var(--space-4) 0 var(--space-10);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-full);
    font-size: var(--fs-base);
    font-family: var(--font-family);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    outline: none;
}

.navbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.navbar-search-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: var(--fs-md);
    pointer-events: none;
    z-index: 1;
}

.global-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: min(70vh, 480px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.12));
    z-index: 1200;
    padding: var(--space-2) 0;
}

.global-search-group-title {
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.global-search-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-3) var(--space-4);
    text-decoration: none;
    color: inherit;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: start;
    cursor: pointer;
}

.global-search-item:hover,
.global-search-item:focus,
.global-search-item.is-active {
    background: rgba(var(--primary-rgb), 0.08);
    outline: none;
}

.global-search-item-primary {
    font-weight: 600;
    color: var(--text-primary);
}

.global-search-item-secondary {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.global-search-item-meta {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.global-search-footer,
.global-search-empty,
.global-search-loading {
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.global-search-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.global-search-footer a:hover {
    text-decoration: underline;
}

[dir="rtl"] .navbar-search-icon {
    left: auto;
    right: var(--space-4);
}

[dir="rtl"] .navbar-search input {
    padding: 0 var(--space-10) 0 var(--space-4);
}

[dir="rtl"] .navbar-search-input-wrap .navbar-search-icon {
    left: auto;
    right: var(--space-4);
}

[dir="rtl"] .navbar-search-input-wrap input {
    padding: 0 var(--space-10) 0 var(--space-4);
}

/* Navbar right actions */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-inline-start: auto;
    flex-shrink: 0;
}

.navbar-notification-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.navbar-store-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
}

.navbar-store-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light, var(--surface));
}

.navbar-store-link i {
    font-size: var(--fs-base);
    line-height: 1;
    flex-shrink: 0;
}

.navbar-store-external {
    font-size: 0.7rem !important;
    opacity: 0.75;
}

.navbar-action-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--fs-lg);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.navbar-action-btn:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.navbar-action-btn .notification-count {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    inset-inline-start: auto;
    min-width: 18px;
    max-width: 2.25rem;
    height: 18px;
    padding: 0 4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: notificationPulse 2s infinite;
    z-index: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

.navbar-action-btn .notification-count[hidden] {
    display: none !important;
    animation: none;
}

.navbar-action-btn.has-unread i {
    color: var(--primary);
}

.navbar-action-btn.bell-pulse {
    animation: bellShake 0.6s ease;
}

@keyframes bellShake {
    0%, 100% { transform: rotate(0); }
    15% { transform: rotate(12deg); }
    30% { transform: rotate(-10deg); }
    45% { transform: rotate(8deg); }
    60% { transform: rotate(-6deg); }
    75% { transform: rotate(3deg); }
}

@keyframes notificationPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Navbar user profile */
.navbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: none;
    background: transparent;
}

.navbar-user:hover {
    background: var(--surface);
}

.navbar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--info));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: var(--fs-base);
}

.navbar-user-info {
    text-align: start;
}

.navbar-user-name {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.navbar-user-role {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* Language toggle */
.lang-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 40px;
    padding: 0 var(--space-3);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
    flex-shrink: 0;
}

.lang-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ========================================================================
   MAIN CONTENT AREA
   ======================================================================== */
.main-wrapper {
    flex: 1;
    min-width: 0;
    margin-inline-start: var(--sidebar-width);
    transition: margin var(--transition-slow);
}

.sidebar.collapsed ~ .main-wrapper {
    margin-inline-start: var(--sidebar-collapsed);
}

.main-content {
    padding-top: calc(var(--navbar-height) + var(--space-6));
    padding-bottom: var(--space-6);
    padding-inline-start: max(var(--space-6), env(safe-area-inset-left, 0px));
    padding-inline-end: max(var(--space-6), env(safe-area-inset-right, 0px));
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Page header — sticky on all authenticated Dashboard screens (below fixed navbar) */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    position: sticky;
    top: var(--navbar-height);
    z-index: 1025;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    /* Bleed into main-content horizontal padding so the bar covers the full content width */
    margin-inline-start: calc(-1 * max(var(--space-6), env(safe-area-inset-left, 0px)));
    margin-inline-end: calc(-1 * max(var(--space-6), env(safe-area-inset-right, 0px)));
    padding-inline-start: max(var(--space-6), env(safe-area-inset-left, 0px));
    padding-inline-end: max(var(--space-6), env(safe-area-inset-right, 0px));
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-6);
    /* Allow dropdowns / menus from the action bar to paint above scrolling content */
    overflow: visible;
}

.page-header > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.page-header .page-breadcrumb {
    margin-top: var(--space-1);
}

.page-header-actions .bi,
.page-header .view-all-link .bi {
    line-height: 1;
}

[dir="rtl"] .view-all-link .bi-arrow-right {
    transform: scaleX(-1);
}

[data-theme="dark"] .page-header {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.page-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.page-subtitle {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.page-breadcrumb a {
    color: var(--text-secondary);
}

.page-breadcrumb a:hover {
    color: var(--primary);
}

.page-breadcrumb .separator {
    font-size: var(--fs-xs);
}

/* ========================================================================
   MOBILE / TABLET SIDEBAR OVERLAY
   Stacking: content < overlay < sidebar < top navbar (toggle stays clickable)
   ======================================================================== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition), visibility var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.sidebar-mobile-open {
    overflow: hidden;
    overscroll-behavior: none;
}

body.sidebar-mobile-open .sidebar-nav {
    overscroll-behavior: contain;
}

body.sidebar-mobile-open .top-navbar {
    z-index: 1060;
}

body.sidebar-mobile-open .sidebar {
    z-index: 1055;
}

body.sidebar-mobile-open .sidebar-overlay {
    z-index: 1050;
}

/* ========================================================================
   RTL SUPPORT
   ======================================================================== */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
}

[dir="rtl"] .sidebar .nav-link.active::before {
    left: auto;
    right: 0;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

[dir="rtl"] .top-navbar {
    left: 0;
    right: var(--sidebar-width);
}

[dir="rtl"] .sidebar.collapsed ~ .main-wrapper .top-navbar {
    right: var(--sidebar-collapsed);
    left: 0;
}

[dir="rtl"] .navbar-search-icon {
    left: auto;
    right: var(--space-4);
}

[dir="rtl"] .navbar-search input {
    padding: 0 var(--space-10) 0 var(--space-4);
}

/* ========================================================================
   LOADER / SPLASH
   ======================================================================== */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-6);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.page-loader .loader-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    animation: loaderPulse 1.5s ease-in-out infinite;
}

.page-loader .loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(27, 111, 168, 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.page-loader .loader-text {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 500;
    letter-spacing: 0.05em;
}

@keyframes loaderPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.08); opacity: 0.8; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================================================
   NOTIFICATION DROPDOWN
   ======================================================================== */
.notification-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    width: 380px;
    max-height: 480px;
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    display: none;
    overflow: hidden;
}

[dir="rtl"] .notification-dropdown {
    right: auto;
    left: 0;
}

.notification-dropdown.show {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.notification-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--surface-border);
}

.notification-dropdown-header h6 {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.notification-dropdown-body {
    max-height: 350px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--surface-border);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.notification-item:hover {
    background: var(--surface-hover);
}

.notification-item.unread {
    background: var(--primary-light);
}

.notification-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--fs-md);
}

.notification-item-content {
    flex: 1;
    min-width: 0;
}

.notification-item-title {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.notification-item-message {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.notification-item-time {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.notification-dropdown-footer {
    padding: var(--space-3);
    text-align: center;
    border-top: 1px solid var(--surface-border);
}

.notification-dropdown-footer a {
    font-size: var(--fs-sm);
    font-weight: 600;
}

/* ========================================================================
   USER ACCOUNT DROPDOWN (single, custom implementation — matches the
   notification dropdown pattern; no Bootstrap data-bs-toggle involved)
   ======================================================================== */
.navbar-user-dropdown {
    position: relative;
}

.navbar-user-menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    inset-inline-end: 0;
    min-width: 240px;
    max-width: min(300px, calc(100vw - var(--space-4)));
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    display: none;
    overflow: hidden;
    padding: var(--space-2) 0;
}

.navbar-user-menu.show {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
}

.navbar-user-menu-info {
    padding: var(--space-3) var(--space-4);
}

.navbar-user-menu-name {
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    word-break: break-word;
}

.navbar-user-menu-email {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-top: 2px;
    word-break: break-word;
}

.navbar-user-menu-role {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.navbar-user-menu-divider {
    margin: var(--space-2) 0;
    border: 0;
    border-top: 1px solid var(--surface-border);
}

.navbar-user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-base);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.navbar-user-menu-item:hover,
.navbar-user-menu-item:focus {
    background: var(--surface);
    color: var(--text-primary);
}

.navbar-user-menu-item.active {
    background: var(--surface);
    color: var(--primary);
    font-weight: 600;
}

.navbar-user-menu-item.active i {
    color: var(--primary);
}

.navbar-user-menu-item i {
    font-size: var(--fs-lg);
    color: var(--text-muted);
}

.navbar-user-menu-item--danger,
.navbar-user-menu-item--danger i {
    color: var(--danger, #dc3545);
}

.navbar-user-menu-item--danger:hover,
.navbar-user-menu-item--danger:focus {
    color: var(--danger, #dc3545);
}
