/* 49er Race Analyzer - Base Styles */
/* CSS Reset, Variables, Typography */

/* Import Inter + Space Grotesk fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================================================
   Light Theme (Default) - Soft Blue-Gray Nautical
   ============================================================================ */
:root {
    /* Primary Colors - Ocean Blues */
    --primary-color: #0369a1;
    --primary-hover: #075985;
    --primary-light: #0ea5e9;
    --secondary-color: #64748b;
    --secondary-hover: #475569;

    /* Background & Surface - Soft Blue-Gray */
    --background: #e4ecf4;
    --surface: #eef3f8;
    --surface-light: #dce6f0;
    --surface-dark: #cdd9e5;

    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;

    /* Border */
    --border-color: #c8d6e3;
    --border-strong: #a8bdd0;

    /* Status Colors */
    --success: #16a34a;
    --warning: #d97706;
    --error: #dc2626;

    /* Gain/Loss Colors */
    --gain-positive: #16a34a;
    --gain-negative: #dc2626;

    /* Tack Colors */
    --tack-port: #dc2626;
    --tack-port-bg: #fef2f2;
    --tack-starboard: #16a34a;
    --tack-starboard-bg: #f0fdf4;

    /* Zone Colors */
    --zone-1-2-bg: #dbeafe;
    --zone-1-2-text: #1e40af;
    --zone-3-4-bg: #ede9fe;
    --zone-3-4-text: #6d28d9;
    --zone-5-6-bg: #fef3c7;
    --zone-5-6-text: #b45309;
    --zone-7-8-bg: #fee2e2;
    --zone-7-8-text: #dc2626;

    /* Map background */
    --map-background: #aad3df;

    /* Layout Dimensions */
    --panel-width: 280px;
    --header-height: 64px;
    --playback-height: 100px;

    /* Sidebar - Always Dark Navy */
    --sidebar-bg: #001c4a;
    --sidebar-bg-hover: rgba(255,255,255,0.06);
    --sidebar-bg-active: rgba(104,250,221,0.08);
    --sidebar-border: rgba(255,255,255,0.08);
    --sidebar-text: rgba(255,255,255,0.55);
    --sidebar-text-hover: rgba(255,255,255,0.85);
    --sidebar-text-active: #ffffff;
    --sidebar-section-title: rgba(255,255,255,0.35);
    --sidebar-accent: #68fadd;
    --sidebar-accent-bg: rgba(104,250,221,0.1);
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 64px;

    /* Top Bar */
    --topbar-height: 56px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* ========================================================================
       Mobile Touch & Spacing
       ======================================================================== */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;

    /* Mobile input font size - prevents iOS zoom on focus */
    --font-size-mobile-input: 16px;

    /* iOS Safe Areas */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* ============================================================================
   Dark Theme - Classic Dark with Blue Accents
   ============================================================================ */
[data-theme="dark"] {
    /* Primary Colors */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #60a5fa;
    --secondary-color: #64748b;
    --secondary-hover: #475569;

    /* Background & Surface - Dark */
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --surface-dark: #0f172a;

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Border */
    --border-color: #334155;
    --border-strong: #475569;

    /* Tack Colors - Brighter for dark theme */
    --tack-port: #f87171;
    --tack-port-bg: rgba(239, 68, 68, 0.2);
    --tack-starboard: #4ade80;
    --tack-starboard-bg: rgba(34, 197, 94, 0.2);

    /* Zone Colors - Adjusted for dark theme */
    --zone-1-2-bg: rgba(59, 130, 246, 0.2);
    --zone-1-2-text: #60a5fa;
    --zone-3-4-bg: rgba(139, 92, 246, 0.2);
    --zone-3-4-text: #a78bfa;
    --zone-5-6-bg: rgba(245, 158, 11, 0.2);
    --zone-5-6-text: #fbbf24;
    --zone-7-8-bg: rgba(239, 68, 68, 0.2);
    --zone-7-8-text: #f87171;

    /* Map background */
    --map-background: #1a1a2e;

    /* Shadows - More prominent for dark theme */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography utilities */
.number {
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* Empty State */
.empty-state {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    padding: 20px;
}

/* No data message */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Selection */
::selection {
    background: var(--primary-light);
    color: white;
}

/* Focus styles */
:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.theme-toggle:hover {
    background: var(--surface-dark);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    :root {
        --panel-width: 240px;
    }
}

/* ============================================================================
   Mobile Utility Classes
   ============================================================================ */

/* Hide element on mobile (768px and below) */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show element only on mobile (hidden on desktop) */
@media (min-width: 769px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* Ensure touch-friendly tap target size */
.tap-target {
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
}

/* Horizontal scroll container with hidden scrollbar */
.scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.scroll-x::-webkit-scrollbar {
    display: none;
}

/* Full width on mobile */
@media (max-width: 768px) {
    .full-mobile {
        width: 100% !important;
    }
}

/* Sticky first column for tables */
.sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: inherit;
}
