/* ── TRANSCRIPT — Main Stylesheet ─────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;600&family=Bebas+Neue&family=IBM+Plex+Sans:wght@300;400;500&display=swap');

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

:root {
  --bg:      #0a0a0a;
  --surface: #111111;
  --surface2:#1a1a1a;
  --border:  #2a2a2a;
  --accent:  #e8ff47;
  --accent2: #ff4747;
  --text:    #f0f0f0;
  --muted:   #666;
  --green:   #39ff91;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* scanlines */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px,
    rgba(0,0,0,0.07) 2px, rgba(0,0,0,0.07) 4px);
}
/* noise */
body::after {
  content: ''; position: fixed; inset: 0; opacity: 0.025; pointer-events: none; z-index: 9998;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── LAYOUT ────────────────────────────────────────────────────────────────── */

#app { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; overflow: hidden; }

/* ── LOGIN ─────────────────────────────────────────────────────────────────── */

#loginScreen {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
#loginScreen.hidden { display: none; }

.login-card {
  width: 360px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 40px;
  position: relative;
}
.login-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.login-logo {
  font-family: 'Bebas Neue', sans-serif; font-size: 36px; letter-spacing: 5px;
  color: var(--accent); text-shadow: 0 0 24px rgba(232,255,71,0.35); margin-bottom: 4px;
}
.login-sub {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 2.5px;
  color: var(--muted); text-transform: uppercase; margin-bottom: 32px;
}
.login-fields { display: flex; flex-direction: column; gap: 14px; }
.login-field  { display: flex; flex-direction: column; gap: 5px; }
.login-field label {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
}
.login-field input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; font-family: 'IBM Plex Mono', monospace; font-size: 13px;
  width: 100%; outline: none; transition: border-color 0.2s; border-radius: 2px;
}
.login-field input:focus { border-color: var(--accent); }
.login-field input::placeholder { color: #333; }

.server-row { display: grid; grid-template-columns: 1fr 38px; gap: 6px; align-items: end; }

.btn-ping {
  height: 38px; background: var(--bg); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-size: 14px;
}
.btn-ping:hover  { border-color: var(--accent);  color: var(--accent); }
.btn-ping.ok     { border-color: var(--green);   color: var(--green); }
.btn-ping.fail   { border-color: var(--accent2); color: var(--accent2); }

.btn-login {
  margin-top: 8px; width: 100%; padding: 12px;
  background: var(--accent); border: none; color: #000;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; border-radius: 2px; transition: opacity 0.2s; position: relative; overflow: hidden;
}
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-login .spinner {
  display: none; width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,0.3); border-top-color: #000;
  border-radius: 50%; animation: spin 0.6s linear infinite;
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
}
.btn-login.loading .spinner { display: block; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.login-error {
  margin-top: 12px; padding: 10px 14px;
  border: 1px solid var(--accent2); color: var(--accent2);
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  border-radius: 2px; display: none;
}
.login-error.show { display: block; }

/* ── HEADER ────────────────────────────────────────────────────────────────── */

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: relative; z-index: 10;
}
.logo { font-family: 'Bebas Neue', sans-serif; font-size: 28px; letter-spacing: 4px; color: var(--accent); text-shadow: 0 0 20px rgba(232,255,71,0.4); }
.logo span { color: var(--muted); font-size: 11px; font-family: 'IBM Plex Mono', monospace; display: block; letter-spacing: 2px; margin-top: -4px; }
.header-status { display: flex; align-items: center; gap: 16px; }

.session-badge {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px;
  border: 1px solid var(--border); border-radius: 2px;
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 1px; color: var(--muted);
}
.session-badge .sb-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
.session-badge .sb-user { color: var(--accent); }

.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 5px 10px; font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 1px; text-transform: uppercase; cursor: pointer; border-radius: 2px; transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--accent2); color: var(--accent2); }

.status-pill {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 2px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--muted); transition: all 0.3s;
}
.status-pill.active { border-color: var(--green);   color: var(--green);   box-shadow: 0 0 12px rgba(57,255,145,0.15); }
.status-pill.error  { border-color: var(--accent2); color: var(--accent2); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); transition: all 0.3s; }
.status-pill.active .dot { background: var(--green);   animation: pulse 1.5s infinite; }
.status-pill.error  .dot { background: var(--accent2); }
@keyframes pulse { 0%,100%{opacity:1;box-shadow:0 0 6px var(--green);}50%{opacity:.4;box-shadow:none;} }

.timer { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--muted); letter-spacing: 2px; }
.timer.active { color: var(--accent); }

/* ── MAIN GRID ─────────────────────────────────────────────────────────────── */

main { display: grid; grid-template-columns: 300px 1fr; overflow: hidden; }

/* ── LEFT PANEL ────────────────────────────────────────────────────────────── */

.left-panel {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
  background: var(--surface);
}
.left-panel::-webkit-scrollbar { width: 3px; }
.left-panel::-webkit-scrollbar-thumb { background: var(--border); }

