/**
 * Supply Panel Main Styles
 *
 * Custom styles for the Supply Portal.
 */

/* ========================================
   THEME CSS VARIABLES - Light/Dark Mode
   ======================================== */

:root {
    /* Light Mode (default) - FtN cream theme from stash */
    --sp-bg-page: #f5f2ed;
    --sp-bg-topbar: #ffffff;
    --sp-bg-card: #ffffff;
    --sp-bg-card-hover: #ebe7e1;
    --sp-bg-input: #ebe7e1;
    --sp-bg-dropdown: #ffffff;
    --sp-nav-bg: #ebe7e1;
    --sp-nav-border: #d4d8d6;
    --sp-nav-item-active-bg: #006654;
    --sp-nav-item-hover-bg: #d4d8d6;
    --sp-border-default: #d4d8d6;
    --sp-border-subtle: #ebe7e1;
    --sp-text-primary: #1a3b32;
    --sp-text-secondary: #4b5563;
    --sp-text-muted: #6b7280;
    --sp-text-inverted: #ffffff;
    --sp-chart-grid: #ebe7e1;
    --sp-chart-axis: #6b7280;
    --sp-accent-positive: #15803d;
}

.dark {
    /* Dark Mode */
    --sp-bg-page: #006654;
    --sp-bg-topbar: #000000;
    --sp-bg-card: #000000;
    --sp-bg-card-hover: #111111;
    --sp-bg-input: #111111;
    --sp-bg-dropdown: #000000;
    --sp-nav-bg: #111111;
    --sp-nav-border: #222222;
    --sp-nav-item-active-bg: #006654;
    --sp-nav-item-hover-bg: #1a1a1a;
    --sp-border-default: #222222;
    --sp-border-subtle: #111111;
    --sp-text-primary: #ffffff;
    --sp-text-secondary: #888888;
    --sp-text-muted: #666666;
    --sp-text-inverted: #ffffff;
    --sp-chart-grid: #111111;
    --sp-chart-axis: #666666;
    --sp-accent-positive: #10b981;
}

/* ========================================
   CSS VARIABLE OVERRIDES - Filament Grays
   ======================================== */

.dark,
.dark .fi-body,
.dark[data-theme="dark"] {
    /* Filament gray color variables - RGB format (dark mode only) */
    --gray-50: 0 0 0 !important;
    --gray-100: 0 0 0 !important;
    --gray-200: 17 17 17 !important;
    --gray-300: 34 34 34 !important;
    --gray-400: 68 68 68 !important;
    --gray-500: 102 102 102 !important;
    --gray-600: 136 136 136 !important;
    --gray-700: 0 0 0 !important;
    --gray-800: 0 0 0 !important;
    --gray-900: 0 0 0 !important;
    --gray-950: 0 0 0 !important;

    /* Filament component-specific variables */
    --c-50: 0 0 0 !important;
    --c-100: 0 0 0 !important;
    --c-200: 17 17 17 !important;
    --c-300: 34 34 34 !important;
    --c-400: 68 68 68 !important;
    --c-700: 0 0 0 !important;
    --c-800: 0 0 0 !important;
    --c-900: 0 0 0 !important;
    --c-950: 0 0 0 !important;
}

/* ========================================
   DROPDOWN MENUS - Theme Aware
   ======================================== */

.fi-dropdown-panel,
.fi-dropdown-list,
.fi-dropdown-list-item,
.fi-dropdown-header,
.fi-dropdown-trigger,
[class*="fi-dropdown"],
.fi-ac-panel,
.fi-modal-content,
.fi-ta-panel {
    background: var(--sp-bg-dropdown) !important;
    background-color: var(--sp-bg-dropdown) !important;
    border-color: var(--sp-border-default) !important;
}

.fi-dropdown-list-item:hover,
.fi-dropdown-list-item-button:hover {
    background: var(--sp-bg-card-hover) !important;
    background-color: var(--sp-bg-card-hover) !important;
}

/* ========================================
   NUCLEAR OVERRIDE - Grey backgrounds (Dark Mode Only)
   ======================================== */

