@import url('editor-layout.css');
@import url('wizard.css');
@import url('epc-gauge.css');
@import url('tooltip.css');
@import url('generation.css');
@import url('activity-indicator.css');

/* ============================================
   Mango Ignite - Design System
   "Clean Light" - Modern, Light & Friendly
   ============================================ */

/* Design Tokens */
:root {
    /* ===========================================
       MANGO ACCENT PALETTE
       Change these values to rebrand the entire app
       =========================================== */
    --mango-50: #EFF6FF;     /* Lightest - subtle backgrounds */
    --mango-100: #DBEAFE;    /* Light - hover backgrounds */
    --mango-200: #BFDBFE;    /* Light-mid - borders, highlights */
    --mango-300: #60A5FA;    /* Light accent - secondary elements */
    --mango-400: #3B82F6;    /* Primary accent - buttons, links, active */
    --mango-500: #2563EB;    /* Dark accent - hover states */
    --mango-600: #1D4ED8;    /* Darker - gradient endpoints */
    --mango-700: #1E40AF;    /* Darkest */

    /* ===========================================
       NEUTRAL PALETTE
       =========================================== */
    --neutral-0: #FEFEFE;    /* Pure white */
    --neutral-50: #FBFBFB;   /* Off-white */
    --neutral-100: #F7F7F7;  /* Light gray */
    --neutral-150: #F9F9F9;  /* Silver light */
    --neutral-200: #E3E3E3;  /* Silver */
    --neutral-300: #D5D5D5;  /* Silver dark */
    --neutral-400: #A8A29E;  /* Mid gray */
    --neutral-500: #78716C;  /* Gray */
    --neutral-600: #57534E;  /* Dark gray */
    --neutral-700: #3D3D3D;  /* Charcoal light */
    --neutral-800: #292929;  /* Charcoal */
    --neutral-900: #141414;  /* Charcoal dark */
    --neutral-950: #0A0A0A;  /* Near black */

    /* Steel tints (for sidebar) */
    --steel-light: #F9FCFF;
    --steel-dark: #DEE4EA;

    /* ===========================================
       SEMANTIC COLORS
       =========================================== */
    --color-primary: var(--mango-400);
    --color-primary-hover: var(--mango-500);
    --color-primary-subtle: var(--mango-50);

    --color-success: #22C55E;
    --color-success-subtle: #DCFCE7;
    --color-warning: #EAB308;
    --color-warning-subtle: #FEF9C3;
    --color-error: #EF4444;
    --color-error-subtle: #FEE2E2;
    --color-info: var(--mango-400);
    --color-info-subtle: var(--mango-50);

    /* ===========================================
       SURFACES
       =========================================== */
    --surface-sidebar: var(--steel-light);
    --surface-sidebar-hover: var(--steel-dark);
    --surface-sidebar-active: color-mix(in srgb, var(--mango-400) 8%, transparent);
    --surface-body: var(--neutral-100);
    --surface-card: var(--neutral-0);
    --surface-elevated: var(--neutral-0);

    /* ===========================================
       TEXT
       =========================================== */
    --text-primary: var(--neutral-800);
    --text-secondary: var(--neutral-700);
    --text-muted: var(--neutral-500);
    --text-inverse: var(--neutral-0);
    --text-sidebar: var(--neutral-700);
    --text-sidebar-muted: var(--neutral-500);
    --text-accent: var(--mango-400);

    /* ===========================================
       BORDERS
       =========================================== */
    --border-default: var(--neutral-200);
    --border-subtle: var(--neutral-150);
    --border-sidebar: var(--neutral-200);
    --border-accent: var(--mango-200);

    /* Typography */
    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

    /* Font sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Border radius - Soft (8-12px) */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows - Softer, more diffuse */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03);
    --shadow-md: 0 2px 4px -1px rgb(0 0 0 / 0.04), 0 1px 2px -1px rgb(0 0 0 / 0.03);
    --shadow-lg: 0 4px 12px -2px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.04);
    --shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.03), 0 1px 2px -1px rgb(0 0 0 / 0.02);
    --shadow-card-hover: 0 4px 12px -2px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.04);
    --shadow-glow: 0 0 16px -4px rgba(59, 130, 246, 0.25);

    /* Transitions - Subtle, not bouncy */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 200ms;

    /* Animation easing - Subtle curves (no bounce) */
    --ease-bounce: var(--ease-out);
    --ease-spring: var(--ease-out);
    --ease-elastic: var(--ease-out);

    /* Animation durations */
    --duration-instant: 100ms;
    --duration-slow: 300ms;
    --duration-slower: 400ms;

    /* Stagger timing - Reduced */
    --stagger-base: 30ms;

    /* Layout */
    --sidebar-width: 56px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface-body);
}

