/* ============================================
   NEW DESIGN SYSTEM - "The Elevated Dashboard"
   Replaces Metronic layout CSS
   ============================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Primary */
    --ds-primary: #1E3A8A;
    --ds-primary-container: #00236f;
    --ds-primary-dim: #162d6b;
    --ds-on-primary: #ffffff;

    /* Secondary */
    --ds-secondary: #505f76;
    --ds-secondary-container: #d0e1fb;
    --ds-on-secondary-container: #54647a;

    /* Tertiary */
    --ds-tertiary: #4b1c00;
    --ds-tertiary-container: #6e2c00;

    /* Surface hierarchy */
    --ds-surface: #f7f9fb;
    --ds-surface-container: #eceef0;
    --ds-surface-container-high: #e6e8ea;
    --ds-surface-container-highest: #e0e3e5;
    --ds-surface-container-low: #f2f4f6;
    --ds-surface-container-lowest: #ffffff;
    --ds-surface-dim: #d8dadc;

    /* Text */
    --ds-on-surface: #191c1e;
    --ds-on-surface-variant: #444651;

    /* Outline */
    --ds-outline: #757682;
    --ds-outline-variant: #c5c5d3;

    /* Error */
    --ds-error: #ba1a1a;
    --ds-error-container: #ffdad6;

    /* Inverse */
    --ds-inverse-surface: #2d3133;
    --ds-inverse-on-surface: #eff1f3;

    /* Roundness */
    --ds-radius-sm: 0.25rem;
    --ds-radius-md: 0.375rem;
    --ds-radius-lg: 0.5rem;
    --ds-radius-xl: 0.75rem;
    --ds-radius-full: 9999px;

    /* Shadows (tinted, diffused) */
    --ds-shadow-ambient: 0 4px 24px rgba(25, 28, 30, 0.04);
    --ds-shadow-hover: 0 8px 32px rgba(25, 28, 30, 0.08);
    --ds-shadow-float: 0 12px 40px rgba(25, 28, 30, 0.12);

    /* Layout */
    --sidebar-width: 200px;
    --sidebar-collapsed-width: 64px;
    --header-height: 56px;

    /* Transitions */
    --ds-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--ds-on-surface);
    background-color: var(--ds-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Manrope', 'Inter', sans-serif;
    font-weight: 700;
    color: var(--ds-on-surface);
    margin: 0;
}

/* --- App Shell Layout --- */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--ds-surface);
}

/* --- Sidebar (Light theme - matches mockup) --- */
.app-sidebar-new {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--ds-surface-container-lowest);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: width var(--ds-transition), transform var(--ds-transition);
    overflow: hidden;
    /* No border - use tonal shift from content area */
}

.app-sidebar-new.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Logo */
.sidebar-logo {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    flex-shrink: 0;
    gap: 0.625rem;
}

.sidebar-logo .logo-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--ds-primary), var(--ds-primary-container));
    border-radius: var(--ds-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo .logo-icon svg,
.sidebar-logo .logo-icon i {
    color: #fff;
    font-size: 0.8125rem;
}

.sidebar-logo .logo-text {
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: 0.875rem;
    color: var(--ds-on-surface);
    white-space: nowrap;
    overflow: hidden;
    line-height: 1.2;
}

.sidebar-logo .logo-text small {
    display: block;
    font-size: 0.5625rem;
    font-weight: 600;
    color: var(--ds-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-logo img {
    height: 24px;
    transition: opacity var(--ds-transition);
}

.sidebar-logo .logo-mini {
    display: none;
}

.app-sidebar-new.collapsed .sidebar-logo .logo-full,
.app-sidebar-new.collapsed .sidebar-logo .logo-text {
    display: none;
}

.app-sidebar-new.collapsed .sidebar-logo .logo-mini {
    display: block;
    margin: 0 auto;
}

.app-sidebar-new.collapsed .sidebar-logo {
    justify-content: center;
    padding: 0;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    width: 28px;
    height: 28px;
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface-container-low);
    border: none;
    color: var(--ds-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: auto;
    transition: background var(--ds-transition);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--ds-surface-container);
    color: var(--ds-primary);
}

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform var(--ds-transition);
}

.app-sidebar-new.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0.5rem 1rem 0.625rem;
    scrollbar-width: thin;
    scrollbar-color: var(--ds-surface-container-high) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: var(--ds-surface-container-high);
    border-radius: 4px;
}

