/*
 * Allotropic Projects - Ion Trap Demo page additions
 * Link this AFTER styleSheet.css. Kept separate so styleSheet.css stays untouched.
 */

/* ---------- Tabs (uses tab.js: .tab / .item / "tab default") ---------- */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2.5rem;
}

.tab {
    cursor: pointer;
    padding: 0.85rem 1.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    user-select: none;
}

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

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.item {
    display: none;
}

.item.active {
    display: block;
}

/* ---------- Shared form controls ---------- */
.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 220px;
    flex: 1;
}

.field label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="number"],
select,
textarea {
    background: var(--primary-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-size: 15px;
    font-family: inherit;
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.btn.small {
    padding: 0.5rem 1.1rem;
    font-size: 14px;
}

.btn-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: var(--secondary-bg);
    border: 1px solid var(--border);
}

.status-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: #ef4444;
}

.status-pill.connected .status-dot {
    background: #22c55e;
}

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

/* ---------- Camera + Serial combined tab ---------- */
.camera-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 900px) {
    .camera-layout {
        grid-template-columns: 1fr;
    }
}

.camera-stage {
    background: #000;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.camera-stage canvas {
    max-width: 100%;
    display: block;
}

.camera-panel {
    background: var(--secondary-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.camera-panel h3 {
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

.analysis-readout {
    background: var(--code-bg);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

/* Feature-flagged off for now; keep markup/IDs intact for later re-enable. */
.feature-hidden {
    display: none !important;
}

/* ---------- Bottom communication bar (console + raw JSON) ---------- */
.comms-bar {
    margin-top: 3rem;
    border-top: 2px solid var(--border);
    padding-top: 2rem;
}

.serial-console {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    height: 240px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    margin: 1rem 0;
}

.serial-console .rx {
    color: var(--accent);
}

.serial-console .tx {
    color: var(--text-secondary);
}

.serial-console .err {
    color: #ef4444;
}

.serial-console div {
    margin-bottom: 0.25rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------- Experiment table ---------- */
.experiment-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

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

.experiment-table th {
    background: var(--secondary-bg);
}

.experiment-table .remove-row {
    color: #ef4444;
    cursor: pointer;
    font-weight: 600;
    margin-left: 0.75rem;
}

.experiment-table .begin-btn {
    padding: 0.3rem 0.75rem;
    font-size: 13px;
}

.exp-param-group {
    display: none;
}

.exp-param-group.active {
    display: flex;
}

/* ---------- Theory tab ---------- */
.falstad-frame {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.equation-block {
    background: var(--secondary-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
}