#app {
    min-height: 100vh;
}

/* ============================================
   Typography
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 {
    font-size: var(--text-3xl);
}

h2 {
    font-size: var(--text-2xl);
}

h3 {
    font-size: var(--text-xl);
}

h4 {
    font-size: var(--text-lg);
}

p {
    color: var(--text-secondary);
    line-height: 1.7;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--color-primary-hover);
}

/* ============================================
   Layout
   ============================================ */
.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 12px;
    left: 12px;
    bottom: 12px;
    z-index: 50;
    display: flex;
    flex-direction: row;
    background: transparent;
    width: auto;
}

main {
    flex: 1;
    margin-left: calc(var(--sidebar-width) + 24px);
    min-height: 100vh;
    background: var(--surface-body);
}

.content {
    padding: var(--space-8);
    max-width: 1400px;
}

article.content {
    padding: var(--space-8);
}

/* Editor mode - remove padding and constraints */
.content.no-padding {
    padding: 0;
    max-width: none;
}

main.editor-active {
    display: flex;
    flex-direction: column;
}

main.editor-active .content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Remove old px-4 class */
.px-4 {
    padding-left: 0;
    padding-right: 0;
}

/* ============================================
   Navigation - Linear Icon Style
   ============================================ */

/* Outer container - holds both rail and flyout */
.nav-container {
    display: flex;
    flex-direction: row;
    height: 100%;
    padding: 8px;
    background: white;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: width 200ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
    position: relative;
    z-index: 49;
}

/* Nav rail - the icon sidebar inside the container */
.nav-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 52px;
    height: 100%;
    flex-shrink: 0;
    background: transparent;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    position: relative;
}

.nav-brand {
    flex-shrink: 0;
    width: 100%;
    margin: -1px -1px 12px -1px; /* Overlap the nav-rail border */
    padding: 0;
}

.nav-brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    width: calc(100% + 2px); /* Account for border overlap */
    height: 48px;
    background: linear-gradient(135deg, var(--mango-400) 0%, var(--mango-600) 100%);
    border-radius: 11px 11px 8px 8px; /* Match nav-rail inner radius at top, softer at bottom */
    color: white;
    transition: filter 0.15s ease;
}

.nav-brand-logo:hover {
    filter: brightness(1.08);
}

.nav-brand-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.nav-brand-icon svg {
    width: 20px;
    height: 20px;
}

.nav-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Container for main nav items with dynamic overflow */
/* Higher min-height ensures pinned items collapse FIRST before main nav items */
.nav-items-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    /* Reserve space for at least 2 nav items + overflow button (40px each + 12px gaps) */
    min-height: 132px; /* 40 + 12 + 40 + 12 + 40 - ensures nav items are prioritized */
    overflow: hidden;
}

/* Ensure space for "more" button when overflow exists */
.nav-items-container.has-overflow {
    min-height: 40px; /* At least show the "more" button */
}

.nav-items-container .nav-link {
    flex-shrink: 0;
}

.nav-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: auto;
    padding: 12px 0;
    flex-shrink: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: #6B7280;
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-link:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.06);
    color: var(--neutral-800);
}

.nav-link.active {
    color: var(--mango-400);
    border-color: transparent;
    background: transparent;
}

.nav-link.active .nav-icon {
    stroke: var(--mango-400);
}

/* Visual indicator that hovering will expand flyout with active content */
.nav-link.has-active-child:not(.active) {
    position: relative;
}

.nav-link.has-active-child:not(.active)::before {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--mango-400);
    border-radius: 50%;
    opacity: 0.6;
}

.nav-link.has-active-child:not(.active):hover::before {
    opacity: 1;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Notification badge on nav icons */
.nav-link-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    background: var(--color-info);
    color: white;
    font-size: 9px;
    font-weight: 600;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Overflow count on the unified "..." button */
.nav-overflow-count {
    position: absolute;
    top: 0px;
    right: 0px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    background: var(--text-muted);
    color: white;
    font-size: 9px;
    font-weight: 600;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nav-overflow-btn.active .nav-overflow-count {
    background: var(--mango-400);
}

/* Old CSS tooltips removed - now using JS-positioned TooltipPortal system
   which renders tooltips outside overflow-hidden containers */

/* ============================================
   Flyout Panel System
   ============================================ */

.nav-flyout-overlay {
    position: fixed;
    inset: 0;
    z-index: 48;
    /* Use visibility/opacity instead of display for Safari backdrop-filter compatibility */
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: transparent;
    cursor: default;
    /* Safari GPU optimization for backdrop-filter */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: visibility, opacity, backdrop-filter;
}

.nav-flyout-overlay.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.nav-flyout {
    width: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transition: width 200ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)),
                opacity 200ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)),
                margin 200ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

