/* Base Theme & Variables */
:root {
    --bg-base: #1A1A2E;
    /* Dark Blue from guidelines */
    --bg-panel: #16213E;
    /* Slightly lighter inner panel */
    --bg-darker: #0F1423;
    /* Darker secondary panel */
    --bg-card: rgba(255, 255, 255, 0.05);

    --primary: #E74C3C;
    /* Red */
    --secondary: #3498DB;
    /* Blue */
    --accent: #E11D48;

    --text-main: #E2E8F0;
    --text-muted: #94A3B8;

    --border: rgba(255, 255, 255, 0.1);

    /* Specificity Tiers Colors */
    --tier-inline: #E056FD;
    /* Purple */
    --tier-id: #F1C40F;
    /* Yellow */
    --tier-class: #2ECC71;
    /* Green */
    --tier-el: #3498DB;
    /* Blue */
    --tier-important: #E74C3C;
    /* Red */

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Utilities */
.text-center {
    text-align: center;
}

.pb-0 {
    padding-bottom: 0 !important;
}

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

.mt-4 {
    margin-top: 1.5rem;
}

.margin-y {
    margin: 1.5rem 0;
}

.bg-darker {
    background-color: var(--bg-darker) !important;
}

.hidden {
    display: none !important;
}

.space-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-spacer {
    flex: 1;
}

.c-inline {
    color: var(--tier-inline);
}

.c-id {
    color: var(--tier-id);
}

.c-class {
    color: var(--tier-class);
}

.c-el {
    color: var(--tier-el);
}

.c-important {
    color: var(--tier-important);
}

/* Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

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

.logo-mark {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.2rem;
    letter-spacing: -2px;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-btn:hover {
    background-color: var(--bg-card);
    color: var(--text-main);
}

.nav-btn.active {
    background-color: rgba(52, 152, 219, 0.15);
    color: var(--secondary);
}

/* Main Content Views */
.main-content {
    flex: 1;
    overflow: hidden;
    /* Each view manages its own scrolling */
}

.view-pane {
    display: none;
    height: 100%;
}

.view-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Split Pane Layout for Calculator */
.split-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
}

.panel {
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.input-panel {
    border-right: 1px solid var(--border);
    background-color: var(--bg-panel);
}

.panel-header {
    margin-bottom: 1.5rem;
}

.panel-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Editor */
.editor-container {
    flex: 1;
    display: flex;
    background-color: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.5rem;
    min-height: 250px;
}

.line-numbers {
    padding: 1rem 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-align: right;
    width: 40px;
    user-select: none;
    line-height: 1.6;
}

.code-editor {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    white-space: pre;
    overflow: auto;
}

.code-editor::placeholder {
    color: rgba(148, 163, 184, 0.3);
}

/* Buttons & Controls */
.panel-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

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

.btn-primary:hover {
    background-color: #C0392B;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-icon {
    background: transparent;
    padding: 0.5rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.btn-icon:hover {
    color: var(--text-main);
    background-color: var(--bg-card);
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    user-select: none;
}

.toggle-switch input {
    margin: 0;
    accent-color: var(--secondary);
    cursor: pointer;
}

/* Visual Panel */
.table-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.swatch.c-inline {
    background: var(--tier-inline);
}

.swatch.c-id {
    background: var(--tier-id);
}

.swatch.c-class {
    background: var(--tier-class);
}

.swatch.c-el {
    background: var(--tier-el);
}

.swatch.c-important {
    background: var(--tier-important);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 4rem 2rem;
}

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

/* Result Card */
.result-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.result-card.is-winner {
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.15);
}

.winner-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--secondary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-bottom-left-radius: var(--radius-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.selector-text {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--text-main);
    word-break: break-all;
}

.score-tuple {
    font-family: var(--font-mono);
    font-weight: 600;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    display: flex;
    gap: 0.2rem;
}

/* Visualization Bars */
.viz-row {
    margin-bottom: 0.75rem;
}

.viz-row:last-child {
    margin-bottom: 0;
}

.viz-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.viz-label span:last-child {
    font-family: var(--font-mono);
}

.viz-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.viz-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Quiz Interface */
.quiz-panel {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-container {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
}

.score-board {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.score-badge,
.streak-badge {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.code-preview {
    background: #030a05;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    border: 1px solid var(--border);
}

.html-preview {
    color: #a9dcba;
}

.html-preview .tag {
    color: var(--secondary);
}

.html-preview .attr {
    color: var(--primary);
}

.html-preview .eq {
    color: var(--text-main);
}

.html-preview .value {
    color: #F1C40F;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quiz-btn {
    background: var(--bg-darker);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--text-main);
}

.quiz-btn:hover {
    border-color: var(--secondary);
    background: rgba(52, 152, 219, 0.05);
}

.quiz-btn.correct {
    border-color: #2ECC71;
    background: rgba(46, 204, 113, 0.1);
}

.quiz-btn.wrong {
    border-color: #E74C3C;
    background: rgba(231, 76, 60, 0.1);
}

.quiz-feedback {
    margin-top: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    text-align: center;
}

/* Guide Grid */
.guide-panel {
    max-width: 1000px;
    margin: 0 auto;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.guide-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.guide-icon {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.guide-card p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
}

.guide-card code {
    background: var(--bg-darker);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    display: block;
    border: 1px solid var(--border);
    color: #FFF;
}

.important-card {
    border-color: rgba(231, 76, 60, 0.3);
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.05);
}

/* Responsive */
@media (max-width: 900px) {
    .split-pane {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        overflow: auto;
    }

    .input-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .main-content {
        overflow-y: auto;
    }

    .panel {
        overflow-y: visible;
    }
}