/* ==========================================================================
   Fetch.Portal Core Styles & Anti-FOUC Architecture
   ========================================================================== */

/* Critical initial paint styles before Tailwind JIT compilation */
html {
    background-color: #ebebeb;
    color: #2d2d2d;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color-scheme: light;
}

html.dark {
    background-color: #121212;
    color: #f2f2f2;
    color-scheme: dark;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #ebebeb;
    color: #2d2d2d;
    font-family: 'Satoshi', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    accent-color: var(--color-primary, #618264);
    transition: background-color 150ms ease, color 150ms ease;
}

html.dark body {
    background-color: #121212;
    color: #f2f2f2;
    accent-color: var(--color-primary, #618264);
}

/* Anti-FOUC Barrier: Hides content until Tailwind JIT and fonts settle, then smoothly reveals */
html:not(.tw-ready) body {
    opacity: 0 !important;
    visibility: hidden !important;
}

html.tw-ready body {
    opacity: 1 !important;
    visibility: visible !important;
    transition: opacity 120ms ease-out;
}

/* Hide un-evaluated Alpine elements before Alpine renders */
[x-cloak] {
    display: none !important;
}

/* Critical Desktop Sidebar Layout to prevent layout shift before Tailwind loads */
#dashboardSidebar {
    width: 5rem;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    background-color: #ebebeb;
    z-index: 50;
    transition: background-color 150ms ease;
}

html.dark #dashboardSidebar {
    background-color: #121212;
}

/* Dark theme adjustments for sidebar navigation rails */
html.dark nav[data-nav-group],
html.dark div[data-nav-group],
html.dark nav[data-mobile-nav-group] {
    background-color: #1c1c1c !important;
    border-color: #2e2e2e !important;
}

