/* ========================================
   MathMap Dark Theme
   Consistent, readable dark mode for all templates
   ======================================== */

/* CSS Variables - Single source of truth for colors */
:root {
    /* Background colors - progressively lighter */
    --bg-primary: #1a1a1a;      /* Main background */
    --bg-secondary: #2a2a2a;    /* Cards, surfaces */
    --bg-elevated: #3a3a3a;     /* Hover states, elevated elements */
    --bg-input: #374151;        /* Form inputs */

    /* Text colors - high contrast for readability */
    --text-primary: #ffffff;         /* Main text, headings */
    --text-secondary: #e5e7eb;       /* Secondary text */
    --text-tertiary: #9ca3af;        /* Muted text, placeholders */
    --text-disabled: #6b7280;        /* Disabled state */

    /* Accent colors */
    --accent-primary: #2563eb;       /* Primary blue - buttons, links */
    --accent-primary-hover: #1e40af; /* Hover state */
    --accent-secondary: #10b981;     /* Green - success */
    --accent-warning: #f59e0b;       /* Orange - warnings */
    --accent-danger: #ef4444;        /* Red - errors */

    /* Border and divider colors */
    --border-primary: #404040;       /* Default borders */
    --border-secondary: #4b5563;     /* Input borders */
    --border-focus: #2563eb;         /* Focused inputs */

    /* Semantic colors for status badges */
    --status-success-bg: #065f46;
    --status-success-text: #6ee7b7;
    --status-warning-bg: #92400e;
    --status-warning-text: #fcd34d;
    --status-danger-bg: #7f1d1d;
    --status-danger-text: #fca5a5;
    --status-info-bg: #1e3a8a;
    --status-info-text: #93c5fd;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

/* ========================================
   Global Resets & Base Styles
   ======================================== */

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Improve text readability */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
}

p {
    color: var(--text-secondary);
}

a {
    color: var(--accent-primary);
    transition: color 0.2s ease;
}

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

/* ========================================
   Component Classes - Reusable UI Elements
   ======================================== */

/* Card Component */
.card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.card-compact {
    padding: var(--spacing-md);
}

/* Button Components */
.btn,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--accent-primary) !important;
    color: var(--text-primary) !important;
}

.btn-primary:hover {
    background-color: var(--accent-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-primary) !important;
}

.btn-secondary:hover {
    background-color: var(--border-secondary) !important;
}

.btn-success {
    background-color: var(--accent-secondary) !important;
    color: var(--text-primary) !important;
}

.btn-danger {
    background-color: var(--accent-danger) !important;
    color: var(--text-primary) !important;
}

/* ========================================
   Form Elements - Optimized for Readability
   ======================================== */

/* Input fields */
.input-field,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    padding: 0.625rem 1rem;
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-secondary) !important;
    border-radius: var(--radius-md);
    color: var(--text-secondary) !important;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.input-field:focus,
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus) !important;
    background-color: var(--bg-input) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-field::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary) !important;
}

/* Form labels */
label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* Form groups */
.form-group {
    margin-bottom: var(--spacing-lg);
}

/* ========================================
   Table Styles - Data Display
   ======================================== */

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--bg-primary);
    border-bottom: 2px solid var(--border-primary);
}

th {
    padding: 0.75rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr {
    border-bottom: 1px solid var(--border-primary);
    transition: background-color 0.15s ease;
}

tbody tr:hover {
    background-color: var(--bg-primary);
}

td {
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
}

/* ========================================
   Status Badges
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.badge-success {
    background-color: var(--status-success-bg);
    color: var(--status-success-text);
}

.badge-warning {
    background-color: var(--status-warning-bg);
    color: var(--status-warning-text);
}

.badge-danger {
    background-color: var(--status-danger-bg);
    color: var(--status-danger-text);
}

.badge-info {
    background-color: var(--status-info-bg);
    color: var(--status-info-text);
}

/* ========================================
   Utility Classes
   ======================================== */

/* Text colors */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-muted { color: var(--text-tertiary); }

/* Background colors */
.bg-primary { background-color: var(--bg-primary) !important; }
.bg-secondary { background-color: var(--bg-secondary) !important; }
.bg-elevated { background-color: var(--bg-elevated) !important; }

/* Spacing utilities */
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }

/* Border utilities */
.border { border: 1px solid var(--border-primary); }
.border-top { border-top: 1px solid var(--border-primary); }
.border-bottom { border-bottom: 1px solid var(--border-primary); }

/* Rounded corners */
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }

/* ========================================
   Specific Components
   ======================================== */

/* Navigation improvements */
nav {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
}

nav a {
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

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

/* Footer */
footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    color: var(--text-tertiary);
}

/* Code blocks */
code {
    background-color: var(--bg-primary);
    color: var(--accent-primary);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', monospace;
    font-size: 0.875em;
}

pre {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    overflow-x: auto;
}

pre code {
    background: none;
    padding: 0;
}

/* Alert/Message boxes */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    margin-bottom: var(--spacing-md);
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: var(--accent-secondary);
    color: var(--status-success-text);
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-color: var(--accent-warning);
    color: var(--status-warning-text);
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-danger);
    color: var(--status-danger-text);
}

.alert-info {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: var(--accent-primary);
    color: var(--status-info-text);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
    color: var(--text-tertiary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--text-tertiary);
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    .card {
        padding: var(--spacing-md);
    }

    th, td {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
    }
}

/* ========================================
   Accessibility Improvements
   ======================================== */

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Cookie Consent Banner
   ======================================== */

.cookie-banner {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.cookie-banner.visible {
    transform: translateY(0);
    opacity: 1;
}

.cookie-banner.hidden {
    display: none;
}

.cookie-banner-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cookie-banner-icon {
    font-size: 2rem;
    color: var(--accent-warning);
    text-align: center;
}

.cookie-banner-text {
    text-align: center;
}

.cookie-banner-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.cookie-banner-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.cookie-link {
    color: var(--accent-primary);
    text-decoration: underline;
}

.cookie-link:hover {
    color: var(--accent-primary-hover);
}

.cookie-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

.cookie-options.hidden {
    display: none;
}

.cookie-option {
    display: flex;
    align-items: flex-start;
}

.cookie-option-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    width: 100%;
}

.cookie-option-label input[type="checkbox"] {
    margin-top: 0.25rem;
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.cookie-option-label input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.cookie-option-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.cookie-option-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cookie-option-desc {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.cookie-banner-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.cookie-btn {
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.cookie-btn:hover {
    transform: translateY(-1px);
}

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

.cookie-btn-primary:hover {
    background: var(--accent-primary-hover);
}

.cookie-btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.cookie-btn-secondary:hover {
    background: var(--bg-input);
}

.cookie-btn-tertiary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
}

.cookie-btn-tertiary:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.cookie-btn.hidden {
    display: none;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .cookie-banner {
        bottom: 0;
        right: 0;
        left: 0;
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin: 0;
    }

    .cookie-banner-icon {
        font-size: 1.5rem;
    }

    .cookie-banner-title {
        font-size: 1rem;
    }

    .cookie-banner-description {
        font-size: 0.8125rem;
    }
}