/* When flyout is open */
.nav-flyout.open {
    width: 220px;
    opacity: 1;
    margin-left: 6px;
}

/* Flyout Header */
.flyout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    flex-shrink: 0;
}

.flyout-back {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--mango-400);
    font-size: 14px;
    font-weight: 500;
    padding: 0;
}

.flyout-back:hover {
    color: var(--mango-500);
}

.flyout-back svg {
    width: 16px;
    height: 16px;
}

.flyout-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.flyout-header-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 6px;
    transition: all 0.15s ease;
    padding: 0;
}

.flyout-header-btn:hover {
    background: #F3F4F6;
    color: var(--neutral-800);
}

.flyout-header-btn svg {
    width: 16px;
    height: 16px;
}

/* Flyout Content - Scrollable */
.flyout-content {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.flyout-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Section Headers */
.flyout-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 16px 12px 6px;
}

.flyout-section-toggle {
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: #9CA3AF;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.flyout-section-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.flyout-section-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--neutral-800);
}

.flyout-section {
    overflow: hidden;
}

.flyout-section-items {
    transition: all 0.2s ease;
}

.flyout-section.collapsed .flyout-section-items {
    display: none;
}


/* Flyout Items */
.flyout-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--neutral-800);
    text-decoration: none;
    margin: 1px 6px;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.15s ease;
}

.flyout-item:hover {
    background: #F3F4F6;
}

/* Item count badge */
.flyout-item-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.flyout-item.active {
    background: transparent;
    color: var(--mango-400);
}

.flyout-item.active .flyout-icon {
    stroke: var(--mango-400);
}

.flyout-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}

.flyout-item:hover .flyout-icon,
.flyout-item.active .flyout-icon {
    opacity: 1;
}

/* Flyout Divider - now just spacing */
.flyout-divider {
    height: 8px;
    background: transparent;
    margin: 0;
}

/* User Avatar Section */
.nav-user-section {
    padding: 4px 0;
    display: flex;
    justify-content: center;
}

.nav-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    transition: all 0.15s ease;
    background: linear-gradient(135deg, var(--mango-100) 0%, var(--mango-200) 100%);
    border: 2px solid transparent;
}

.nav-avatar:hover {
    transform: scale(1.05);
    border-color: rgba(0, 0, 0, 0.08);
}

/* Avatar with image */
.nav-avatar.has-image {
    background-size: cover;
    background-position: center;
}

/* Storage Section (in flyout footer) */
.storage-section {
    padding: 12px;
    flex-shrink: 0;
    margin-top: auto;
    border-top: 1px solid #F3F4F6;
}

.storage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.storage-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--neutral-800);
}

.storage-label svg {
    color: var(--text-muted);
}

.storage-upgrade {
    font-size: 12px;
    padding: 4px 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
}

.storage-upgrade:hover {
    background: var(--neutral-100);
    border-color: rgba(0, 0, 0, 0.2);
}

.storage-bar {
    height: 4px;
    background: var(--neutral-150);
    border-radius: 2px;
    overflow: hidden;
    width: 85%;
}

.storage-fill {
    height: 100%;
    background: var(--mango-400);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.storage-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Flyout Footer with View Toggle */
.flyout-footer {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px;
    border-top: 1px solid #F3F4F6;
    flex-shrink: 0;
}

.view-toggle {
    display: flex;
    gap: 2px;
    background: #F3F4F6;
    padding: 2px;
    border-radius: 6px;
}

.view-toggle-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s ease;
    padding: 0;
}

.view-toggle-btn:hover {
    color: var(--neutral-800);
}

.view-toggle-btn.active {
    background: white;
    color: var(--mango-400);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.view-toggle-btn svg {
    width: 14px;
    height: 14px;
}

/* Flyout Tiles View */
.flyout-content.view-tiles .flyout-section-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 0 6px;
}

.flyout-content.view-tiles .flyout-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 8px;
    margin: 0;
    gap: 6px;
    height: 88px; /* Fixed height for consistent tile sizes */
    border: 1px solid transparent;
    background: #FAFAFA;
    overflow: hidden;
    /* Text styling for truncation */
    font-size: 12px;
    line-height: 1.3;
    word-break: break-word;
    hyphens: auto;
}

.flyout-content.view-tiles .flyout-item:hover {
    background: #F3F4F6;
    border-color: rgba(0, 0, 0, 0.04);
}

.flyout-content.view-tiles .flyout-item.active {
    background: var(--mango-50);
    border-color: var(--mango-100);
}

