/* ═══════════════════════════════════════════════════════════
   OneProp Screener — Dark Trading Terminal Theme
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #151d2e;
    --bg-card-hover: #1a2540;
    --border: #1e293b;
    --border-active: #334155;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.3);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.15);
    --green-bright: #4ade80;
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.15);
    --red-bright: #f87171;
    --yellow: #eab308;
    --yellow-dim: rgba(234, 179, 8, 0.15);
    --orange: #f97316;
    --purple: #a855f7;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-sans: 'Inter', -apple-system, sans-serif;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── Header ─────────────────────────────────────────── */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-center { display: flex; align-items: center; }
.header-right { display: flex; align-items: center; gap: 16px; }

.logo { display: flex; align-items: center; gap: 8px; }
.logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
}
.auth-logo-img {
    width: 120px;
    height: auto;
}
.logo-text {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.5px;
}
.logo-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 24px;
}
.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.stat-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.stat-value {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
}
.stat-value.accent { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.purple { color: var(--purple); }

/* TF Selector */
.tf-selector { display: flex; gap: 2px; }
.tf-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}
.tf-btn:hover { color: var(--text-primary); border-color: var(--border-active); }
.tf-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Connection Status */
.connection-status { display: flex; align-items: center; gap: 6px; }
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--yellow);
    animation: pulse 2s infinite;
}
.status-dot.connected { background: var(--green); animation: none; }
.status-dot.error { background: var(--red); }
.status-text {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ─── Formation Tabs ─────────────────────────────────── */
#formation-tabs {
    display: flex;
    gap: 2px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
}
#formation-tabs::-webkit-scrollbar { height: 3px; }
#formation-tabs::-webkit-scrollbar-thumb { background: var(--border-active); border-radius: 2px; }

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}
.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}
.tab-btn.active {
    background: linear-gradient(135deg, var(--purple), #7c3aed);
    color: #fff;
    border-color: var(--purple);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}
.tab-btn[data-tab="screener"].active {
    background: linear-gradient(135deg, var(--accent), #2563eb);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}
.tab-icon { font-size: 14px; filter: brightness(1.2); }
.tab-count {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
}
.tab-btn.active .tab-count {
    background: rgba(255,255,255,0.35);
}

/* ─── Main Chart Grid ────────────────────────────────── */
#main {
    flex: 1;
    padding: 4px;
    overflow: hidden;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
    height: 100%;
}

.chart-cell {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: border-color 0.4s ease, box-shadow 0.4s ease, transform 0.2s ease;
    position: relative;
}
.chart-cell:hover {
    border-color: var(--border-active);
    transform: scale(1.005);
    z-index: 2;
}
.chart-cell.has-wall {
    border-color: rgba(234, 179, 8, 0.5);
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.08);
}

.cell-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    height: 28px;
    cursor: pointer;
}
.cell-symbol {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    color: var(--text-primary);
}
.cell-price {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}
.cell-change {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
}
.cell-change.up { color: var(--green); }
.cell-change.down { color: var(--red); }
.cell-wall-badge, .cell-formation-badge {
    font-size: 14px;
    font-weight: 700;
    filter: brightness(1.3) saturate(1.2);
}
.cell-wall-badge.hidden, .cell-formation-badge.hidden { display: none; }
.cell-wall-badge { animation: wallPulse 1.5s infinite; }
.cell-formation-badge {
    animation: formGlow 2.5s ease-in-out infinite;
    filter: brightness(1.5) saturate(1.4);
}

@keyframes wallPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.15); }
}
@keyframes formGlow {
    0%, 100% { opacity: 1; transform: scale(1); filter: brightness(1.5) saturate(1.4); }
    50% { opacity: 0.85; transform: scale(1.1); filter: brightness(1.8) saturate(1.6); }
}

.chart-cell.has-formation {
    border-color: rgba(168, 85, 247, 0.25);
    box-shadow: 0 0 6px rgba(168, 85, 247, 0.06);
    animation: formCellPulse 4s ease-in-out infinite;
}

@keyframes formCellPulse {
    0%, 100% { box-shadow: 0 0 6px rgba(168, 85, 247, 0.06); }
    50% { box-shadow: 0 0 10px rgba(168, 85, 247, 0.12); }
}

.cell-chart {
    flex: 1;
    min-height: 0;
}

/* ─── Bottom Panel ────────────────────────────────────── */
#wall-panel {
    height: 800px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.panel-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}
.panel-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.panel-tab:hover { color: var(--text-primary); }
.panel-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.panel-count {
    font-family: var(--font-mono);
    font-size: 10px;
    background: var(--accent);
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    margin-left: 4px;
}
.hidden { display: none !important; }

.wall-table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.wall-table-wrap::-webkit-scrollbar { width: 4px; }
.wall-table-wrap::-webkit-scrollbar-thumb { background: var(--border-active); border-radius: 2px; }

.wall-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.wall-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}
.wall-table th {
    background: var(--bg-card);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.wall-table td {
    padding: 5px 12px;
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.wall-table tr:hover td { background: var(--bg-card-hover); }
.wall-table tr.broken td { opacity: 0.5; text-decoration: line-through; }

.side-bid {
    color: var(--green);
    font-weight: 600;
}
.side-ask {
    color: var(--red);
    font-weight: 600;
}
.wall-size {
    color: var(--yellow);
    font-weight: 700;
}
.wall-status {
    font-weight: 600;
    font-size: 11px;
}
.wall-status.alive { color: var(--green); }
.wall-status.eating { color: var(--orange); }
.wall-status.broken { color: var(--red); }

/* ─── Toast Notifications ────────────────────────────── */
#toast-container {
    position: fixed;
    top: 56px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 16px;
    min-width: 280px;
    max-width: 380px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
    font-size: 12px;
}
.toast.wall-new { border-left-color: var(--yellow); }
.toast.wall-break { border-left-color: var(--red); }

.toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.toast-title {
    font-weight: 700;
    font-size: 13px;
}
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
}
.toast-body {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast.formation { border-left-color: var(--purple); }

/* ─── Toast Toggle ───────────────────────────────────── */
.toast-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 16px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.toast-toggle:hover { border-color: var(--border-active); }
.toast-toggle.active {
    color: var(--yellow);
    border-color: rgba(234, 179, 8, 0.3);
}
.toast-toggle:not(.active) { opacity: 0.5; }

/* ─── Auth Overlay ───────────────────────────────────── */
#auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}
#auth-overlay.hidden { display: none; }

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 56px 48px 44px;
    text-align: center;
    min-width: 380px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.6), 0 0 80px rgba(59, 130, 246, 0.05);
    animation: authFadeIn 0.5s ease-out;
}
@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.auth-logo-img {
    width: 140px;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.15));
}
.auth-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    padding: 4px 16px;
    border-radius: 4px;
    margin-bottom: 24px;
}
.auth-logo .logo-text { font-size: 24px; }
.auth-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
}
#auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.auth-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 16px;
    text-align: center;
    letter-spacing: 3px;
    outline: none;
    transition: border-color 0.2s;
}
.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { letter-spacing: 0; font-size: 13px; color: var(--text-muted); }
.auth-submit {
    background: linear-gradient(135deg, var(--accent), #2563eb);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}
.auth-error {
    color: var(--red);
    font-size: 12px;
    margin-top: 12px;
    animation: shake 0.3s ease-in-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}
