/* --- Global Glassmorphism System --- */

/* Body & Backgrounds */
body {
    background-color: var(--color-bg-base);
    color: var(--color-text-main);
    font-family: var(--font-family-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;

    /* Fluid Mesh Gradient Background */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(37, 99, 235, 0.08) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(124, 58, 237, 0.08) 0%, transparent 25%);
    background-attachment: fixed;
}

/* Dark Mode Mesh - Deeper & Richer */
[data-theme="dark"] body {
    background-color: #0b0f19;
    /* Almost Black Blue */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(37, 99, 235, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(124, 58, 237, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 50% 10%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body {
        background-color: #0b0f19;
        background-image:
            radial-gradient(circle at 15% 50%, rgba(37, 99, 235, 0.15) 0%, transparent 40%),
            radial-gradient(circle at 85% 30%, rgba(124, 58, 237, 0.15) 0%, transparent 40%),
            radial-gradient(circle at 50% 10%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
    }
}

/* --- Components: Glass Card --- */
.card,
.glass {
    background: var(--color-bg-glass);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    transition: var(--transition-base);
    overflow: hidden;
    /* For inner borders */
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    /* Lift effect */
    border-color: rgba(255, 255, 255, 0.2);
    /* Subtle highlight */
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-4) var(--spacing-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: var(--spacing-6);
}

/* --- Layout --- */
/* --- Layout --- */
.layout-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--color-bg-glass-strong);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--color-border);
    /* Full border */
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 12px;
    /* Margin top */
    height: calc(100vh - 24px);
    /* Full height minus margins */
    margin: 12px;
    /* Float effect */
    border-radius: 18px;
    /* Rounded corners */
    z-index: 1001;
    color: var(--color-text-main);
    padding: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    /* Deep shadow */
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Profile (macOS Header Style) */
.sidebar-profile {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    transition: background 0.2s;
}

.sidebar-profile:hover {
    background: rgba(125, 125, 125, 0.1);
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    /* Circular */
    object-fit: cover;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-title);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}


/* Sidebar Profile Section (Hero Style) */
.sidebar-profile {
    padding: 10px 20px 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 10px;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    /* Smooth rounded corners */
    object-fit: cover;
    border: 2px solid var(--color-bg-base);
    box-shadow: var(--shadow-sm);
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text-title);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sidebar Header (Logo - Now optional or moved) */
.sidebar-brand-section {
    padding: 20px 24px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}


/* Navigation Links */
/* Navigation Links (macOS Style) */
.nav-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px;
    /* Reduced side padding */
}

.nav-section-title {
    margin: 16px 0 6px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--color-text-muted);
    opacity: 0.6;
}

.nav-link {
    position: relative;
    padding: 6px 12px;
    /* Compact padding */
    border-radius: 6px;
    /* macOS rounded corners */
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text-main);
    transition: background 0.15s ease;
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 2px;
    font-size: 0.85rem;
    /* Smaller font match macOS */
}

/* Icon Squircle Simulation (Dynamic Colors) */
.nav-link {
    --nav-color: var(--color-primary);
    /* Default Fallback */
}

.nav-link svg {
    padding: 5px;
    /* Use color-mix for 15% opacity tint of the specific color */
    background: color-mix(in srgb, var(--nav-color) 15%, transparent);
    border-radius: 6px;
    /* Squircle */
    width: 28px;
    height: 28px;
    box-sizing: content-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--nav-color);
}

/* Hover State */
.nav-link:hover {
    background: rgba(125, 125, 125, 0.08);
}

/* "Alive" Effect: Solid Color on Hover */
.nav-link:hover svg {
    background: var(--nav-color);
    color: white;
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 4px 10px color-mix(in srgb, var(--nav-color) 40%, transparent);
}


/* Active State - macOS Blue */
.nav-link.active {
    background: #007AFF;
    /* macOS Blue */
    color: white !important;
    box-shadow: none;
}

.nav-link.active svg {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.nav-link.active:hover {
    background: #007AFF;
    /* Maintain blue on hover */
}

/* Badges */
.nav-badge {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-badge.danger {
    background: #ef4444;
}

.nav-badge.warning {
    background: #f59e0b;
    color: black;
}


/* Submenu / Accordion */
/* Submenu / Accordion */
.nav-group-trigger {
    cursor: pointer;
    justify-content: space-between;
}

.nav-chevron {
    width: 8px !important;
    height: 8px !important;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6;
    margin-right: 4px;
}

.nav-group-trigger[aria-expanded="true"] {
    color: var(--color-text-title);
    background: rgba(125, 125, 125, 0.05);
}

.nav-group-trigger[aria-expanded="true"] .nav-chevron {
    transform: rotate(45deg);
    /* Down arrow */
    opacity: 1;
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-left: 20px;
    /* Indent */
    position: relative;
}

.submenu::before {
    content: '';
    position: absolute;
    left: 21px;
    /* Center of indent */
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.08);
    /* Vertical guide line */
}

.submenu.open {
    max-height: 1500px;
    /* Increased to fit all items */
}

.submenu .nav-link {
    font-size: 0.85rem;
    padding: 8px 12px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.user-profile-card:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 70px;
    padding: 0 var(--spacing-6);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(4px);
    /* Subtle blur behind topbar */
}

.content-wrapper {
    padding: var(--spacing-6);
    max-width: 1400px;
    /* Wider for dashboard */
    margin: 0 auto;
    width: 100%;
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: var(--transition-base);
    border: 1px solid transparent;
    font-size: 0.9rem;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(var(--color-primary-rgb), 0.4);
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.btn-outline:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-main);
    border-color: var(--color-text-muted);
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
}

.btn-outline-primary:hover {
    background: rgba(var(--color-primary-rgb), 0.1);
}

/* --- Dashboard Specifics --- */
.stat-card {
    padding: var(--spacing-6);
    border-radius: var(--radius-lg);
    background: var(--color-bg-glass);
    border: var(--glass-border);
    position: relative;
    overflow: hidden;
    transition: var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text-title);
    line-height: 1.2;
}

.stat-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.15;
    transition: all 0.3s ease;
}

.stat-card:hover .stat-icon {
    transform: translateY(-50%) scale(1.1) rotate(-10deg);
    opacity: 0.25;
}

/* --- Login Specifics --- */
.login-input-group {
    margin-bottom: 1.5rem;
    position: relative;
    text-align: left;
}

.login-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-title);
    padding-left: 2px;
}

/* --- Inputs --- */
.form-control,
.form-select {
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-input-text);
    padding: 0.75rem 1rem;
    transition: var(--transition-base);
    backdrop-filter: blur(5px);
}

textarea.form-control {
    min-height: 150px;
    resize: vertical;
    line-height: 1.6;
}

.form-control:focus,
.form-select:focus {
    background: var(--color-input-bg-focus);
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(var(--color-primary-rgb), 0.15);
}

/* --- Animations --- */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Tables --- */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--color-text-main);
    border-collapse: separate;
    border-spacing: 0 8px;
    /* Space between rows */
}

.table th {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    padding: 1rem;
    border: none;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    background: var(--color-bg-glass);
    border: var(--glass-border);
}

.table tr td:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.table tr td:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}


/* --- Mobile --- */
#sidebar-close {
    display: none;
    /* Default hidden on desktop */
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--color-bg-base) !important;
        /* Solid for perf on mobile */
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .layout-container {
        flex-direction: column;
    }

    #menu-toggle {
        display: flex !important;
    }

    #sidebar-close {
        display: flex !important;
    }

    /* Show on mobile */
}

@media (min-width: 769px) {
    #menu-toggle {
        display: none !important;
    }
}