.flyout-content.view-tiles .flyout-icon {
    width: 22px;
    height: 22px;
    margin: 0;
}

.flyout-content.view-tiles .flyout-item-count {
    display: none;
}

/* Hide section headers in tiles view for cleaner look */
.flyout-content.view-tiles .flyout-section-header {
    padding: 12px 12px 8px;
}

.flyout-content.view-tiles .flyout-divider {
    height: 4px;
}

/* Focus-visible styles for keyboard navigation */
.nav-link:focus-visible {
    outline: 2px solid var(--mango-400);
    outline-offset: -2px;
}

.flyout-item:focus-visible {
    outline: 2px solid var(--mango-400);
    outline-offset: -2px;
}

.flyout-back:focus-visible {
    outline: 2px solid var(--mango-400);
    outline-offset: 2px;
}

/* Flyout scrollbar styling - hidden but scrollable */
.flyout-content {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.flyout-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Mobile responsiveness for flyout */
@media (max-width: 768px) {
    .sidebar {
        top: 8px;
        left: 8px;
        bottom: 8px;
    }

    .nav-flyout {
        width: 260px;
        max-width: calc(85vw - 64px);
    }

    .nav-flyout-overlay.active {
        background: rgba(0, 0, 0, 0.3);
    }
}

/* ============================================
   Cards - Clean Modern Style
   ============================================ */
.card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: all var(--duration-normal) var(--ease-out);
}

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

/* Clickable card with active state */
.card-clickable {
    cursor: pointer;
}

.card-clickable:active {
    transform: translateY(-2px) scale(0.99);
    transition-duration: 50ms;
}

/* Card with subtle accent border on hover */
.card-animated {
    position: relative;
}

.card-animated:hover {
    border-color: var(--mango-300);
}

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

.card-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-description {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

/* Feature Card (for home page) */
.feature-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-card);
    transition: all var(--duration-normal) var(--ease-out);
    animation: fade-in 0.3s var(--ease-out) forwards;
}

/* Staggered feature card entrance */
.feature-card:nth-child(1) { animation-delay: 0ms; }
.feature-card:nth-child(2) { animation-delay: 50ms; }
.feature-card:nth-child(3) { animation-delay: 100ms; }
.feature-card:nth-child(4) { animation-delay: 150ms; }
.feature-card:nth-child(5) { animation-delay: 200ms; }
.feature-card:nth-child(6) { animation-delay: 250ms; }

.feature-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--mango-300);
    transform: translateY(-2px);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: var(--mango-50);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
    color: var(--mango-400);
}

.feature-icon svg {
    width: 24px;
    height: 24px;
}

.feature-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.feature-description {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-6);
}

/* ============================================
   Buttons - Clean & Modern
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--mango-400);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--mango-400);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--mango-500);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: scale(0.98);
    transition-duration: 50ms;
}

.btn-secondary {
    background: var(--surface-card);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    background: var(--neutral-100);
    border-color: var(--neutral-300);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-ghost {
    background: transparent;
    color: var(--mango-400);
}

.btn-ghost:hover {
    background: var(--mango-50);
}

.btn-ghost:active {
    transform: scale(0.98);
}

.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* Button loading state */
.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn.loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: var(--space-2);
}

/* Button success state */
.btn.success {
    animation: spring-pop 0.3s var(--ease-bounce);
    background: var(--color-success) !important;
    border-color: var(--color-success) !important;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-out);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--mango-400);
    box-shadow: 0 0 0 3px var(--mango-100);
    transform: translateY(-1px);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* Form validation states */
.form-input.valid,
.form-select.valid,
.form-textarea.valid {
    border-color: var(--color-success);
}

.form-input.valid:focus,
.form-select.valid:focus,
.form-textarea.valid:focus {
    box-shadow: 0 0 0 3px var(--color-success-subtle);
}

.form-input.invalid,
.form-select.invalid,
.form-textarea.invalid {
    border-color: var(--color-error);
}

.form-input.invalid:focus,
.form-select.invalid:focus,
.form-textarea.invalid:focus {
    box-shadow: 0 0 0 3px var(--color-error-subtle);
}

/* ============================================
   Tables
   ============================================ */
.table-container {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--neutral-100);
    border-bottom: 1px solid var(--border-default);
}

.table td {
    padding: var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background-color var(--duration-fast) var(--ease-out);
}