.panel-label {
  padding: 14px 20px;
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 3px; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.config-section { padding: 20px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.field-group { display: flex; flex-direction: column; gap: 5px; }

label {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
}
input[type=text], input[type=url], input[type=password], select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  width: 100%; outline: none; transition: border-color 0.2s; border-radius: 2px; -webkit-appearance: none;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: #333; }
select option { background: var(--surface); }

/* token status */
.token-panel { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.token-row { display: flex; align-items: center; justify-content: space-between; font-family: 'IBM Plex Mono', monospace; font-size: 11px; }
.tk-label { color: var(--muted); }
.tk-val        { color: var(--text); }
.tk-val.good   { color: var(--green); }
.tk-val.warn   { color: var(--accent); }
.tk-val.bad    { color: var(--accent2); }
.vend-bar-wrap { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.vend-bar      { height: 100%; background: var(--green); transition: width 0.4s, background 0.4s; border-radius: 2px; }

/* audio monitor */
.visualizer-section { padding: 20px; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.waveform-container { height: 80px; background: var(--bg); border: 1px solid var(--border); border-radius: 2px; overflow: hidden; }
canvas#waveform { width: 100%; height: 100%; }
.audio-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-box { background: var(--bg); border: 1px solid var(--border); padding: 10px 12px; border-radius: 2px; }
.stat-label { font-family: 'IBM Plex Mono', monospace; font-size: 9px; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; }
.stat-value { font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 600; color: var(--accent); margin-top: 2px; }
.speakers-list { display: flex; flex-direction: column; gap: 6px; }
.speaker-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 2px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
}
.speaker-color { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── TRANSCRIPT PANEL ──────────────────────────────────────────────────────── */

.transcript-panel { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.transcript-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.toolbar-left { display: flex; align-items: center; gap: 16px; }
.word-count { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--muted); }

.btn-icon {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 2px; transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

.transcript-body { flex: 1; overflow-y: auto; padding: 28px 32px; scroll-behavior: smooth; }
.transcript-body::-webkit-scrollbar { width: 4px; }
.transcript-body::-webkit-scrollbar-track { background: var(--surface); }
.transcript-body::-webkit-scrollbar-thumb { background: var(--border); }

.transcript-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 12px; text-align: center; }
.transcript-empty .big-icon { font-size: 48px; opacity: 0.15; }
.transcript-empty p { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--muted); letter-spacing: 1px; }

.transcript-segment {
  display: grid; grid-template-columns: 100px 1fr; gap: 16px;
  margin-bottom: 20px; animation: fadeUp 0.3s ease forwards;
}
@keyframes fadeUp { from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:translateY(0);} }

.segment-meta { display: flex; flex-direction: column; gap: 3px; padding-top: 2px; }
.segment-speaker { font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.segment-time    { font-family: 'IBM Plex Mono', monospace; font-size: 9px; color: var(--muted); }
.segment-text    { font-family: 'IBM Plex Sans', sans-serif; font-size: 15px; line-height: 1.65; color: #ddd; border-left: 2px solid var(--border); padding-left: 16px; }
.segment-text.partial { color: var(--muted); font-style: italic; }

.partial-cursor {
  display: inline-block; width: 2px; height: 14px; background: var(--accent);
  margin-left: 2px; vertical-align: middle; animation: blink 0.8s steps(1) infinite;
}
@keyframes blink { 0%,100%{opacity:1;}50%{opacity:0;} }

/* ── FOOTER ────────────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 20px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.controls-left { display: flex; align-items: center; gap: 12px; }

.btn-record {
  display: flex; align-items: center; gap: 10px; padding: 12px 28px;
  background: var(--accent); color: #000; border: none;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase; cursor: pointer; border-radius: 2px;
  transition: all 0.2s; position: relative;
}
.btn-record:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-record.recording { background: var(--accent2); animation: recPulse 2s ease-in-out infinite; }
@keyframes recPulse { 0%,100%{box-shadow:0 0 0 0 rgba(255,71,71,.4);}50%{box-shadow:0 0 0 8px rgba(255,71,71,0);} }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #000; }
.btn-record.recording .rec-dot { animation: recBlink 1s steps(1) infinite; }
@keyframes recBlink { 0%,100%{opacity:1;}50%{opacity:0;} }

.btn-secondary {
  padding: 12px 20px; background: none; border: 1px solid var(--border); color: var(--muted);
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; cursor: pointer; border-radius: 2px; transition: all 0.2s;
}
.btn-secondary:hover    { border-color: var(--text); color: var(--text); }
.btn-secondary:disabled { opacity: 0.3; cursor: not-allowed; }

.controls-right { display: flex; align-items: center; gap: 12px; }
.volume-control { display: flex; align-items: center; gap: 8px; font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--muted); }
input[type="range"] { -webkit-appearance: none; width: 80px; height: 2px; background: var(--border); border: none; padding: 0; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); cursor: pointer; }

/* ── TOAST ─────────────────────────────────────────────────────────────────── */

#toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface2); border: 1px solid var(--border);
  padding: 10px 20px; font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text);
  border-radius: 2px; opacity: 0; transition: all 0.3s; pointer-events: none; z-index: 100;
}
#toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error   { border-color: var(--accent2); color: var(--accent2); }
#toast.success { border-color: var(--green);   color: var(--green); }
