/* ============================================
   OUTSMART THE LOT
   Dark Theme Styling - Clean Architecture
   ============================================ */

/* ===========================================
   DARK THEME COLOR SYSTEM
   =========================================== */

:root {
    /* Backgrounds (darkest to lightest) */
    --bg-darkest: #0f172a;
    --bg-dark: #1e293b;
    --bg-medium: #334155;
    --bg-light: #475569;

    /* Text (lightest to darkest) */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    /* Accent Colors */
    --blue: #3b82f6;
    --blue-hover: #2563eb;
    --amber: #f59e0b;
    --amber-hover: #d97706;
    --green: #10b981;
    --red: #ef4444;

    /* Borders */
    --border: #475569;
    --border-light: #64748b;
}

/* ===========================================
   BASE STYLES
   =========================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    margin: 0;
    background: var(--bg-darkest);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', system-ui, sans-serif;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    color: var(--text-primary);
}

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

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    color: var(--amber);
}

img, svg, video {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===========================================
   NAVIGATION
   =========================================== */

nav {
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
}

.mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--bg-dark);
}

.mobile-menu.open {
    max-height: 100vh;
}

.mobile-menu a {
    display: block;
    padding: 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.mobile-menu a:hover {
    color: var(--blue);
    background: rgba(59, 130, 246, 0.1);
}

/* ===========================================
   FORMS
   =========================================== */

input[type="text"],
input[type="number"],
input[type="email"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 1rem;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-medium);
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s ease;
}

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

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--bg-medium);
    border-radius: 4px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--blue);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--blue);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
}

/* ===========================================
   BUTTONS
   =========================================== */

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    color: white;
    background: var(--blue);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

button:hover {
    background: var(--blue-hover);
}

/* Copy button */
.copy-btn {
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: var(--bg-medium);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.copy-btn:hover {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
}

.copy-btn.copied {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

/* Term/Calculator buttons */
.term-btn,
.lease-term-btn,
.buy-term-btn,
.mf-preset,
.calc-jump-btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--bg-medium);
    color: var(--text-secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.term-btn:hover,
.lease-term-btn:hover,
.buy-term-btn:hover,
.calc-jump-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.term-btn.active,
.lease-term-btn.active,
.buy-term-btn.active,
.calc-jump-btn.active {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
}

/* ===========================================
   CARDS & SURFACES
   =========================================== */

.tactic-card,
.card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.tactic-card:hover,
.card:hover {
    border-color: var(--blue);
}

/* Glass panels - dark themed */
.glass {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
}

/* Result cards */
.result-card {
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.result-card.good { border-color: var(--green); }
.result-card.warning { border-color: var(--amber); }
.result-card.bad { border-color: var(--red); }

.result-value {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--text-primary);
}

/* ===========================================
   ALERTS - Dark Themed
   =========================================== */

.alert-scam,
.alert-tip,
.alert-warning,
.alert-info {
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid;
    margin-bottom: 1rem;
}

.alert-scam {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--red);
    color: #fca5a5;
}

.alert-tip {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--green);
    color: #6ee7b7;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--amber);
    color: #fcd34d;
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--blue);
    color: #93c5fd;
}

/* ===========================================
   QUIZ
   =========================================== */

.quiz-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 56px;
    padding: 1rem;
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quiz-option:hover {
    border-color: var(--blue);
    background: rgba(59, 130, 246, 0.1);
}

.quiz-option.selected {
    border-color: var(--blue);
    background: rgba(59, 130, 246, 0.2);
}

.quiz-option.correct {
    border-color: var(--green);
    background: rgba(16, 185, 129, 0.2);
}

.quiz-option.incorrect {
    border-color: var(--red);
    background: rgba(239, 68, 68, 0.2);
}

/* ===========================================
   CHECKLIST
   =========================================== */

.checklist-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 52px;
    padding: 1rem;
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.15s ease;
}

.checklist-item:hover {
    border-color: var(--blue);
}

.checklist-item.checked {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--green);
}

.checklist-item.checked label {
    text-decoration: line-through;
    color: var(--text-muted);
}

.checklist-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    min-width: 24px;
    accent-color: var(--green);
    cursor: pointer;
}

/* ===========================================
   SIDEBAR NAVIGATION
   =========================================== */

.sidebar-nav {
    background: var(--bg-dark);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.sidebar-link {
    display: block;
    padding: 1rem;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    text-decoration: none;
    transition: all 0.15s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    color: var(--blue);
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--blue);
}

@media (min-width: 1024px) {
    .sidebar-nav {
        position: sticky;
        top: 80px;
    }
}

/* ===========================================
   SCRIPT BOXES
   =========================================== */

.script-box {
    position: relative;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    padding-left: 3rem;
    font-family: Georgia, serif;
    font-style: italic;
    color: var(--text-secondary);
}

