/**
 * GeoLocate Rodeo - Armani-Inspired Design System
 * Clean, elegant, professional aesthetic
 */

/* ============================================================================
   DESIGN TOKENS
   ============================================================================ */
:root {
    /* Colors - Sophisticated Monochrome Palette */
    --color-primary: #1a1a1a;
    --color-secondary: #2d2d2d;
    --color-accent: #c9a876; /* Subtle gold accent */
    --color-text-primary: #1a1a1a;
    --color-text-secondary: #6b6b6b;
    --color-text-light: #999999;
    --color-background: #ffffff;
    --color-background-light: #f8f8f8;
    --color-background-dark: #2d2d2d;
    --color-border: #e0e0e0;
    --color-border-light: #f0f0f0;
    --color-success: #2d5016;
    --color-warning: #c9a876;
    --color-error: #8b2c2c;
    --color-info: #2d4a5c;

    /* Typography - Elegant Fonts */
    --font-primary: 'Helvetica Neue', 'Arial', sans-serif;
    --font-heading: 'Georgia', 'Times New Roman', serif;
    --font-mono: 'Monaco', 'Courier New', monospace;

    /* Font Sizes - Refined Scale */
    --text-xs: 0.75rem;   /* 12px */
    --text-sm: 0.875rem;  /* 14px */
    --text-base: 1rem;    /* 16px */
    --text-lg: 1.125rem;  /* 18px */
    --text-xl: 1.5rem;    /* 24px */
    --text-2xl: 2rem;     /* 32px */
    --text-3xl: 2.5rem;   /* 40px */
    --text-4xl: 3.5rem;   /* 56px */

    /* Spacing - Generous Whitespace */
    --space-xs: 0.5rem;   /* 8px */
    --space-sm: 1rem;     /* 16px */
    --space-md: 1.5rem;   /* 24px */
    --space-lg: 2rem;     /* 32px */
    --space-xl: 3rem;     /* 48px */
    --space-2xl: 4rem;    /* 64px */
    --space-3xl: 6rem;    /* 96px */

    /* Layout */
    --container-max: 1400px;
    --container-narrow: 800px;
    --sidebar-width: 280px;
    --header-height: 80px;

    /* Effects */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ============================================================================
   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: var(--font-primary);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text-primary);
    background-color: var(--color-background);
    background-image: url('background.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    overflow-x: hidden;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
    color: var(--color-text-primary);
}

h1 { font-size: var(--text-4xl); margin-bottom: var(--space-lg); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); font-weight: 500; }

p {
    margin-bottom: var(--space-sm);
    color: var(--color-text-secondary);
}

a {
    color: var(--color-text-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
}

a:hover {
    border-bottom-color: var(--color-accent);
}

/* ============================================================================
   LAYOUT COMPONENTS
   ============================================================================ */

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 var(--space-xl);
}

.header__logo {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 300;
}

.header__nav {
    margin-left: auto;
    display: flex;
    gap: var(--space-lg);
}

.header__nav-link {
    font-size: var(--text-sm);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 400;
    padding: var(--space-xs) 0;
}

.header__user {
    margin-left: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header__nav-link--active {
    border-bottom: 2px solid var(--color-accent);
}

.header__logo-text {
    display: inline;
}

/* Mobile menu toggle button */
.header__mobile-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
}

.header__mobile-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--color-text-primary);
    transition: var(--transition-fast);
}

.header__mobile-toggle.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.header__mobile-toggle.active span:nth-child(2) {
    opacity: 0;
}

.header__mobile-toggle.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Mobile responsive header */
@media (max-width: 900px) {
    .header {
        padding: 0 var(--space-md);
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-height);
    }

    .header__logo-text {
        display: none;
    }

    .header__mobile-toggle {
        display: flex;
        order: 2;
    }

    .header__nav {
        display: none;
        width: 100%;
        order: 3;
        flex-direction: column;
        gap: 0;
        padding: var(--space-sm) 0;
        border-top: 1px solid var(--color-border);
        margin-left: 0;
    }

    .header__nav--open {
        display: flex;
    }

    .header__nav-link {
        padding: var(--space-sm) 0;
        border-bottom: 1px solid var(--color-border-light);
    }

    .header__nav-link--active {
        border-bottom: 1px solid var(--color-border-light);
        color: var(--color-accent);
        font-weight: 500;
    }

    .header__user {
        display: none;
        width: 100%;
        order: 4;
        padding: var(--space-sm) 0;
        margin-left: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .header__user--open {
        display: flex;
    }

    .page {
        padding-top: var(--header-height);
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0 var(--space-sm);
    }

    .header__logo img {
        height: 40px !important;
        width: 40px !important;
    }
}

