/* DNA Copy Number Calculator — scientific calculator UI */

:root {
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #e0f7fa;
    --accent: #3b82f6;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --error: #dc2626;
    --highlight-bg: #f0fdfa;
    --highlight-border: #14b8a6;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app { max-width: 960px; margin: 0 auto; padding: 0 1rem 3rem; }

/* ─── Header ──────────────────────────────────────────────── */

.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 2rem 1.5rem;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.header h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.header .subtitle { font-size: 0.9rem; opacity: 0.9; }

/* ─── Load Example button ─────────────────────────────────── */

.btn-example {
    margin-top: 0.75rem;
    padding: 0.45rem 1rem;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1.5px solid rgba(255,255,255,0.4);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-example:hover { background: rgba(255,255,255,0.3); }
.btn-example:active { transform: scale(0.98); }

/* ─── Persistent input strip ──────────────────────────────── */

.input-strip {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.strip-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    flex: 1;
    min-width: 100px;
    padding-right: 0.5rem;
    border-right: 1px solid var(--border);
}

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

.strip-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.strip-value {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.strip-highlight .strip-value {
    color: var(--primary-dark);
    font-size: 0.95rem;
}

.strip-highlight {
    background: var(--highlight-bg);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    margin: -0.3rem -0.4rem;
    border-right: none;
}

/* ─── Tabs ────────────────────────────────────────────────── */

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.55rem 0.9rem;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tab:hover { border-color: var(--primary); color: var(--primary); }

.tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

/* ─── Cards ───────────────────────────────────────────────── */

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.15rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-light);
}

.card h3 {
    font-size: 1rem;
    color: var(--text);
    margin: 1.2rem 0 0.6rem;
}

/* ─── Forms ───────────────────────────────────────────────── */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Units contain µL; keep them case-sensitive so the micro sign (µ)
   isn't uppercased into Μ (Greek capital Mu, which looks like "M"). */
.form-group label .unit {
    text-transform: none;
}

input, select {
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.15s ease;
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input::placeholder { color: #cbd5e1; }

/* ─── Buttons ─────────────────────────────────────────────── */

.btn {
    padding: 0.65rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.98); }

.btn-secondary {
    padding: 0.5rem 1.2rem;
    background: var(--card-bg);
    color: var(--primary-dark);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-secondary:hover { background: var(--primary-light); }

/* ─── Copy button ─────────────────────────────────────────── */

.result-value-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-copy {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.35rem;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s ease, background 0.15s ease;
    line-height: 1;
}

.btn-copy:hover { opacity: 1; background: var(--primary-light); }
.btn-copy.copied { opacity: 1; background: var(--success); border-color: var(--success); }

/* ─── Results ─────────────────────────────────────────────── */

.result-box {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.result-row:last-child { border-bottom: none; }

.result-row.highlight {
    background: var(--highlight-bg);
    border: 1.5px solid var(--highlight-border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin: 0.3rem 0;
}

.result-label {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
}

.result-value {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    text-align: right;
}

.result-row.highlight .result-value {
    color: var(--primary-dark);
    font-size: 1.05rem;
}

/* ─── Tables ──────────────────────────────────────────────── */

.table-wrapper { overflow-x: auto; margin-top: 1rem; }

.dilution-table, .ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.dilution-table th, .dilution-table td,
.ref-table th, .ref-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.dilution-table th, .ref-table th {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
    white-space: nowrap;
}

.dilution-table tbody tr:hover { background: var(--bg); }
.dilution-table td { font-family: var(--font-mono); white-space: nowrap; }
.dilution-table tr.stock-row { font-weight: 700; background: var(--highlight-bg); }

/* ─── Formula & References ────────────────────────────────── */

.formula-display {
    background: var(--bg);
    border-left: 3px solid var(--primary);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0 1rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    border-radius: 0 6px 6px 0;
    overflow-x: auto;
}

.example-block {
    background: var(--primary-light);
    padding: 1rem;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.8;
}

.assumption-list {
    margin-left: 1.2rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.assumption-list li { margin-bottom: 0.3rem; }

/* ─── Calculation Details ─────────────────────────────────── */

.details-box { margin-top: 1rem; }

.detail-step {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.detail-step h3 {
    color: var(--primary-dark);
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.formula-block {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 2;
    white-space: pre-wrap;
}

/* ─── Misc ────────────────────────────────────────────────── */

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.error-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    animation: slideUp 0.25s ease;
}

.success-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { transform: translate(-50%, 100%); opacity: 0; }
    to   { transform: translate(-50%, 0);    opacity: 1; }
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 640px) {
    .header { padding: 1.5rem 1rem; }
    .header h1 { font-size: 1.25rem; }
    .tabs { gap: 0.25rem; }
    .tab { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
    .card { padding: 1rem; }
    .form-grid { grid-template-columns: 1fr; }
    .result-row { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
    .result-value { text-align: left; }
    .result-value-group { width: 100%; justify-content: space-between; }
    .dilution-table { font-size: 0.78rem; }
    .dilution-table th, .dilution-table td { padding: 0.4rem 0.5rem; }
    .input-strip { flex-direction: column; gap: 0.3rem; }
    .strip-item { border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
    .strip-item:last-child { border-bottom: none; }
}
