/* IB Chemistry Apps - Shared Styles */
/* Light Theme · Dark Night / Golden Amber Accents */
/* Modeled after IB-Biology-Syllabus/styles.css */

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

/* ===== Header (compact app bar) ===== */
.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    color: white;
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.header h1 {
    font-size: 1.5rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.header .tag,
.tag {
    background: rgba(201, 162, 39, 0.9);
    color: #1e3a5f;
    padding: 0.2rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-right {
    font-size: 0.85rem;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.header-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* ===== App Layout (controls + sim area) ===== */
.app-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    max-width: 1500px;
    margin: 1rem auto;
    gap: 1rem;
    padding: 0 1rem 4rem 1rem;
}

/* ===== Controls Panel ===== */
.controls,
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.control-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.control-card h2 {
    font-size: 1rem;
    color: #1e3a5f;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Form Groups ===== */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.25rem;
}

.form-group label span {
    color: #c9a227;
    font-weight: 600;
}

.form-group select,
.form-group input[type="range"] {
    width: 100%;
}

.form-group select {
    padding: 0.5rem;
    border-radius: 8px;
    border: 1.5px solid #d1d5db;
    font-size: 0.85rem;
    background: white;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-group select:focus {
    outline: none;
    border-color: #c9a227;
}

.form-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #d1d5db;
    border-radius: 3px;
    outline: none;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #c9a227;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===== Toggle Switch ===== */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 22px;
}

.toggle-switch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 22px;
    cursor: pointer;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background: #c9a227;
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(22px);
}

/* ===== Buttons ===== */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #c9a227, #d4a82a);
    color: #1e3a5f;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(201, 162, 39, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #f0f4f8;
    color: #555;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-row {
    display: flex;
    gap: 0.5rem;
}

.btn-row .btn {
    flex: 1;
}

/* ===== Simulation Area ===== */
.sim-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===== Canvas Card ===== */
.canvas-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.canvas-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.canvas-card-header h2 {
    font-size: 1.1rem;
    color: #1e3a5f;
}

.canvas-card-body {
    padding: 0.5rem;
    background: #f8fafc;
}

.canvas-card-body canvas {
    width: 100%;
    display: block;
}

/* ===== Readout Strip ===== */
.readout-strip {
    display: flex;
    border-top: 1px solid #e2e8f0;
}

.readout-item {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    border-right: 1px solid #e2e8f0;
    background: white;
}

.readout-item:last-child {
    border-right: none;
}

.readout-item .label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.readout-item .value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e3a5f;
}

.readout-item .unit {
    font-size: 0.75rem;
    font-weight: 400;
    color: #888;
}

/* ===== Chart Card ===== */
.chart-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.chart-card-header h2 {
    font-size: 1rem;
    color: #1e3a5f;
}

.chart-card-header .subtitle {
    font-size: 0.8rem;
    color: #888;
}

.chart-card-body,
.chart-body {
    padding: 0.75rem;
    height: 300px;
}

.chart-body canvas {
    width: 100%;
    height: 250px;
}

/* ===== Legend Strip ===== */
.legend-strip {
    display: flex;
    gap: 1.5rem;
    padding: 0.6rem 1.25rem 0.8rem;
    border-top: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #555;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

/* ===== Status Badge ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}

.status-badge.ready {
    background: rgba(74, 222, 128, 0.15);
    color: #16a34a;
}

.status-badge.running {
    background: rgba(201, 162, 39, 0.15);
    color: #b8941f;
}

.status-badge.complete {
    background: rgba(96, 165, 250, 0.15);
    color: #2563eb;
}

.status-badge.paused {
    background: rgba(251, 146, 60, 0.15);
    color: #ea580c;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ===== Element Badge ===== */
.element-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
    background: rgba(201, 162, 39, 0.15);
    color: #b8941f;
    border: 1px solid rgba(201, 162, 39, 0.3);
}

/* ===== Equation Box (KaTeX) ===== */
.equation-box {
    background: #f0f4f8;
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    border-left: 3px solid #c9a227;
    color: #333;
}

.equation-box .katex {
    font-size: 0.85em;
}

/* ===== Calc Result ===== */
.calc-result {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #555;
    text-align: left;
}

.calc-result .val {
    color: #c9a227;
    font-weight: 600;
}

/* ===== Transition Grid (spectral apps) ===== */
.transition-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.transition-btn {
    padding: 0.5rem 0.4rem;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-weight: 500;
}

.transition-btn:hover {
    background: rgba(201, 162, 39, 0.08);
    border-color: #c9a227;
}

.transition-btn.active {
    background: rgba(201, 162, 39, 0.12);
    border-color: #c9a227;
    color: #b8941f;
    font-weight: 700;
}

.transition-btn .line-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* ===== Series Legend (spectral apps) ===== */
.series-legend {
    margin-top: 0.5rem;
    padding: 0.6rem;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #666;
}

.series-legend .series-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.2rem;
}

.series-legend .series-swatch {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .controls,
    .controls-panel {
        position: static;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .readout-strip {
        flex-wrap: wrap;
    }

    .readout-item {
        min-width: 33%;
    }
}