/* ============================================================
   Epic Quest Bio SPA — Color System & Responsive Tab Layout
   ============================================================ */

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

html, body {
    height: 100%;
    overflow: hidden;
    background: #000;
    color: #c8ccd4;
    font-family: 'Fira Sans', 'Open Sans', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ============================================================
   Tab Bar
   ============================================================ */

.tab-bar {
    display: flex;
    width: 100%;
    background: #000;
    border-bottom: 1px solid #1a1a1a;
    flex-shrink: 0;
}

/* Horizontal: single row */
.tab-bar-horizontal {
    flex-direction: row;
    height: 44px;
}

/* Vertical: two rows of 3 */
.tab-bar-vertical {
    flex-wrap: wrap;
    height: 88px;
}
.tab-bar-vertical .tab-btn {
    flex: 0 0 33.333%;
    height: 44px;
}

.tab-btn {
    flex: 1 1 0;
    min-width: 0;
    border: none;
    background: hsl(var(--tab-h, 190), 30%, 8%);
    color: hsl(var(--tab-h, 190), 15%, 45%);
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 4px 8px 0 8px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.tab-btn:hover {
    background: hsl(var(--tab-h, 190), 35%, 12%);
    color: hsl(var(--tab-h, 190), 40%, 60%);
}

.tab-btn.active {
    background: hsl(var(--tab-h, 190), 40%, 18%);
    color: hsl(var(--tab-h, 190), 60%, 70%);
}

/* ============================================================
   Content Area
   ============================================================ */

.content-area {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    background: hsl(var(--tab-h, 190), 20%, 10%);
    border-left: 1px solid hsl(var(--tab-h, 190), 60%, 35%);
    border-right: 1px solid hsl(var(--tab-h, 190), 60%, 35%);
    border-bottom: 1px solid hsl(var(--tab-h, 190), 60%, 35%);
    transition: background 0.3s, border-color 0.3s;
    display: flex;
    flex-direction: column;
}

.tab-panel {
    display: none;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.tab-panel.active {
    display: flex;
    flex-direction: column;
}

.tab-inner {
    padding: 2rem;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   Streaming Tab Layout
   ============================================================ */

#panel-streaming {
    overflow: hidden;
}

#panel-streaming.active {
    display: flex;
}

.streaming-layout {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

/* Vertical layout (default) */
.streaming-vertical {
    flex-direction: column;
}

.streaming-vertical .streaming-top {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.streaming-vertical .streaming-right {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Horizontal layout: top 50% split left/right, bottom 50% lab chat */
.streaming-horizontal {
    flex-direction: column;
}

.streaming-horizontal .streaming-top {
    flex: 0 0 50%;
    display: flex;
    flex-direction: row;
    min-height: 0;
}

.streaming-horizontal .streaming-right {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* --- Webcam area ----------------------------------------- */

.webcam-area {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    background: #000;
}

.streaming-vertical .webcam-area {
    flex-direction: row;
    height: 20vh;
    max-height: 20%;
    flex-shrink: 0;
}

.streaming-horizontal .webcam-area {
    flex-direction: column;
    width: 25%;
    max-width: 25vw;
    flex: 0 0 auto;
}

.webcam-box {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.webcam-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.webcam-label {
    position: absolute;
    top: 4px;
    left: 8px;
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.webcam-nodata {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: #444;
    pointer-events: none;
    z-index: 2;
}

/* --- Chiron marquee -------------------------------------- */

.chiron-bar {
    flex-shrink: 0;
    height: 28px;
    background: #050505;
    border-top: 1px solid #1a1a1a;
    border-bottom: 1px solid #1a1a1a;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.chiron-track {
    display: flex;
    white-space: nowrap;
    animation: chiron-scroll 20s linear infinite;
}

.chiron-text {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: #39FF14;
    padding: 0 2rem;
    letter-spacing: 0.05em;
}

@keyframes chiron-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- Data view (grid lines canvas) ----------------------- */

.data-view {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    background: #050508;
    position: relative;
    overflow: hidden;
}

#data-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- Lab chat area (bottom half) ------------------------- */

.lab-chat-area {
    flex: 0 0 50%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #08080c;
    border-top: 1px solid hsl(var(--tab-h, 190), 60%, 25%);
}

/* --- Sub-tabs -------------------------------------------- */

.subtab-bar {
    display: flex;
    flex-shrink: 0;
    background: #000;
    border-bottom: 1px solid #1a1a1a;
}

.subtab-btn {
    flex: 1 1 0;
    border: none;
    background: #080810;
    color: #555;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    padding: 8px 4px 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.subtab-btn:hover {
    background: #0e0e18;
    color: #888;
}

.subtab-btn.active {
    background: #101018;
    color: hsl(var(--tab-h, 190), 60%, 55%);
    border-bottom: 2px solid hsl(var(--tab-h, 190), 60%, 35%);
}

.subtab-panels {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.subtab-panel {
    display: none;
    height: 100%;
    overflow-y: auto;
}

.subtab-panel.active {
    display: flex;
    flex-direction: column;
}

.chat-input-area {
    flex-shrink: 0;
    padding: 0.75rem;
    border-top: 1px solid #1a1a1a;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-signin-prompt {
    color: #555;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

.chat-signin-prompt:hover {
    color: hsl(var(--tab-h, 190), 50%, 50%);
}

/* --- Controls sections ----------------------------------- */

.controls-sections {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group {
    background: #0a0a10;
    border: 1px solid #1a1a1a;
    padding: 1rem;
}

.control-group h3 {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.admin-only {
    border-color: #2a1a0a;
}

/* --- Streams list ---------------------------------------- */

.streams-list {
    padding: 1rem;
}

/* ============================================================
   Shared Components
   ============================================================ */

.compact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.compact-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.compact-form label span {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.compact-form input,
.compact-form textarea,
.compact-form select {
    background: #0a0a10;
    border: 1px solid #1a1a1a;
    color: #c8ccd4;
    padding: 0.6rem 0.75rem;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.compact-form input:focus,
.compact-form textarea:focus {
    border-color: hsl(var(--tab-h, 190), 40%, 30%);
}

.btn-primary {
    background: hsl(var(--tab-h, 190), 30%, 18%);
    color: hsl(var(--tab-h, 190), 60%, 70%);
    border: 1px solid hsl(var(--tab-h, 190), 40%, 30%);
    padding: 0.6rem 1.25rem;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: hsl(var(--tab-h, 190), 35%, 22%);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 11px;
}

/* --- Form extras ----------------------------------------- */

.form-row-2col {
    display: flex;
    gap: 0.75rem;
}
.form-row-2col label {
    flex: 1 1 0;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.btn-option {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.6rem;
    background: #0a0a10;
    border: 1px solid #1a1a1a;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
}
.btn-option input[type="radio"] {
    display: none;
}
.btn-option.active {
    background: hsl(var(--tab-h, 140), 20%, 12%);
    border-color: hsl(var(--tab-h, 140), 35%, 25%);
    color: hsl(var(--tab-h, 140), 50%, 55%);
}
.btn-option:hover {
    border-color: #333;
}

fieldset.signalling-group {
    border: none;
    padding: 0;
}
fieldset.signalling-group legend {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

/* --- Profile card ---------------------------------------- */

.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid hsl(var(--tab-h, 220), 40%, 30%);
    object-fit: cover;
}

.profile-stats {
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    color: #888;
}

.profile-about {
    width: 100%;
    text-align: left;
}

.profile-about label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.25rem;
}

.profile-about textarea {
    width: 100%;
    background: #0a0a10;
    border: 1px solid #1a1a1a;
    color: #c8ccd4;
    padding: 0.6rem;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 0.5rem;
}

/* --- Login links ----------------------------------------- */

.login-links {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    font-size: 13px;
    color: #666;
}

.login-links a:hover {
    color: hsl(var(--tab-h, 220), 50%, 50%);
}

/* --- Prose content --------------------------------------- */

.prose-content {
    max-width: 680px;
    font-size: 15px;
    line-height: 1.8;
    color: #b0b4bc;
    padding: 1rem;
}

.prose-content p {
    margin-bottom: 1rem;
}

/* --- Chat messages (compact) ----------------------------- */

.chat-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
}

.chat-placeholder {
    color: #444;
    text-align: center;
    padding: 1rem;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
}

/* --- Placeholder ----------------------------------------- */

.placeholder-text {
    color: #444;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    text-align: center;
    padding: 3rem 1rem;
}

/* --- Flash messages -------------------------------------- */

.flash-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flash {
    padding: 0.6rem 1rem;
    font-size: 13px;
    font-family: 'Roboto Mono', monospace;
    border: 1px solid;
    max-width: 360px;
    animation: flash-in 0.3s ease;
}

.flash-success { background: #0a1a0a; border-color: #1a3a1a; color: #4a8; }
.flash-error   { background: #1a0a0a; border-color: #3a1a1a; color: #a44; }
.flash-info    { background: #0a0a1a; border-color: #1a1a3a; color: #48a; }

@keyframes flash-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* ============================================================
   Responsive
   ============================================================ */

/* Ensure full-height layout */
body {
    display: flex;
    flex-direction: column;
}

/* Touch-friendly */
@media (pointer: coarse) {
    .tab-btn {
        font-size: 13px;
    }
    .subtab-btn {
        padding: 10px 4px 8px;
    }
}

/* Very narrow: force vertical layout */
@media (max-width: 480px) {
    .tab-inner {
        padding: 1rem;
    }
    .tab-btn {
        font-size: 11px;
        letter-spacing: 0;
    }
    .webcam-label {
        font-size: 9px;
    }
}

/* --- Live status bar & device lights --- */
#live-status-bar {
    flex: 0 0 auto;
}
.dev-light {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #666;
}
.dev-light i {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #f23;
    box-shadow: 0 0 3px #f23;
}
.dev-light.on { color: #9c9; }
.dev-light.on i {
    background: #39FF14;
    box-shadow: 0 0 5px #39FF14;
}

/* --- Membership descriptions --------------------------------- */
.membership-desc {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-left: 2px solid hsl(var(--tab-h, 140), 40%, 25%);
    background: rgba(0,0,0,0.2);
}

/* --- Admin inline editor -------------------------------------- */
.admin-edit-btn {
    opacity: 0.7;
    transition: opacity 0.15s;
}
.admin-edit-btn:hover {
    opacity: 1;
}