/* Main Container */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--space-xl);
}

.container--narrow {
    max-width: var(--container-narrow);
}

.page {
    min-height: 100vh;
    padding-top: var(--header-height);
}

.page__content {
    padding: var(--space-2xl);
    background: rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    margin: var(--space-lg);
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--space-lg);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

/* ============================================================================
   CARD COMPONENTS
   ============================================================================ */
.card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: var(--space-xl);
    transition: all var(--transition-base);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card__header {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
}

.card__title {
    font-size: var(--text-xl);
    margin-bottom: var(--space-xs);
}

.card__subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-light);
}

.card__content {
    margin-bottom: var(--space-md);
}

.card__footer {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================================================
   FORM ELEMENTS
   ============================================================================ */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-help {
    font-size: var(--text-sm);
    color: var(--color-text-light);
    margin-top: var(--space-xs);
}

.form-error {
    font-size: var(--text-sm);
    color: var(--color-error);
    margin-top: var(--space-xs);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    display: inline-block;
    padding: var(--space-sm) var(--space-lg);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
    color: var(--color-background);
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
}

.btn:hover {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
}

.btn--outline {
    color: var(--color-primary);
    background: transparent;
}

.btn--outline:hover {
    color: var(--color-background);
    background: var(--color-primary);
}

.btn--accent {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-primary);
}

.btn--accent:hover {
    background: #b39668;
    border-color: #b39668;
}

.btn--sm {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-xs);
}

.btn--lg {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--text-base);
}

.btn--block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   BADGES & STATUS
   ============================================================================ */
.badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.8);
    color: var(--color-text-secondary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
}

.badge--success { background: var(--color-success); color: white; border-color: var(--color-success); }
.badge--warning { background: var(--color-warning); color: var(--color-primary); border-color: var(--color-warning); }
.badge--error { background: var(--color-error); color: white; border-color: var(--color-error); }
.badge--info { background: var(--color-info); color: white; border-color: var(--color-info); }

/* ============================================================================
   TABLES
   ============================================================================ */
.table-container {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.table th {
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    background: rgba(0, 0, 0, 0.03);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(0, 0, 0, 0.03);
}

/* ============================================================================
   UTILITIES
   ============================================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-light { color: var(--color-text-light); }
.text-accent { color: var(--color-accent); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.flex { display: flex; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-column { flex-direction: column; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.hidden { display: none; }

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Alert Messages */
.alert {
    padding: var(--space-md);
    border-left: 3px solid var(--color-primary);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    margin-bottom: var(--space-md);
}

.alert--success { border-left-color: var(--color-success); }
.alert--warning { border-left-color: var(--color-warning); }
.alert--error { border-left-color: var(--color-error); }
.alert--info { border-left-color: var(--color-info); }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal__content {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--space-2xl);
    transform: translateY(-20px);
    transition: transform var(--transition-base);
}

.modal.active .modal__content {
    transform: translateY(0);
}