.script-box::before {
    content: '"';
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    font-size: 2.5rem;
    color: var(--blue);
    opacity: 0.5;
    line-height: 1;
}

/* ===========================================
   SIMULATOR
   =========================================== */

.response-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 56px;
    padding: 1rem;
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    width: 100%;
}

.response-option:hover:not(:disabled) {
    border-color: var(--blue);
    background: rgba(59, 130, 246, 0.1);
}

/* ===========================================
   FOUR SQUARE DIAGRAM
   =========================================== */

.four-square-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    background: var(--blue);
    border: 2px solid var(--blue);
    border-radius: 12px;
    overflow: hidden;
    max-width: 400px;
    margin: 0 auto;
}

.four-square-cell {
    background: var(--bg-dark);
    padding: 1rem;
    text-align: center;
}

/* ===========================================
   PROGRESS BAR
   =========================================== */

.progress-bar {
    background: linear-gradient(90deg, var(--green), #34d399);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* ===========================================
   FLOATING RED FLAG BUTTON
   =========================================== */

.floating-red-flag {
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 999;
}

.floating-red-flag a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--red);
    border-radius: 50%;
    color: white;
    font-size: 1.25rem;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    text-decoration: none;
    transition: transform 0.15s ease;
}

.floating-red-flag a:hover {
    transform: scale(1.1);
}

.floating-red-flag .tooltip-text {
    position: absolute;
    right: 64px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: white;
    background: var(--bg-medium);
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
}

.floating-red-flag:hover .tooltip-text {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 768px) {
    .floating-red-flag {
        display: none;
    }
}

/* ===========================================
   CATEGORY BUTTONS (Glossary)
   =========================================== */

.category-btn {
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.category-btn.active {
    background: var(--amber);
    color: white;
}

/* ===========================================
   RED FLAG CARDS
   =========================================== */

.red-flag-card {
    touch-action: manipulation;
}

.red-flag-card .card-answer {
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.red-flag-card.expanded .card-answer {
    max-height: 500px;
}

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

.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--amber);
    color: #000;
    padding: 0.5rem 1.5rem;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    z-index: 9999;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

:focus-visible {
    outline: 3px solid var(--amber);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

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

/* ===========================================
   PRINT STYLES
   =========================================== */

@media print {
    nav, footer, .floating-red-flag, .no-print {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    h1, h2, h3, h4, h5, h6 {
        color: black !important;
    }

    p, li, td, th {
        color: #333 !important;
    }

    .checklist-item {
        page-break-inside: avoid;
        background: white !important;
        border: 1px solid #ccc !important;
        color: black !important;
    }

    .checklist-item label {
        color: black !important;
    }

    a { color: black !important; }

    /* Print checkboxes */
    .checklist-item input[type="checkbox"] {
        -webkit-appearance: none;
        appearance: none;
        width: 16px;
        height: 16px;
        border: 2px solid #333;
        border-radius: 3px;
        background: white;
    }

    .checklist-item input[type="checkbox"]:checked::after {
        content: '✓';
        display: block;
        text-align: center;
        font-size: 12px;
        line-height: 12px;
        color: #333;
    }
}

/* ===========================================
   RESPONSIVE - Mobile First
   =========================================== */

/* Fluid typography */
@media (max-width: 640px) {
    .text-6xl { font-size: 2.25rem; }
    .text-5xl { font-size: 2rem; }
    .text-4xl { font-size: 1.75rem; }
    .text-3xl { font-size: 1.5rem; }
    .text-2xl { font-size: 1.25rem; }
}

/* Prevent overflow */
html, body {
    overflow-x: hidden;
}

main, section, article {
    max-width: 100%;
}

/* Word wrapping */
h1, h2, h3, h4, h5, h6, p, li, td, th, a {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Mobile spacing */
@media (max-width: 767px) {
    .py-20 { padding-top: 3rem; padding-bottom: 3rem; }
    .py-16 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
    .py-12 { padding-top: 2rem; padding-bottom: 2rem; }
    .px-8 { padding-left: 1rem; padding-right: 1rem; }

    .gap-12 { gap: 2rem; }
    .gap-8 { gap: 1.5rem; }

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

    .four-square-grid { max-width: 100%; }
    .four-square-cell { padding: 0.75rem; font-size: 0.875rem; }

    footer .grid { text-align: center; }
}

@media (max-width: 480px) {
    .flex.flex-col.sm\:flex-row > a,
    .flex.flex-col.sm\:flex-row > button {
        width: 100%;
        justify-content: center;
    }

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

@media (min-width: 768px) and (max-width: 1023px) {
    .grid-cols-5 { grid-template-columns: repeat(4, 1fr); }
}

/* ===========================================
   UTILITIES
   =========================================== */

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
}

/* ===========================================
   ANIMATIONS
   =========================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.3s ease forwards;
}

/* Gradient text */
.stat-number {
    background: linear-gradient(135deg, var(--blue), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
