/* Joanna Mission Control — Dark Ops Dashboard
   Aesthetic: Bloomberg terminal meets NASA flight control
   Palette: Deep space blacks, teal (#00D4AA) primary, lobster red (#E85D4A) accent */

:root {
    --bg-0: #0a0b0f;
    --bg-1: #12141a;
    --bg-2: #1a1d26;
    --bg-3: #232733;
    --border: #2a2e3a;
    --border-light: #363b4a;
    --text-0: #e8eaf0;
    --text-1: #a0a4b2;
    --text-2: #6b7080;
    --teal: #00D4AA;
    --teal-dim: #00D4AA33;
    --teal-glow: #00D4AA22;
    --lobster: #E85D4A;
    --lobster-dim: #E85D4A33;
    --green: #34D399;
    --green-dim: #34D39922;
    --red: #F87171;
    --red-dim: #F8717122;
    --yellow: #FBBF24;
    --yellow-dim: #FBBF2422;
    --blue: #60A5FA;
    --blue-dim: #60A5FA22;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-sans: 'Space Grotesk', system-ui, sans-serif;
    --radius: 6px;
    --radius-lg: 10px;
}

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

body {
    font-family: var(--font-mono);
    background: var(--bg-0);
    color: var(--text-0);
    font-size: 13px;
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ===== Screens ===== */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* ===== Login ===== */
#login-screen {
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 30% 50%, var(--teal-glow) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 50%, var(--lobster-dim) 0%, transparent 50%),
        var(--bg-0);
}

.login-container {
    text-align: center;
    padding: 3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-1);
    min-width: 380px;
    box-shadow: 0 0 80px var(--teal-glow);
}

.login-glyph {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.login-title {
    font-family: var(--font-sans);
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--teal);
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-2);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 2.5rem;
}

.login-step { display: none; }
.login-step.active { display: block; }

.btn-primary {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.8rem 2rem;
    background: var(--teal-dim);
    color: var(--teal);
    border: 1px solid var(--teal);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.05em;
    width: 100%;
}

.btn-primary:hover {
    background: var(--teal);
    color: var(--bg-0);
    box-shadow: 0 0 20px var(--teal-dim);
}

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

.btn-icon { margin-right: 0.5rem; }

.otp-hint {
    color: var(--text-1);
    font-size: 0.8rem;
    margin-bottom: 1.5rem;
}

.otp-inputs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
}

.otp-digit {
    width: 3rem;
    height: 3.5rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--bg-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--teal);
    outline: none;
    transition: border-color 0.2s;
}

.otp-digit:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 2px var(--teal-dim);
}

.otp-sep {
    color: var(--text-2);
    font-size: 1.2rem;
}

.login-status {
    margin-top: 1rem;
    font-size: 0.8rem;
    min-height: 1.5em;
}

.login-status.error { color: var(--red); }
.login-status.success { color: var(--green); }
.login-status.loading { color: var(--text-2); }

.login-footer {
    margin-top: 2rem;
    font-size: 0.7rem;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.pulse-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--green); }
    50% { opacity: 0.6; box-shadow: 0 0 8px 2px var(--green-dim); }
}

/* ===== Dashboard Layout ===== */
#dashboard-screen {
    flex-direction: column;
}

/* ===== Top Bar ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 1rem;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-logo { font-size: 1.2rem; }
.topbar-title {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--teal);
    letter-spacing: 0.15em;
}
.topbar-sep { color: var(--border-light); }
.topbar-label {
    font-size: 0.7rem;
    color: var(--text-2);
    letter-spacing: 0.1em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ===== Navigation Tabs ===== */
.nav-tabs {
    display: flex;
    gap: 2px;
}

.nav-tab {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.4rem 0.9rem;
    background: transparent;
    color: var(--text-2);
    border: none;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.03em;
}

.nav-tab:hover {
    color: var(--text-1);
    background: var(--bg-2);
}

.nav-tab.active {
    color: var(--teal);
    background: var(--bg-2);
    border-bottom: 2px solid var(--teal);
}

.tab-icon {
    margin-right: 0.3rem;
    font-size: 0.65rem;
}

/* ===== Date Picker ===== */
.date-picker {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
    background: var(--bg-2);
    color: var(--text-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}

.date-picker:focus { border-color: var(--teal); }

.btn-icon-only {
    font-size: 1rem;
    padding: 0.3rem 0.5rem;
    background: transparent;
    color: var(--text-2);
    border: none;
    cursor: pointer;
    border-radius: var(--radius);
}
.btn-icon-only:hover { color: var(--red); background: var(--red-dim); }

/* ===== Content ===== */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.view-header h2 {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-0);
}

.view-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
}