/* Menu Item */
.menu-item-new {
    margin-bottom: 6px;
}

.menu-item-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.875rem;
    padding: 0.625rem 1rem;
    border-radius: var(--ds-radius-md);
    color: var(--ds-on-surface-variant);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ds-transition);
    white-space: nowrap;
    overflow: hidden;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    height: 42px;
}

.menu-item-link:hover {
    background: rgba(30, 58, 138, 0.06);
    color: var(--ds-primary);
}

.menu-item-link.active {
    background: rgba(30, 58, 138, 0.1);
    color: var(--ds-primary);
    font-weight: 600;
}

.menu-item-icon {
    width: 24px;
    min-width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.125rem;
}

.menu-item-link.active .menu-item-icon {
    color: var(--ds-primary);
}

.menu-item-text {
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Inter', sans-serif;
}

.app-sidebar-new.collapsed .menu-item-text {
    display: none;
}

.app-sidebar-new.collapsed .menu-item-link {
    justify-content: center;
    padding: 0.5rem;
    border-radius: var(--ds-radius-md);
}

/* Sidebar Upgrade Button */
.sidebar-upgrade-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(100% - 1.5rem);
    margin: 0 0.75rem 0.75rem;
    height: 42px;
    border-radius: var(--ds-radius-full);
    border: none;
    background: linear-gradient(135deg, var(--ds-primary), var(--ds-primary-container));
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ds-transition);
}

.sidebar-upgrade-btn:hover {
    box-shadow: 0 4px 16px rgba(30, 58, 138, 0.35);
    transform: translateY(-1px);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem 0.625rem;
    flex-shrink: 0;
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: var(--ds-radius-md);
    color: var(--ds-on-surface-variant);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: all var(--ds-transition);
}

.sidebar-footer-link:hover {
    background: rgba(30, 58, 138, 0.06);
    color: var(--ds-on-surface);
}

.sidebar-footer-link i {
    font-size: 1.125rem;
    width: 24px;
    min-width: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Main Content Area --- */
.app-main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--ds-transition);
}

.app-sidebar-new.collapsed ~ .app-main-area {
    margin-left: var(--sidebar-collapsed-width);
}

/* --- Header --- */
.app-header-new {
    height: var(--header-height);
    background: var(--ds-surface-container-lowest);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(16px);
    background: rgba(255, 255, 255, 0.92);
    gap: 1rem;
}

/* Header Search Bar */
.header-search {
    flex: 0 1 360px;
    position: relative;
}

.header-search-input {
    width: 100%;
    height: 38px;
    padding: 0 0.875rem 0 2.5rem;
    border-radius: var(--ds-radius-full);
    border: none;
    background: var(--ds-surface-container-low);
    color: var(--ds-on-surface);
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    outline: none;
    transition: all var(--ds-transition);
}

.header-search-input::placeholder {
    color: var(--ds-on-surface-variant);
}

.header-search-input:focus {
    background: var(--ds-surface-container);
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
}

.header-search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ds-on-surface-variant);
    font-size: 0.875rem;
    pointer-events: none;
}

/* Header CTA Button */
.header-cta-btn {
    height: 38px;
    padding: 0 1.25rem;
    border-radius: var(--ds-radius-full);
    border: none;
    background: linear-gradient(135deg, var(--ds-primary), var(--ds-primary-container));
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--ds-transition);
    flex-shrink: 0;
}