.table tbody tr:hover {
    background: var(--neutral-100);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-primary {
    background: var(--mango-100);
    color: var(--mango-500);
}

.badge-success {
    background: var(--color-success-subtle);
    color: #047857;
}

.badge-warning {
    background: var(--color-warning-subtle);
    color: #B45309;
}

.badge-error {
    background: var(--color-error-subtle);
    color: #B91C1C;
}

.badge-info {
    background: var(--color-info-subtle);
    color: #1D4ED8;
}

/* ============================================
   Page Headers
   ============================================ */
.page-header {
    margin-bottom: var(--space-8);
}

.page-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    letter-spacing: -0.02em;
}

.page-description {
    font-size: var(--text-base);
    color: var(--text-secondary);
    max-width: 600px;
}

/* ============================================
   Stats Cards (Dashboard-style)
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-8);
}

.stat-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-card);
    transition: all var(--duration-normal) var(--ease-out);
}

.stat-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--mango-300);
}

.stat-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
}

.stat-change {
    font-size: var(--text-xs);
    font-weight: 500;
    margin-top: var(--space-1);
}

.stat-change.positive {
    color: var(--color-success);
}

.stat-change.negative {
    color: var(--color-error);
}

/* ============================================
   Loading States
   ============================================ */
.loading-progress {
    position: relative;
    display: block;
    width: 6rem;
    height: 6rem;
    margin: 25vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--neutral-200);
    stroke-width: 0.4rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--mango-400);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--mango-500);
    inset: calc(25vh + 2rem) 0 auto 0;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--neutral-200);
    border-top-color: var(--mango-400);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Animation Keyframes - Subtle & Smooth
   ============================================ */

/* Simple fade animation */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Legacy bounce-in (simplified to fade) */
@keyframes bounce-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spring-pop {
    from { transform: scale(0.98); }
    to { transform: scale(1); }
}