.modal__header {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.modal__close {
    float: right;
    font-size: var(--text-2xl);
    font-weight: 300;
    cursor: pointer;
    color: var(--color-text-light);
    transition: color var(--transition-fast);
}

.modal__close:hover {
    color: var(--color-text-primary);
}

/* ============================================================================
   MOBILE RESPONSIVE OVERRIDES
   Comprehensive mobile-first responsive design
   ============================================================================ */

/* Prevent horizontal scrolling on all elements */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Mobile-friendly page content */
@media (max-width: 768px) {
    :root {
        --space-xl: 1.5rem;
        --space-2xl: 2rem;
        --space-3xl: 3rem;
    }

    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); }
    h3 { font-size: var(--text-lg); }

    .container {
        padding: var(--space-sm);
    }

    .page__content {
        padding: var(--space-md);
        margin: var(--space-sm);
        border-radius: 6px;
    }

    /* Cards */
    .card {
        padding: var(--space-md);
    }

    /* Buttons - full width on mobile */
    .btn {
        padding: var(--space-sm) var(--space-md);
    }

    /* Form elements */
    .form-group {
        margin-bottom: var(--space-md);
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: var(--space-sm);
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Modal full-width on mobile */
    .modal__content {
        width: 95%;
        max-width: none;
        padding: var(--space-lg);
        margin: var(--space-sm);
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    :root {
        --space-lg: 1.25rem;
        --space-xl: 1.5rem;
        --space-2xl: 1.75rem;
    }

    h1 { font-size: var(--text-xl); }
    h2 { font-size: var(--text-lg); }

    .page__content {
        padding: var(--space-sm);
        margin: var(--space-xs);
    }

    .container {
        padding: var(--space-xs);
    }

    /* Stack all grids on small mobile */
    .grid, .grid--2, .grid--3, .grid--4 {
        grid-template-columns: 1fr !important;
        gap: var(--space-sm);
    }

    /* Full width buttons */
    .btn {
        width: 100%;
        margin-bottom: var(--space-xs);
    }

    .flex {
        flex-wrap: wrap;
    }

    .gap-lg {
        gap: var(--space-sm);
    }
}

/* Table responsive wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table {
        min-width: 600px;
    }

    .table th,
    .table td {
        padding: var(--space-sm);
        font-size: var(--text-sm);
    }
}

/* ============================================================================
   PAGE-SPECIFIC MOBILE OVERRIDES
   For pages with custom layouts (judge-live-view, etc.)
   ============================================================================ */

/* Two-column layouts become single column on mobile */
@media (max-width: 900px) {
    .judge-container,
    .split-view,
    .two-column,
    [style*="grid-template-columns: 420px"],
    [style*="grid-template-columns: 400px"],
    [style*="grid-template-columns: 350px"],
    [style*="grid-template-columns: 300px"] {
        display: flex !important;
        flex-direction: column !important;
        gap: var(--space-md) !important;
    }

    .left-panel,
    .right-panel,
    .sidebar {
        width: 100% !important;
        max-width: 100% !important;
        order: 1;
    }

    /* Map views should have a minimum height on mobile */
    #mapView,
    .map-container,
    [id*="map"] {
        min-height: 300px !important;
        height: 50vh !important;
        order: 0; /* Map first on mobile */
    }
}

/* Alert container mobile positioning */
@media (max-width: 480px) {
    #alert-container {
        left: 10px !important;
        right: 10px !important;
        max-width: none !important;
    }
}

/* Fix inline styles that break mobile */
@media (max-width: 768px) {
    [style*="display: flex"][style*="gap"] {
        flex-wrap: wrap;
    }

    /* Override any fixed widths in inline styles */
    [style*="width: 400px"],
    [style*="width: 420px"],
    [style*="width: 500px"],
    [style*="min-width: 400px"],
    [style*="min-width: 420px"] {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }
}

/* Dashboard cards mobile */
@media (max-width: 768px) {
    .dashboard-card {
        padding: 12px !important;
    }

    .dashboard-card .card-icon {
        font-size: 24px;
    }

    .dashboard-card h3 {
        font-size: 13px;
    }

    .dashboard-card p {
        font-size: 11px;
    }
}

/* Form rows that need to stack */
@media (max-width: 640px) {
    .form-row,
    .input-group,
    .deduction-input {
        display: flex !important;
        flex-direction: column !important;
        gap: var(--space-xs) !important;
    }

    .form-row > *,
    .input-group > *,
    .deduction-input > * {
        width: 100% !important;
    }
}

/* Timer section mobile */
@media (max-width: 480px) {
    .timer-section {
        flex-direction: column;
        gap: 8px;
    }

    .timer-display {
        font-size: 24px !important;
    }

    .timer-buttons {
        width: 100%;
        justify-content: center;
    }
}

/* Scoring panels mobile */
@media (max-width: 480px) {
    .scoring-panel,
    .participant-info {
        padding: 10px !important;
    }

    .score-row {
        flex-direction: column;
        gap: 4px;
        padding: 8px;
    }

    .score-value {
        font-size: 16px !important;
    }
}

/* Fix any elements with absolute positioning that break on mobile */
@media (max-width: 768px) {
    .fixed-bottom,
    .sticky-footer {
        position: relative !important;
        bottom: auto !important;
    }
}

/* Utility classes for mobile */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    .full-width-mobile { width: 100% !important; }
    .stack-mobile {
        display: flex !important;
        flex-direction: column !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
    .show-desktop { display: block !important; }
}

/* Touch-friendly tap targets */
@media (max-width: 768px) {
    a, button, .btn, input, select, textarea {
        min-height: 44px;
    }

    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
    }
}

/* Prevent text from being too small on mobile */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .text-xs {
        font-size: 11px;
    }

    .text-sm {
        font-size: 12px;
    }
}