.stat-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-weight: 500;
}

.view-controls select {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    background: var(--bg-2);
    color: var(--text-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ===== Timeline (Activity View) ===== */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 70px 8px 1fr auto;
    gap: 0.75rem;
    align-items: start;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    background: var(--bg-1);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}

.timeline-item:hover {
    border-color: var(--border-light);
    background: var(--bg-2);
}

.timeline-time {
    font-size: 0.7rem;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    padding-top: 2px;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 5px;
}

.timeline-body { min-width: 0; }

.timeline-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-meta {
    font-size: 0.7rem;
    color: var(--text-2);
    margin-top: 2px;
}

.timeline-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-weight: 500;
    white-space: nowrap;
    align-self: center;
}

.timeline-detail {
    display: none;
    grid-column: 1 / -1;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-0);
    border-radius: var(--radius);
    font-size: 0.75rem;
    color: var(--text-1);
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--border);
}

.timeline-item.expanded .timeline-detail { display: block; }

/* Status Colors */
.status-success { background: var(--green-dim); color: var(--green); }
.status-failed, .status-rejected { background: var(--red-dim); color: var(--red); }
.status-timeout, .status-warning { background: var(--yellow-dim); color: var(--yellow); }
.status-pending { background: var(--blue-dim); color: var(--blue); }
.status-edited { background: var(--teal-dim); color: var(--teal); }

.dot-success { background: var(--green); }
.dot-failed, .dot-rejected { background: var(--red); }
.dot-timeout, .dot-warning { background: var(--yellow); }
.dot-pending { background: var(--blue); }
.dot-edited { background: var(--teal); }

/* ===== Flow Cards ===== */
.flow-group {
    margin-bottom: 1.5rem;
}

.flow-group-header {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-0);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flow-group-header .flow-type {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--teal);
    padding: 0.1rem 0.4rem;
    background: var(--teal-dim);
    border-radius: var(--radius);
}

/* ===== Tweet Metrics Cards ===== */
.tweet-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

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

.tweet-id {
    font-size: 0.7rem;
    color: var(--teal);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.metric-cell {
    background: var(--bg-2);
    border-radius: var(--radius);
    padding: 0.75rem;
    text-align: center;
}

.metric-label {
    font-size: 0.65rem;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.3rem;
}

.metric-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-0);
}

.metric-trend {
    font-size: 0.7rem;
    margin-top: 0.2rem;
}

.trend-up { color: var(--green); }
.trend-down { color: var(--red); }
.trend-flat { color: var(--text-2); }

.snapshot-row {
    display: grid;
    grid-template-columns: 80px repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
}

.snapshot-label {
    color: var(--text-2);
    font-weight: 500;
}

/* ===== Usage View ===== */
.usage-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.usage-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.usage-card-title {
    font-size: 0.7rem;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-3);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

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

.usage-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-sans);
}

.usage-unit {
    font-size: 0.8rem;
    color: var(--text-2);
    margin-left: 0.3rem;
}

/* ===== Token Health ===== */
.token-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.token-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.token-card-title {
    font-size: 0.7rem;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.token-status-indicator {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: var(--font-sans);
    margin: 0.5rem 0;
}

.token-detail {
    font-size: 0.75rem;
    color: var(--text-1);
    margin-top: 0.5rem;
}

/* ===== Approvals ===== */
.approval-item {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
}

.approval-item:hover {
    border-color: var(--border-light);
}

.approval-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.approval-flow {
    font-weight: 500;
    color: var(--text-0);
}

.approval-content {
    font-size: 0.8rem;
    color: var(--text-1);
    padding: 0.5rem;
    background: var(--bg-0);
    border-radius: var(--radius);
    margin-top: 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
    display: none;
}

.approval-item.expanded .approval-content { display: block; }

/* ===== Loading & Empty States ===== */
.loading-state, .empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-2);
    font-size: 0.85rem;
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* ===== Status Bar ===== */
.statusbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 28px;
    padding: 0 1rem;
    background: var(--bg-1);
    border-top: 1px solid var(--border);
    font-size: 0.65rem;
    color: var(--text-2);
    flex-shrink: 0;
}

.statusbar-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.timeline-item, .tweet-card, .approval-item, .usage-card, .token-card, .flow-group {
    animation: fadeIn 0.3s ease both;
}

.timeline-item:nth-child(n) { animation-delay: calc(var(--i, 0) * 30ms); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .nav-tabs { gap: 0; }
    .nav-tab { padding: 0.4rem 0.5rem; font-size: 0.7rem; }
    .tab-icon { display: none; }
    .topbar-label { display: none; }
    .token-cards { grid-template-columns: 1fr; }
}