/* Slide & Fade Animations */
@keyframes slide-up-fade {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slide-down-fade {
    from { transform: translateY(-8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slide-in-left {
    from { transform: translateX(-12px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-in-right {
    from { transform: translateX(12px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Page Transitions */
@keyframes page-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes page-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Loading & Skeleton Animations */
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Toast Animations - Simplified */
@keyframes toast-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-slide-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes toast-progress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ============================================
   Animation Utility Classes
   ============================================ */

/* Duration utilities */
.animate-fast { animation-duration: var(--duration-fast); }
.animate-normal { animation-duration: var(--duration-normal); }
.animate-slow { animation-duration: var(--duration-slow); }
.animate-slower { animation-duration: var(--duration-slower); }

/* Delay utilities for staggered animations */
.delay-1 { animation-delay: calc(var(--stagger-base) * 1); }
.delay-2 { animation-delay: calc(var(--stagger-base) * 2); }
.delay-3 { animation-delay: calc(var(--stagger-base) * 3); }
.delay-4 { animation-delay: calc(var(--stagger-base) * 4); }
.delay-5 { animation-delay: calc(var(--stagger-base) * 5); }
.delay-6 { animation-delay: calc(var(--stagger-base) * 6); }
.delay-7 { animation-delay: calc(var(--stagger-base) * 7); }
.delay-8 { animation-delay: calc(var(--stagger-base) * 8); }

/* Animation application classes */
.animate-bounce-in {
    animation: bounce-in 0.5s var(--ease-bounce);
}

.animate-slide-up {
    animation: slide-up-fade 0.3s var(--ease-out);
}

.animate-slide-down {
    animation: slide-down-fade 0.3s var(--ease-out);
}

.animate-slide-left {
    animation: slide-in-left 0.3s var(--ease-out);
}

.animate-slide-right {
    animation: slide-in-right 0.3s var(--ease-out);
}

.animate-wiggle {
    animation: wiggle 0.5s ease-in-out;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

.animate-spring-pop {
    animation: spring-pop 0.3s var(--ease-bounce);
}

.animate-error-shake {
    animation: error-shake 0.4s ease-in-out;
}

/* Fill mode utilities */
.animate-fill-both {
    animation-fill-mode: both;
}

.animate-fill-forwards {
    animation-fill-mode: forwards;
}

/* Page transition wrapper */
.page-transition {
    animation-fill-mode: both;
}

.page-transition.page-enter {
    animation: page-fade-in 0.3s var(--ease-out);
}

.page-transition.page-exit {
    animation: page-fade-out 0.15s var(--ease-out);
}

/* ============================================
   Skeleton Loading States
   ============================================ */

/* Base skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--neutral-200) 0%,
        var(--neutral-150) 50%,
        var(--neutral-200) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

/* Skeleton variants */
.skeleton-text {
    height: 1rem;
    width: 100%;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-title {
    height: 2rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
    width: 100%;
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: var(--radius-md);
}

.skeleton-badge {
    height: 24px;
    width: 60px;
    border-radius: var(--radius-full);
}

/* Skeleton table row */
.skeleton-row {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.skeleton-row .skeleton {
    flex: 1;
}

/* Skeleton stat card */
.skeleton-stat {
    padding: var(--space-5);
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.skeleton-stat .skeleton-badge {
    margin-bottom: var(--space-3);
}

.skeleton-stat .skeleton-title {
    margin-bottom: var(--space-2);
}

.skeleton-stat .skeleton-text {
    width: 40%;
}

/* ============================================
   Toast Notifications
   ============================================ */

/* Toast container */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
    width: 100%;
    pointer-events: none;
}

/* Individual toast */
.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

/* Toast entrance/exit animations */
.toast-enter {
    animation: toast-slide-in 0.4s var(--ease-bounce);
}

.toast-exit {
    animation: toast-slide-out 0.3s var(--ease-out) forwards;
}

/* Toast variants */
.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-error); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-info { border-left-color: var(--color-info); }

.toast-success .toast-icon { color: var(--color-success); }
.toast-error .toast-icon { color: var(--color-error); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info .toast-icon { color: var(--color-info); }

/* Toast parts */
.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-icon svg {
    width: 100%;
    height: 100%;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.4;
}

.toast-dismiss {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast);
    padding: 0;
}

.toast-dismiss:hover {
    background: var(--neutral-150);
    color: var(--text-primary);
}

/* Progress bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    animation: toast-progress linear forwards;
}

/* Responsive */
@media (max-width: 480px) {
    .toast-container {
        top: auto;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

/* ============================================
   Modal & Dialog Animations
   ============================================ */

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    animation: modal-overlay-in 0.2s var(--ease-out);
}

.modal-overlay.closing {
    animation: modal-overlay-out 0.15s var(--ease-out) forwards;
}

@keyframes modal-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-overlay-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Modal content */
.modal-content {
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-content-in 0.3s var(--ease-bounce);
}

.modal-overlay.closing .modal-content {
    animation: modal-content-out 0.15s var(--ease-out) forwards;
}

@keyframes modal-content-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modal-content-out {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
}

/* Modal header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast);
}

.modal-close:hover {
    background: var(--neutral-150);
    color: var(--text-primary);
}

/* Modal body */
.modal-body {
    padding: var(--space-6);
}

/* Modal footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--border-subtle);
}

/* ============================================
   Error UI
   ============================================ */
#blazor-error-ui {
    background: var(--color-error);
    color: white;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-sm);
    display: none;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.8;
}

#blazor-error-ui .dismiss:hover {
    opacity: 1;
}

#blazor-error-ui .reload {
    color: white;
    text-decoration: underline;
    margin-left: var(--space-2);
}

/* ============================================
   Grid Utilities
   ============================================ */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: 1fr;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

.gap-8 {
    gap: var(--space-8);
}

/* Flex utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

/* ============================================
   Admin Pages
   ============================================ */
.admin-page {
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    margin-bottom: var(--space-8);
    gap: var(--space-4);
    flex-wrap: wrap;
}

.page-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-description {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: var(--space-2) 0 0 0;
}

/* Tables */
.table-container {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    border-bottom: 2px solid var(--border-default);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
}

.data-table tbody tr {
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background: var(--neutral-100);
}

/* Badges */
.badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: capitalize;
}

/* Button variants */
.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
}

.btn-danger {
    background: var(--color-error);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.action-buttons {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* Loading and empty states */
.loading {
    text-align: center;
    padding: var(--space-12);
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-8);
    color: var(--text-secondary);
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: var(--space-4);
}

.empty-state p {
    font-size: var(--text-lg);
    margin-bottom: var(--space-6);
}

/* ============================================
   Admin Layout
   ============================================ */
.admin-layout .sidebar {
    border-right-color: var(--mango-700);
}

.admin-layout .nav-menu::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg, var(--mango-400) 0%, var(--mango-600) 100%);
}

.admin-icon {
    background: linear-gradient(135deg, var(--neutral-600) 0%, var(--neutral-800) 100%) !important;
}

.nav-link-back {
    background: rgba(212, 96, 160, 0.1);
    border-left: 3px solid var(--mango-400);
    margin-left: -3px;
}

.nav-link-back:hover {
    background: rgba(212, 96, 160, 0.2);
    border-left-color: var(--mango-400);
}

.nav-link-back .nav-icon {
    color: var(--mango-400);
    opacity: 1;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    main {
        margin-left: 0;
    }

    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }

    .content,
    article.content {
        padding: var(--space-4);
    }
}

/* ============================================
   Google Places Autocomplete & Safari Autofill Fixes
   ============================================ */

/* Google Places Autocomplete dropdown - ensure it's above Safari's autofill bubble */
.pac-container {
    z-index: 99999 !important;
    position: absolute !important;
    background-color: var(--surface-card, #FFFFFF) !important;
    border: 1px solid var(--border-default, #E2E8F0) !important;
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.08)) !important;
    margin-top: 4px !important;
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
    /* Add top padding to prevent Safari autofill from obscuring first item */
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

/* Style individual autocomplete items */
.pac-item {
    padding: 10px 16px !important;
    font-size: var(--text-sm, 0.875rem) !important;
    color: var(--text-primary, #0F172A) !important;
    cursor: pointer !important;
    border: none !important;
    border-bottom: 1px solid var(--border-subtle, #F1F5F9) !important;
    line-height: 1.5 !important;
}

.pac-item:first-child {
    /* Extra padding on first item to ensure it's not obscured by Safari autofill */
    padding-top: 12px !important;
    border-top-left-radius: var(--radius-md, 8px) !important;
    border-top-right-radius: var(--radius-md, 8px) !important;
}

.pac-item:last-child {
    border-bottom: none !important;
    border-bottom-left-radius: var(--radius-md, 8px) !important;
    border-bottom-right-radius: var(--radius-md, 8px) !important;
}

.pac-item:hover,
.pac-item-selected {
    background-color: var(--mango-50, #EFF6FF) !important;
}

.pac-item-query {
    font-size: var(--text-sm, 0.875rem) !important;
    color: var(--text-primary, #0F172A) !important;
    font-weight: 500 !important;
}

.pac-matched {
    font-weight: 600 !important;
    color: var(--mango-500, #2563EB) !important;
}

.pac-icon {
    margin-right: 12px !important;
}

/* Hide the "powered by Google" logo if desired, or style it */
.pac-logo::after {
    padding: 8px 16px !important;
    background-color: var(--neutral-100, #F7F7F7) !important;
    border-top: 1px solid var(--border-subtle, #F1F5F9) !important;
}

/* Safari-specific autofill prevention and z-index fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific fixes */
    .pac-container {
        z-index: 999999 !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }
}

/* Prevent Safari from showing its autofill icon/bubble over our dropdown */
input[type="text"]::-webkit-contacts-auto-fill-button,
input[type="text"]::-webkit-credentials-auto-fill-button {
    visibility: hidden !important;
    display: none !important;
    pointer-events: none !important;
    position: absolute !important;
    right: 0 !important;
}

/* Additional Safari autofill prevention */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--surface-card, white) inset !important;
    -webkit-text-fill-color: var(--text-primary, #0F172A) !important;
    transition: background-color 5000s ease-in-out 0s !important;
}

/* ============================================
   Accessibility - Reduced Motion Support
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .skeleton {
        animation: none;
        background: var(--neutral-200);
    }

    .page-transition {
        animation: none;
    }

    .toast-enter,
    .toast-exit {
        animation: none;
    }

    .modal-overlay,
    .modal-content {
        animation: none;
    }
}

/* ============================================
   Responsive Sidebar
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(calc(-100% - 24px));
    }

    main {
        margin-left: 0;
    }
}

/* ============================================
   Global Nav Auto-Hide for Editor Mode
   ============================================ */

.page.nav-auto-hidden main {
    margin-left: 0;
    transition: margin-left var(--duration-normal, 200ms) var(--ease-out, ease-out);
}

.sidebar.auto-hidden {
    transform: translateX(calc(-100% - 24px));
    opacity: 0;
    pointer-events: none;
    transition: all var(--duration-normal, 200ms) var(--ease-out, ease-out);
}

/* Ensure smooth transition when nav becomes visible again */
.sidebar:not(.auto-hidden) {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    transition: all var(--duration-normal, 200ms) var(--ease-out, ease-out);
}

/* ============================================
   Pinned Items Feature
   ============================================ */

/* Flyout Item Wrapper for pin button */
.flyout-item-wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.flyout-item-wrapper .flyout-item {
    flex: 1;
}

.flyout-item-pin {
    position: absolute;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0;
    transition: all 0.15s ease;
    padding: 0;
}

.flyout-item-wrapper:hover .flyout-item-pin {
    opacity: 1;
}

.flyout-item-pin:hover {
    background: #F3F4F6;
    color: var(--neutral-800);
}

.flyout-item-pin.pinned {
    opacity: 1;
    color: var(--mango-400);
}

.flyout-item-pin.pinned:hover {
    background: var(--mango-50);
}

.flyout-item-pin svg {
    width: 14px;
    height: 14px;
}

/* Pin button positioning in tile view - top right corner */
.flyout-content.view-tiles .flyout-item-wrapper {
    position: relative;
    display: block; /* Override flex for tile layout */
    height: 88px; /* Match flyout-item height */
}

.flyout-content.view-tiles .flyout-item-wrapper .flyout-item {
    flex: none; /* Override flex: 1 from base wrapper */
    width: 100%;
    height: 100%;
}

.flyout-content.view-tiles .flyout-item-pin {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
}

.flyout-content.view-tiles .flyout-item-pin svg {
    width: 12px;
    height: 12px;
}

/* Nav Rail Pinned Items */

/* Container for dynamic pinned items calculation via ResizeObserver */
.nav-pinned-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

/* When pins exist, just ensure separator is visible (items collapse into unified overflow) */
.nav-pinned-container.has-pins {
    min-height: 17px; /* separator height - pinned items can fully collapse */
}

.nav-pinned-container .nav-link {
    flex-shrink: 0;
}

.nav-pinned-separator {
    width: 24px;
    height: 1px;
    background: rgba(0, 0, 0, 0.2);
    margin: 8px auto;
    flex-shrink: 0;
}

/* ============================================
   Reusable Nav Collapsible Zone Component
   ============================================ */

.nav-collapsible-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

.nav-collapsible-zone .nav-link {
    flex-shrink: 0;
}

.nav-zone-separator {
    width: 24px;
    height: 1px;
    background: rgba(0, 0, 0, 0.2);
    margin: 0 auto;
    flex-shrink: 0;
}

/* Zone with primary priority - doesn't shrink easily */
.nav-collapsible-zone.zone-primary {
    flex-shrink: 0;
}

/* Zone with secondary priority - shrinks first */
.nav-collapsible-zone.zone-secondary {
    flex: 1;
}

.nav-pinned {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

/* More Flyout for overflow pinned items */
.nav-more-flyout {
    position: absolute;
    left: 100%;
    bottom: 0;
    width: 200px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: all 0.2s ease;
}

.nav-more-flyout.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.nav-more-flyout .flyout-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--neutral-800);
    text-decoration: none;
    font-size: 13px;
}

.nav-more-flyout .flyout-item:hover {
    background: #F3F4F6;
}

.nav-more-flyout .flyout-item.active {
    background: var(--mango-50);
    color: var(--mango-400);
}

.nav-more-flyout .flyout-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ============================================
   Nav Overflow Popover - Unified for all collapsed items
   ============================================ */

.nav-overflow-popover {
    position: absolute;
    left: 60px; /* Position to the right of the nav rail */
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 8px;
    z-index: 1001;
    min-width: 200px;
    max-height: 80vh;
    overflow-y: auto;
    animation: nav-overflow-appear 0.15s ease-out;
}

@keyframes nav-overflow-appear {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* Section divider within unified popover */
.nav-overflow-section + .nav-overflow-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.nav-overflow-header {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 10px 4px;
}

.nav-overflow-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--neutral-800);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s ease;
}

.nav-overflow-item:hover {
    background: #F3F4F6;
}

.nav-overflow-item.active {
    background: var(--mango-50);
    color: var(--mango-400);
}

.nav-overflow-item.active .nav-overflow-icon {
    stroke: var(--mango-400);
}

.nav-overflow-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-overflow-item:hover .nav-overflow-icon,
.nav-overflow-item.active .nav-overflow-icon {
    opacity: 1;
}

.nav-overflow-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: var(--mango-400);
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ============================================
   Flyout Glass Effect - Content Change Indicator
   ============================================ */

/* Base transition setup for smooth glass effect */
.nav-flyout-overlay.active {
    transition: opacity 200ms var(--ease-out, ease-out),
                background 300ms var(--ease-out, ease-out),
                backdrop-filter 300ms var(--ease-out, ease-out),
                -webkit-backdrop-filter 300ms var(--ease-out, ease-out);
}

/* Glass effect active - appears when content changes behind flyout */
.nav-flyout-overlay.active.glass-active {
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* Glass fading out - user moved mouse to acknowledge */
.nav-flyout-overlay.active.glass-fading {
    background: transparent;
    -webkit-backdrop-filter: blur(0px);
    backdrop-filter: blur(0px);
    transition: opacity 200ms var(--ease-out, ease-out),
                background 400ms var(--ease-out, ease-out),
                backdrop-filter 400ms var(--ease-out, ease-out),
                -webkit-backdrop-filter 400ms var(--ease-out, ease-out);
}

/* Reduced motion - instant transitions */
@media (prefers-reduced-motion: reduce) {
    .nav-flyout-overlay.active,
    .nav-flyout-overlay.active.glass-active,
    .nav-flyout-overlay.active.glass-fading {
        transition: none;
    }
}