/**
 * 1-FOUNDATION.CSS
 * 
 * CSS Variables, resets, base typography, and foundational styles.
 * This file has NO layout rules - only tokens and base element styles.
 * 
 * UPDATED: Phase 1 Fixes Applied
 * - Typography sizes reduced for information density
 * - Spacing converted to rem units
 * - Border radius adjusted
 * - Border color updated to match design principles
 * - New variables added (hero font size, icon sizes, backdrop opacity)
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */

:root {
    /* Colors */
    --bg-primary: #212121;
    --bg-secondary: #2f2f2f;
    --bg-tertiary: #3a3a3a;
    --bg-hover: rgba(255, 255, 255, 0.05);
    
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --text-muted: #8e8e8e;
    
    --accent-primary: #c47c4e;
    --success: #5ebd90;
    --danger: #d45859;
    --warning: #d4a249;
    
    --border: #444444;  /* UPDATED: Was #3a3a3a */
    
    /* Spacing Scale - UPDATED: Converted to rem units */
    --spacing-xs: 0.25rem;   /* 4px */
    --spacing-sm: 0.5rem;    /* 8px */
    --spacing-md: 0.75rem;   /* 12px */
    --spacing-lg: 1rem;      /* 16px */
    --spacing-xl: 1.5rem;    /* 24px */
    --spacing-2xl: 2rem;     /* 32px */
    
    /* Border Radius - UPDATED: Reduced md and lg values */
    --radius-sm: 4px;
    --radius-md: 6px;        /* Was 8px */
    --radius-lg: 8px;        /* Was 12px */
    --radius-full: 9999px;
    
    /* Typography - UPDATED: Reduced sizes for information density */
    --font-size-tiny: 0.7rem;      /* 11.2px - Was 0.75rem (12px) */
    --font-size-small: 0.75rem;    /* 12px - Was 0.875rem (14px) */
    --font-size-base: 0.85rem;     /* 13.6px - Was 1rem (16px) */
    --font-size-h1: 1.1rem;        /* 17.6px - Was 2rem (32px) */
    --font-size-h2: 1rem;          /* 16px - Was 1.5rem (24px) */
    --font-size-h3: 0.95rem;       /* 15.2px - Was 1.25rem (20px) */
    --font-size-hero: 2rem;        /* NEW - For P&L display only */
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    --line-height-tight: 1.25;
    --line-height-base: 1.5;
    --line-height-relaxed: 1.75;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Z-Index Scale */
    --z-base: 1;
    --z-sidebar: 100;
    --z-header: 1000;
    --z-backdrop: 9998;
    --z-modal: 9999;
    --z-toast: 10000;
    
    /* Layout Dimensions - Compact for information density */
    --header-height: 40px;
    --sidebar-width-collapsed: 48px;
    --sidebar-width-expanded: 180px;
    
    /* Content Scaling (for panel system) */
    --content-scale: 1;
    --panel-push-margin: 0px;
    
    /* NEW VARIABLES - Added in Phase 1 */
    
    /* Backdrop opacity for overlays */
    --backdrop-opacity: 0.5;
    
    /* Icon sizes for consistency */
    --icon-size-sm: 16px;
    --icon-size-md: 20px;
    --icon-size-lg: 24px;
}

/* ============================================
   CSS RESET & BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: var(--line-height-base);
    overflow-x: hidden;
}

/* ============================================
   BASE TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-base);
}

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

/* ============================================
   BASE FORM ELEMENTS
   ============================================ */

button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    transition: border-color var(--transition-base);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ============================================
   SCROLLBAR STYLING (Optional)
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
