/* ShowTrack - Main Stylesheet */
/* Optimized for Raspberry Pi - Lightweight & Fast */

/* ============================================================================
   BASE STYLES
   ========================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #5568d3;
    --primary-dark: #4451b8;
    --primary-light: #667eea;
    --secondary: #4b5563;
    --secondary-dark: #374151;
    --success: #059669;
    --success-light: #10b981;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning: #d97706;
    --warning-light: #f59e0b;
    --background: #f9fafb;
    --surface: #ffffff;
    --text: #111827;
    --text-light: #4b5563;  /* Darker for better contrast (was #6b7280) */
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
    --focus-ring: #5568d3;
    --focus-ring-offset: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;  /* Increased for better readability */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Focus visible for keyboard navigation */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

/* Skip to main content link for screen readers */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 1rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 0.375rem;
}

.skip-to-main:focus {
    left: 1rem;
    top: 1rem;
}

/* ============================================================================
   LAYOUT
   ========================================================================= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.header-brand {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-light);
}

.nav {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    padding: 0.5rem 1rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 0.2s;
    position: relative;
}

.nav-link:hover {
    background: var(--background);
    color: var(--primary);
}

.nav-link:focus-visible {
    background: var(--background);
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.nav-link.active {
    background: var(--background);
    color: var(--primary);
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1rem;
    right: 1rem;
    height: 2px;
    background: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    font-size: 0.875rem;
    color: var(--text-light);
}

.main {
    flex: 1;
    padding: 2rem 0;
}

.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
}

/* ============================================================================
   COMPONENTS - Buttons
   ========================================================================= */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.btn:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
    z-index: 1;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-secondary:active {
    background: var(--secondary-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-danger:active {
    background: var(--danger-dark);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* ============================================================================
   COMPONENTS - Cards & Grid
   ========================================================================= */
.card {
    background: var(--surface);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ============================================================================
   COMPONENTS - Forms
   ========================================================================= */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.625rem;
    border: 2px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: var(--surface);
}

.form-input:hover, .form-select:hover, .form-textarea:hover {
    border-color: var(--secondary);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(85, 104, 211, 0.1);
}

.form-input:focus-visible, .form-select:focus-visible, .form-textarea:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.form-input:invalid, .form-select:invalid, .form-textarea:invalid {
    border-color: var(--danger);
}

.form-input[aria-invalid="true"], .form-select[aria-invalid="true"], .form-textarea[aria-invalid="true"] {
    border-color: var(--danger);
}

/* Form Validation States */
.form-input-error,
.form-textarea-error,
.form-select-error {
    border-color: var(--danger);
    background: #fef2f2;
}

.form-input-error:focus,
.form-textarea-error:focus,
.form-select-error:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-input-success,
.form-textarea-success,
.form-select-success {
    border-color: var(--success);
    background: #f0fdf4;
}

.form-input-success:focus,
.form-textarea-success:focus,
.form-select-success:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-error {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-error::before {
    content: '⚠';
    font-size: 1rem;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ============================================================================
   COMPONENTS - Tables
   ========================================================================= */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    background: var(--background);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    color: var(--text-light);
}

.table tbody td {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.table tbody tr:hover {
    background: var(--background);
}

/* ============================================================================
   COMPONENTS - Modals
   ========================================================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Confirmation modal should appear on top of other modals */
#confirmModal {
    z-index: 2000;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: 0.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Countdown container */
.countdown-container {
    margin-top: 1.5rem;
    text-align: center;
}

.countdown-text {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.countdown-text span {
    font-weight: bold;
    color: var(--primary);
    font-size: 1.1rem;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.1s linear;
    width: 100%;
}

/* ============================================================================
   COMPONENTS - Alerts & Badges
   ========================================================================= */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;  /* Increased for better visibility */
    border-radius: 0.25rem;
}

.badge-success {
    background: #a7f3d0;  /* Darker background */
    color: #064e3b;  /* Darker text for better contrast */
}

.badge-warning {
    background: #fcd34d;  /* Darker background */
    color: #78350f;  /* Darker text for better contrast */
}

.badge-danger {
    background: #fca5a5;  /* Darker background */
    color: #7f1d1d;  /* Darker text for better contrast */
}

.badge-primary {
    background: #93c5fd;  /* Blue background */
    color: #1e3a8a;  /* Dark blue text */
}

.badge-info {
    background: #bfdbfe;  /* Light blue background */
    color: #1e3a8a;  /* Dark blue text */
}

.badge-secondary {
    background: #d1d5db;  /* Gray background */
    color: #1f2937;  /* Dark gray text */
}

/* ============================================================================
   COMPONENTS - Loading & Toasts
   ========================================================================= */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--border) 0%,
        #f3f4f6 50%,
        var(--border) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-card {
    height: 200px;
    width: 100%;
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    z-index: 10000;
    pointer-events: none;
    max-width: 200px;
    word-wrap: break-word;
    animation: tooltip-fade-in 0.15s ease;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip-top::after,
.tooltip-bottom::after,
.tooltip-left::after,
.tooltip-right::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 4px solid transparent;
}

.tooltip-top::after {
    bottom: -8px;
    left: 50%;
    margin-left: -4px;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.tooltip-bottom::after {
    top: -8px;
    left: 50%;
    margin-left: -4px;
    border-bottom-color: rgba(0, 0, 0, 0.9);
}

.tooltip-left::after {
    right: -8px;
    top: 50%;
    margin-top: -4px;
    border-left-color: rgba(0, 0, 0, 0.9);
}

.tooltip-right::after {
    left: -8px;
    top: 50%;
    margin-top: -4px;
    border-right-color: rgba(0, 0, 0, 0.9);
}

.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--surface);
    padding: 1rem 1.5rem;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px var(--shadow);
    min-width: 300px;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

/* ============================================================================
   UTILITIES
   ========================================================================= */
.text-center {
    text-align: center;
}

.text-light {
    color: var(--text-light);
}

.text-small {
    font-size: 0.875rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ============================================================================
   RESPONSIVE
   ========================================================================= */

/* Tablet breakpoint */
@media (max-width: 1024px) {
    .container {
        padding: 0 1.5rem;
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile landscape / Small tablet */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-block {
        width: 100%;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        min-width: auto;
    }

    .modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .table {
        font-size: 0.8125rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.5rem;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    body {
        font-size: 0.9375rem;
    }

    .header-brand {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.75rem;
    }

    .user-name {
        display: none; /* Hide on very small screens */
    }

    .card {
        padding: 1rem;
    }

    .modal-content {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.9375rem;
    }

    .btn-small {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --text-light: #000000;
    }

    .btn {
        border: 2px solid currentColor;
    }

    .form-input, .form-select, .form-textarea {
        border-width: 2px;
    }
}

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

/* Judge selection chips */
.judge-chip {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9375rem;
    color: var(--text);
}

.judge-chip:hover {
    border-color: var(--primary);
    background: rgba(0, 102, 204, 0.05);
}

.judge-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.judge-chip.selected::before {
    content: '✓ ';
    font-weight: bold;
}

/* ─── Landing / Home Page ─────────────────────────────────────── */

.home-hero {
    text-align: center;
    padding: 4rem 1rem 3rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    border-radius: 0.75rem;
    margin-bottom: 2.5rem;
}

.home-hero-title {
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: 800;
    margin: 0 0 1rem;
    line-height: 1.2;
}

.home-hero-sub {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 580px;
    margin: 0 auto 1.75rem;
    line-height: 1.6;
}

.home-hero .btn-primary {
    background: #fff;
    color: var(--primary);
    font-weight: 700;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    border: none;
}

.home-hero .btn-primary:hover {
    background: #f0f0f0;
}

.home-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
    color: var(--text);
}

.home-features {
    margin-bottom: 0;
}

.home-feature-card {
    text-align: center;
    padding: 1.75rem 1.5rem;
}

.home-feature-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0.75rem 0 0.5rem;
}

.home-feature-icon {
    font-size: 2.25rem;
    line-height: 1;
}

.home-events,
.home-contact {
    margin-top: 2.5rem;
}

/* Dark mode support (optional - for future) */
@media (prefers-color-scheme: dark) {
    /* Color scheme can be implemented here */
}