.header-cta-btn:hover {
    box-shadow: 0 4px 16px rgba(30, 58, 138, 0.35);
    transform: translateY(-1px);
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1;
    min-width: 0;
}

.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.75rem;
}

.header-breadcrumb li {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--ds-on-surface-variant);
}

.header-breadcrumb li a {
    color: var(--ds-primary);
    text-decoration: none;
    font-weight: 500;
}

.header-breadcrumb li a:hover {
    text-decoration: underline;
}

.header-breadcrumb li + li::before {
    content: '/';
    color: var(--ds-outline-variant);
    font-size: 0.6875rem;
}

.header-page-title {
    font-family: 'Manrope', sans-serif;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--ds-on-surface);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Header Action Buttons */
.header-action-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--ds-radius-md);
    border: none;
    background: var(--ds-surface-container-low);
    color: var(--ds-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ds-transition);
    position: relative;
}

.header-action-btn:hover {
    background: var(--ds-surface-container);
    color: var(--ds-primary);
}

.header-action-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ds-tertiary);
    border: 2px solid var(--ds-surface-container-lowest);
}

/* User Avatar */
.header-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--ds-radius-md);
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    transition: box-shadow var(--ds-transition);
}

.header-user-avatar:hover {
    box-shadow: var(--ds-shadow-hover);
}

.header-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: var(--ds-surface-container-lowest);
    border-radius: var(--ds-radius-xl);
    box-shadow: var(--ds-shadow-float);
    padding: 0.5rem;
    z-index: 1050;
    backdrop-filter: blur(16px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--ds-transition);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
}

.user-dropdown-name {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--ds-on-surface);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--ds-surface-container);
    margin: 0.25rem 0.5rem;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--ds-radius-md);
    color: var(--ds-on-surface);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background var(--ds-transition);
}

.user-dropdown-item:hover {
    background: var(--ds-surface-container-low);
}

.user-dropdown-item.danger {
    color: var(--ds-error);
}

/* --- Page Content --- */
.app-page-content {
    flex: 1;
    padding: 1.25rem 1.5rem;
    background: var(--ds-surface-container-low);
}

/* --- Notification Dropdown --- */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--ds-surface-container-lowest);
    border-radius: var(--ds-radius-xl);
    box-shadow: var(--ds-shadow-float);
    backdrop-filter: blur(16px);
    z-index: 1050;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--ds-transition);
}

.notification-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.notification-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--ds-primary), var(--ds-primary-container));
    color: #fff;
}

.notification-header h3 {
    font-family: 'Manrope', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.notification-tabs {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
}

.notification-tab {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: all var(--ds-transition);
}

.notification-tab.active {
    color: #fff;
    border-bottom-color: #fff;
}

.notification-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 0.5rem;
}

.notification-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--ds-on-surface-variant);
    font-size: 0.8125rem;
}

.notification-footer {
    padding: 0.75rem;
    text-align: center;
}

.notification-footer a {
    color: var(--ds-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
}

/* --- Mobile Sidebar Overlay --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 15, 33, 0.5);
    z-index: 1035;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.show {
    display: block;
}

/* Mobile Toggle */
.mobile-sidebar-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: var(--ds-radius-md);
    border: none;
    background: var(--ds-surface-container-low);
    color: var(--ds-on-surface);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 0.75rem;
}

/* --- Responsive --- */
@media (max-width: 991.98px) {
    .app-sidebar-new {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .app-sidebar-new.mobile-open {
        transform: translateX(0);
    }

    .app-main-area {
        margin-left: 0 !important;
    }

    .mobile-sidebar-toggle {
        display: flex;
    }

    .header-breadcrumb {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .app-page-content {
        padding: 1rem;
    }

    .app-header-new {
        padding: 0 1rem;
    }
}

/* --- Utility: Ghost Border (for inputs in layout) --- */
.ghost-border {
    border: 1.5px solid rgba(145, 180, 228, 0.15);
}

/* --- Scrollbar global --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--ds-surface-container-high);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ds-outline-variant);
}