/* Target Tailwind's dark mode grey classes directly */
.dark .bg-gray-900,
.dark .bg-gray-800,
.dark .bg-gray-950,
.dark [class*="bg-gray-9"],
.dark [class*="bg-gray-8"],
.dark .bg-\[\#111827\],
.dark .bg-\[\#1f2937\] {
    background: #000 !important;
    background-color: #000 !important;
}

/* ========================================
   TOPBAR / HEADER - Theme Aware
   ======================================== */

/* Topbar uses theme variables */
.fi-topbar,
.fi-topbar nav,
.fi-topbar-ctn,
.fi-topbar > div,
.fi-topbar > nav,
.fi-topbar > nav > div,
header.fi-topbar,
.fi-layout > header,
.fi-topbar-item,
.fi-topbar-item-label,
.fi-avatar,
.fi-user-menu {
    background: var(--sp-bg-topbar) !important;
    background-color: var(--sp-bg-topbar) !important;
}

.fi-topbar {
    border-bottom: 1px solid var(--sp-border-default) !important;
}

/* Align logo with page content */
.fi-topbar .fi-logo {
    margin-left: 1rem;
}

/* Override any Tailwind gray backgrounds in the header area (dark mode) */
.dark .fi-layout > header [class*="bg-"],
.dark .fi-topbar [class*="bg-"] {
    background: var(--sp-bg-topbar) !important;
    background-color: var(--sp-bg-topbar) !important;
}

/* Page header area */
.fi-header,
.fi-header-heading,
.fi-page-header {
    background: transparent !important;
    background-color: transparent !important;
}

/* Breadcrumbs and title */
.fi-header-heading {
    color: var(--sp-text-primary) !important;
}

/* ========================================
   SIDEBAR - Keep default green theme
   ======================================== */

/* Sidebar uses the panel's primary color (green) - no overrides needed */

/* ========================================
   MAIN CONTENT AREA - Theme Aware
   ======================================== */

.fi-main {
    background: var(--sp-bg-page) !important;
}

.fi-main-ctn {
    background: transparent !important;
}

/* ========================================
   KPI CARDS - Modern Dashboard Style
   ======================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    transition: box-shadow 0.2s ease;
}

.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dark .kpi-card {
    background: #1f2937;
    border-color: #374151;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.dark .kpi-label {
    color: #9ca3af;
}

.kpi-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.dark .kpi-value {
    color: #f9fafb;
}

.kpi-change {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.kpi-change.positive {
    color: #059669;
}

.kpi-change.negative {
    color: #dc2626;
}

.dark .kpi-change.positive {
    color: #34d399;
}

.dark .kpi-change.negative {
    color: #f87171;
}

/* Smooth scroll behavior for section navigation */
html {
    scroll-behavior: smooth;
}

/* Add offset for sticky header when scrolling to anchors */
[id^="section-"] {
    scroll-margin-top: 8rem;
}

/* Hide scrollbar for section nav overflow */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Section nav active state via IntersectionObserver (optional enhancement) */
.section-nav-link.active {
    color: var(--primary-600);
    background-color: var(--primary-50);
}

.dark .section-nav-link.active {
    color: var(--primary-400);
    background-color: rgba(var(--primary-900), 0.3);
}

/* ========================================
   PROFILE DROPDOWN - Professional Styling
   ======================================== */

/* User header in dropdown */
.sp-user-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--sp-border-subtle);
    margin-bottom: 4px;
}

.sp-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #006654 0%, #004d3d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.sp-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sp-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--sp-text-primary);
    line-height: 1.3;
}

.sp-user-meta {
    font-size: 11px;
    color: var(--sp-text-muted);
    margin-top: 1px;
}

/* Dropdown panel with polished animation */
.fi-user-menu .fi-dropdown-panel {
    min-width: 240px !important;
    border-radius: 12px !important;
    border: 1px solid var(--sp-border-default) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12) !important;
    overflow: hidden !important;
    animation: sp-dropdown-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    transform-origin: top right !important;
}

@keyframes sp-dropdown-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.dark .fi-user-menu .fi-dropdown-panel {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
}

/* Menu items */
.fi-user-menu .fi-dropdown-list {
    padding: 4px 8px 8px 8px !important;
}

.fi-user-menu .fi-dropdown-list-item {
    border-radius: 8px !important;
    padding: 10px 12px !important;
    transition: background 0.15s ease !important;
}

/* Sign out - red hover */
.fi-user-menu .fi-dropdown-list-item:last-child:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

.fi-user-menu .fi-dropdown-list-item:last-child:hover .fi-dropdown-list-item-label {
    color: #dc2626 !important;
}

.dark .fi-user-menu .fi-dropdown-list-item:last-child:hover {
    background: rgba(248, 113, 113, 0.15) !important;
}

.dark .fi-user-menu .fi-dropdown-list-item:last-child:hover .fi-dropdown-list-item-label {
    color: #f87171 !important;
}