/* Navigation rails */
.nav-indicator,
.mobile-nav-indicator {
    background-color: var(--brand-1, #618264) !important;
}

html.dark .nav-indicator,
html.dark .mobile-nav-indicator {
    background-color: var(--brand-1, #618264) !important;
}

.nav-indicator + a[aria-current="page"],
[data-nav-link][aria-current="page"],
[data-mobile-nav-link][aria-current="page"],
html.dark .nav-indicator + a[aria-current="page"],
html.dark [data-nav-link][aria-current="page"],
html.dark [data-mobile-nav-link][aria-current="page"] {
    color: #ffffff !important;
}

/* Dark mode overrides for common containers and cards */
html.dark .bg-white {
    background-color: #1c1c1c !important;
}

html.dark .bg-neutral-50,
html.dark .bg-neutral-50\/80,
html.dark .bg-neutral-50\/60 {
    background-color: #161616 !important;
}

html.dark .bg-neutral-100 {
    background-color: #262626 !important;
    color: #e5e5e5 !important;
}

html.dark .bg-neutral-200 {
    background-color: #333333 !important;
    color: #f2f2f2 !important;
}

html.dark .bg-\[\#ebebeb\],
html.dark .bg-\[\#ebebeb\]\/95 {
    background-color: rgba(18, 18, 18, 0.95) !important;
}

html.dark [class*="border-neutral-"],
html.dark [class*="border-gray-"],
html.dark [class*="border-slate-"],
html.dark .border-neutral-200,
html.dark .border-neutral-200\/80,
html.dark .border-neutral-200\/70,
html.dark .border-neutral-200\/60,
html.dark .border-neutral-200\/50,
html.dark .border-neutral-300,
html.dark .border-neutral-100 {
    border-color: #2b2b2b !important;
}

html.dark [class*="bg-neutral-50"] {
    background-color: #161616 !important;
}

html.dark .text-\[\#2d2d2d\] {
    color: #f2f2f2 !important;
}

html.dark .text-neutral-700,
html.dark .text-neutral-800,
html.dark .text-neutral-600 {
    color: #d4d4d4 !important;
}

html.dark .text-neutral-500,
html.dark .text-neutral-400 {
    color: #949494 !important;
}

html.dark .divide-neutral-100 > :not([hidden]) ~ :not([hidden]),
html.dark .divide-neutral-200 > :not([hidden]) ~ :not([hidden]) {
    border-color: #262626 !important;
}

html.dark .hover\:bg-neutral-50:hover,
html.dark .hover\:bg-neutral-100:hover {
    background-color: #262626 !important;
}

html.dark .hover\:bg-white:hover {
    background-color: #242424 !important;
}

html.dark input:not([type="checkbox"]):not([type="radio"]),
html.dark select,
html.dark textarea {
    background-color: #171717 !important;
    border-color: #383838 !important;
    color: #f2f2f2 !important;
}

html.dark input:focus,
html.dark select:focus,
html.dark textarea:focus {
    border-color: #e5e5e5 !important;
}



main[role="main"] {
    min-height: 100vh;
    width: 100%; 
} 

@media (min-width: 640px) {
    main[role="main"] {
        padding-left: 5rem;
    }
}

/* Smooth Native Browser View Transitions between pages */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 140ms;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* GPU-Accelerated Hardware Composited Sliding Rail Indicator with Gradient */
.nav-indicator {
    position: absolute;
    left: 5px;
    top: 5px;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-ui, 6px);
    background: linear-gradient(135deg, var(--brand-2, #79ac78) 0%, var(--brand-1, #618264) 100%) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
    pointer-events: none;
    will-change: transform, opacity;
    transform: translate3d(0, 0, 0);
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease;
    z-index: 1;
}

.mobile-nav-indicator {
    position: absolute;
    top: 0.375rem;
    left: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-ui, 6px);
    background: linear-gradient(135deg, var(--brand-2, #79ac78) 0%, var(--brand-1, #618264) 100%) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
    pointer-events: none;
    will-change: transform, opacity;
    transform: translate3d(0, 0, 0);
    transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease;
    z-index: 1;
}

/* Centering and smooth text color transition for navigation icon links */
[data-nav-link], [data-mobile-nav-link] {
    transition: color 150ms ease, opacity 150ms ease;
}

[data-nav-link].active, [data-mobile-nav-link].active {
    color: #ffffff !important;
}

/* ==========================================================================
   Fetch Tabs (<fetch-tabs>) Isolated Component Styles with Linear Gradient
   ========================================================================== */
fetch-tabs {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-ui, 6px);
    padding: 3px;
    gap: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    user-select: none;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-tap-highlight-color: transparent;
}

html.dark fetch-tabs {
    background: #1c1c1c;
    border-color: #2e2e2e;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

fetch-tabs::-webkit-scrollbar {
    display: none;
}

fetch-tabs .fetch-tabs-indicator {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: calc(var(--radius-ui, 6px) - 2px);
    background: linear-gradient(135deg, var(--brand-2, #79ac78) 0%, var(--brand-1, #618264) 100%) !important;
    pointer-events: none;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
    will-change: transform, width, height;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), width 0.28s cubic-bezier(0.16, 1, 0.3, 1), height 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Tab button/link reset & defaults */
fetch-tabs > button,
fetch-tabs > a,
fetch-tabs > [role="tab"] {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 600;
    border-radius: calc(var(--radius-ui, 6px) - 2px);
    border: none !important;
    background: transparent !important;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: color 0.18s ease, opacity 0.18s ease;
    color: #525252 !important;
}

html.dark fetch-tabs > button,
html.dark fetch-tabs > a,
html.dark fetch-tabs > [role="tab"] {
    color: #a3a3a3 !important;
}

fetch-tabs > button:hover:not([aria-selected="true"]):not([data-active="true"]),
fetch-tabs > a:hover:not([aria-selected="true"]):not([data-active="true"]),
fetch-tabs > [role="tab"]:hover:not([aria-selected="true"]):not([data-active="true"]) {
    color: #171717 !important;
}

html.dark fetch-tabs > button:hover:not([aria-selected="true"]):not([data-active="true"]),
html.dark fetch-tabs > a:hover:not([aria-selected="true"]):not([data-active="true"]),
html.dark fetch-tabs > [role="tab"]:hover:not([aria-selected="true"]):not([data-active="true"]) {
    color: #ffffff !important;
}

/* Active tab text and icons ALWAYS pure white */
fetch-tabs > [aria-selected="true"],
fetch-tabs > [data-active="true"],
fetch-tabs > button[aria-selected="true"],
fetch-tabs > a[aria-selected="true"],
fetch-tabs > [role="tab"][aria-selected="true"] {
    color: #ffffff !important;
    font-weight: 700 !important;
}

fetch-tabs > [aria-selected="true"] i,
fetch-tabs > [aria-selected="true"] span:not([data-tab-badge]),
fetch-tabs > [data-active="true"] i,
fetch-tabs > [data-active="true"] span:not([data-tab-badge]) {
    color: #ffffff !important;
}

/* Tab badges (e.g. step counters) */
fetch-tabs [data-tab-badge],
fetch-tabs .fetch-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    line-height: 1;
    font-family: monospace;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    transition: background-color 0.18s ease, color 0.18s ease;
    background-color: #e5e5e5;
    color: #404040;
}

html.dark fetch-tabs [data-tab-badge],
html.dark fetch-tabs .fetch-tab-badge {
    background-color: #2e2e2e;
    color: #d4d4d4;
}

fetch-tabs > [aria-selected="true"] [data-tab-badge],
fetch-tabs > [data-active="true"] [data-tab-badge],
fetch-tabs > [aria-selected="true"] .fetch-tab-badge,
fetch-tabs > [data-active="true"] .fetch-tab-badge {
    background-color: rgba(0, 0, 0, 0.28) !important;
    color: #ffffff !important;
}

[data-nav-link] i, [data-mobile-nav-link] i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 1em;
    height: 1em;
}

/* Progress bar / pulse for SPA background fetch */
#spa-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-1, var(--color-primary, #3368a0)) 0%, var(--brand-2, #66a3bf) 50%, var(--brand-3, #c8dfdb) 100%);
    box-shadow: 0 0 10px var(--brand-1, var(--color-primary, #3368a0));
    z-index: 99999;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: 0% 50%;
    transition: transform 200ms ease-out, opacity 100ms ease-in;
    pointer-events: none;
}

#spa-progress-bar.active {
    opacity: 1;
    transform: scaleX(0.75);
}

#spa-progress-bar.done {
    opacity: 0;
    transform: scaleX(1);
}

/* ==========================================================================
   Crisp Numeric Indicators & Contrast-Aware Text Shadows
   ========================================================================== */
.num-glow-dark,
.text-shadow-dark {
    text-shadow: 0 0 2px #7d7d7d;
}

.text-2xl.num-glow-dark,
.text-3xl.num-glow-dark,
.text-4xl.num-glow-dark,
.text-5xl.num-glow-dark,
.text-2xl.text-shadow-dark,
.text-3xl.text-shadow-dark,
.text-4xl.text-shadow-dark,
.text-5xl.text-shadow-dark {
    text-shadow: 0 0 2px #7d7d7d;
}

.num-glow-light,
.text-shadow-light {
    text-shadow: 0 0 2px #ffffff;
}

/* Adaptive class: defaults to dark glow (#7d7d7d), switches to white glow inside dark containers */
.num-glow {
    text-shadow: 0 0 2px #7d7d7d;
}

.bg-\[\#1a1a1a\] .num-glow,
.bg-\[\#2d2d2d\] .num-glow,
.bg-neutral-900 .num-glow,
.bg-black .num-glow,
.text-white .num-glow,
.text-white.num-glow {
    text-shadow: 0 0 2px #ffffff;
}

/* ==========================================================================
   Industrial Auth Canvas & Blueprint Patterns
   ========================================================================== */
.auth-blueprint-grid {
    background-color: #ebebeb;
    background-image: 
        radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px),
        linear-gradient(to right, rgba(0, 0, 0, 0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
    background-size: 24px 24px, 120px 120px, 120px 120px;
}

.auth-dark-blueprint,
.auth-dark-dots {
    background-color: #141414;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 24px 24px;
}

@keyframes live-pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.08); opacity: 0.4; }
}

.animate-pulse-glow {
    animation: live-pulse-glow 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes wave-dash {
    to {
        stroke-dashoffset: -100;
    }
}

.animate-waveform {
    stroke-dasharray: 8, 4;
    animation: wave-dash 4s linear infinite;
}

