/* ============================================================
   TelePrompter Studio — Main Stylesheet
   Aesthetic: Cinematic broadcast studio — deep black, amber
   ============================================================ */

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

:root {
  --black:    #0a0a0c;
  --dark:     #111115;
  --panel:    #16161c;
  --border:   #2a2a35;
  --amber:    #f5a623;
  --amber2:   #ffc84a;
  --red:      #e03e3e;
  --green:    #3ecf7a;
  --white:    #f0ede8;
  --muted:    #7a7a8a;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;
  --radius:   8px;
  --trans:    .18s ease;
}

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--black);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber2); }

/* ---------- AUTH PAGE ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, #1e1408 0%, var(--black) 70%);
  overflow: hidden;
}
.film-grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: .45;
}
.scan-lines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.08) 2px, rgba(0,0,0,.08) 4px);
  pointer-events: none;
}
.auth-glow {
  position: absolute; top: -200px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 400px;
  background: radial-gradient(ellipse, rgba(245,166,35,.12) 0%, transparent 70%);
}

.auth-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2.5rem 2rem;
  box-shadow: 0 24px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(245,166,35,.06);
  animation: slideUp .4s cubic-bezier(.2,.8,.4,1) both;
}
@keyframes slideUp { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:translateY(0); } }

.auth-logo {
  display: flex; align-items: center; gap: .7rem;
  margin-bottom: .5rem;
}
.logo-icon {
  width: 38px; height: 38px;
  background: var(--amber);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--black); font-weight: 900;
}
.logo-text {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: .04em;
  color: var(--white);
}
.auth-tagline { color: var(--muted); font-size: .85rem; margin-bottom: 1.6rem; }

.auth-tabs {
  display: flex; gap: 2px;
  background: var(--dark);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 1.4rem;
}
.tab-btn {
  flex: 1; padding: .55rem;
  background: transparent; border: none;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted); font-family: var(--font-body);
  font-size: .9rem; font-weight: 500; cursor: pointer;
  transition: var(--trans);
}
.tab-btn.active { background: var(--amber); color: var(--black); font-weight: 700; }
.tab-btn:not(.active):hover { color: var(--white); }

.auth-form { display: none; flex-direction: column; gap: 1rem; }
.auth-form.active { display: flex; }

.field-group { display: flex; flex-direction: column; gap: .4rem; }
.field-group label { font-size: .8rem; font-weight: 500; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.field-group input, .field-group textarea {
  background: var(--dark); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--white);
  font-family: var(--font-body); font-size: .95rem;
  padding: .7rem .9rem; outline: none;
  transition: border-color var(--trans);
}
.field-group input:focus, .field-group textarea:focus { border-color: var(--amber); }
.field-group textarea { resize: vertical; line-height: 1.6; }

.btn-primary {
  margin-top: .3rem;
  padding: .75rem 1.4rem;
  background: var(--amber); color: var(--black);
  border: none; border-radius: var(--radius);
  font-family: var(--font-display); font-size: 1.15rem;
  letter-spacing: .06em; cursor: pointer;
  transition: var(--trans);
  box-shadow: 0 4px 18px rgba(245,166,35,.3);
}
.btn-primary:hover { background: var(--amber2); transform: translateY(-1px); box-shadow: 0 6px 24px rgba(245,166,35,.45); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  width: 100%; padding: .6rem .9rem;
  background: var(--dark); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--white);
  font-family: var(--font-body); font-size: .88rem;
  cursor: pointer; transition: var(--trans); text-align: left;
  margin-bottom: .4rem;
}
.btn-secondary:hover { border-color: var(--amber); color: var(--amber); }

.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--muted);
  font-family: var(--font-body); font-size: .88rem;
  padding: .55rem 1rem; cursor: pointer; transition: var(--trans);
}
.btn-ghost:hover { border-color: var(--white); color: var(--white); }

.form-footer { text-align: center; font-size: .83rem; color: var(--muted); margin-top: .4rem; }

.alert {
  padding: .75rem 1rem; border-radius: var(--radius);
  font-size: .88rem; font-weight: 500; margin-bottom: .2rem;
}
.alert-error   { background: rgba(224,62,62,.15); border: 1px solid rgba(224,62,62,.4); color: #f97474; }
.alert-success { background: rgba(62,207,122,.12); border: 1px solid rgba(62,207,122,.3); color: #5be898; }

/* ---------- SITE HEADER ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; height: 58px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-logo { display: flex; align-items: center; gap: .6rem; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.user-badge {
  background: var(--dark); border: 1px solid var(--border);
  border-radius: 99px; padding: .3rem .85rem;
  font-size: .82rem; color: var(--muted); font-family: var(--font-mono);
}

/* ---------- DASHBOARD ---------- */
.dashboard-page { background: var(--black); min-height: 100vh; }
.dashboard-main { padding: 2.5rem 2rem; max-width: 1100px; margin: 0 auto; }
.dash-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 2rem;
}
.dash-title { font-family: var(--font-display); font-size: 2.6rem; letter-spacing: .04em; }
.dash-subtitle { color: var(--muted); font-size: .9rem; margin-top: .2rem; }

.scripts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.2rem;
}
.script-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.3rem 1.4rem;
  display: flex; flex-direction: column; gap: 1rem;
  transition: border-color var(--trans), transform var(--trans);
}
.script-card:hover { border-color: var(--amber); transform: translateY(-2px); }
.script-title { font-size: 1.05rem; font-weight: 500; color: var(--white); }
.script-meta  { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.script-card-actions { display: flex; gap: .6rem; align-items: center; }

.btn-launch {
  flex: 1; padding: .6rem .8rem;
  background: var(--amber); color: var(--black);
  border-radius: var(--radius); font-family: var(--font-display);
  font-size: 1rem; letter-spacing: .05em; text-align: center;
  transition: var(--trans); border: none; cursor: pointer;
}
.btn-launch:hover { background: var(--amber2); color: var(--black); }

.btn-edit, .btn-delete {
  padding: .55rem .85rem; border-radius: var(--radius);
  font-size: .82rem; cursor: pointer; border: 1px solid var(--border);
  background: var(--dark); color: var(--muted); transition: var(--trans);
}
.btn-edit:hover   { border-color: var(--amber); color: var(--amber); }
.btn-delete:hover { border-color: var(--red); color: var(--red); }

.empty-state {
  grid-column: 1/-1; text-align: center;
  padding: 5rem 2rem; color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-size: 1.4rem; font-weight: 400; margin-bottom: .5rem; color: var(--white); }
.empty-state p  { font-size: .9rem; margin-bottom: 1.5rem; }

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  animation: popIn .22s cubic-bezier(.2,.8,.4,1) both;
}
.modal-wide { max-width: 780px; }
@keyframes popIn { from { opacity:0; transform:scale(.94); } to { opacity:1; transform:scale(1); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: .04em; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--dark); border: 1px solid var(--border);
  color: var(--muted); font-size: .95rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--trans);
}
.modal-close:hover { border-color: var(--red); color: var(--red); }
.modal-body {
  padding: 1.5rem; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 1rem;
}
.modal-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .7rem;
}

/* ---------- TELEPROMPTER PAGE ---------- */
.prompter-page { background: var(--black); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

.prompter-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 52px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 50;
}
.back-btn { font-size: .85rem; color: var(--muted); transition: color var(--trans); }
.back-btn:hover { color: var(--amber); }
.script-name-display { font-family: var(--font-display); font-size: 1.2rem; letter-spacing: .05em; color: var(--amber); }

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

/* ----- CONTROLS PANEL ----- */
.controls-panel {
  width: 230px; flex-shrink: 0;
  background: var(--panel); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: .2rem;
}
.ctrl-section {
  padding: .9rem 0; border-bottom: 1px solid var(--border);
}
.ctrl-section:last-child { border-bottom: none; }
.ctrl-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .12em;
  color: var(--muted); text-transform: uppercase; margin-bottom: .65rem;
  display: flex; justify-content: space-between; align-items: center;
}
.ctrl-val { color: var(--amber); font-family: var(--font-mono); font-weight: 400; }

.main-controls { display: flex; gap: .4rem; margin-bottom: .6rem; }
.ctrl-btn {
  flex: 1; padding: .55rem .5rem;
  border: none; border-radius: var(--radius);
  font-family: var(--font-body); font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: var(--trans);
}
.btn-play  { background: var(--amber); color: var(--black); }
.btn-play:hover  { background: var(--amber2); }
.btn-pause { background: var(--amber); color: var(--black); }
.btn-pause:hover { background: var(--amber2); }
.btn-reset { background: var(--dark); border: 1px solid var(--border); color: var(--muted); }
.btn-reset:hover { border-color: var(--white); color: var(--white); }

.progress-bar-wrap {
  height: 4px; background: var(--dark); border-radius: 99px; overflow: hidden; margin-bottom: .4rem;
}
.progress-bar { height: 100%; background: var(--amber); width: 0%; transition: width .3s; }
.time-display { font-family: var(--font-mono); font-size: .82rem; color: var(--muted); text-align: right; }

.ctrl-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 99px;
  background: var(--dark); outline: none; cursor: pointer;
  margin-top: .2rem;
}
.ctrl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--amber); cursor: pointer;
  box-shadow: 0 0 0 3px rgba(245,166,35,.25);
}
.ctrl-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--amber); cursor: pointer; border: none;
}

.color-row {
  display: flex; gap: .6rem; flex-wrap: wrap;
  font-size: .8rem; color: var(--muted);
}
.color-row label { display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }
.color-row input[type="color"] {
  width: 44px; height: 28px; border: 1px solid var(--border);
  border-radius: var(--radius); background: transparent; cursor: pointer; padding: 2px;
}

.toggle-row { margin-top: .6rem; }
.toggle-label { display: flex; align-items: center; justify-content: space-between; font-size: .85rem; cursor: pointer; }
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--dark); border: 1px solid var(--border);
  border-radius: 99px; cursor: pointer; transition: var(--trans);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; background: var(--muted);
  border-radius: 50%; left: 2px; top: 2px; transition: var(--trans);
}
.toggle input:checked + .toggle-slider { background: rgba(245,166,35,.25); border-color: var(--amber); }
.toggle input:checked + .toggle-slider::before { background: var(--amber); transform: translateX(18px); }

.btn-cam, .btn-record {
  width: 100%; padding: .6rem .8rem;
  border-radius: var(--radius); font-size: .84rem; cursor: pointer;
  font-family: var(--font-body); font-weight: 500; transition: var(--trans);
  border: 1px solid var(--border); margin-bottom: .5rem;
}
.btn-cam    { background: var(--dark); color: var(--white); }
.btn-cam:hover { border-color: var(--amber); color: var(--amber); }
.btn-record { background: var(--dark); color: var(--white); }
.btn-record:hover { border-color: var(--red); color: var(--red); }
.btn-record.recording { background: rgba(224,62,62,.15); border-color: var(--red); color: var(--red); animation: recPulse 1s infinite; }
@keyframes recPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(224,62,62,.4); } 50% { box-shadow: 0 0 0 6px rgba(224,62,62,0); } }

.rec-indicator {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; display: inline-block; margin-right: .4rem;
}
.rec-indicator.active { background: var(--red); animation: blink .8s infinite; }
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0;} }
.rec-time { display: inline; font-family: var(--font-mono); font-size: .82rem; color: var(--muted); }

.rec-item {
  background: var(--dark); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55rem .7rem;
  margin-top: .5rem;
}
.rec-name  { font-size: .78rem; color: var(--muted); display: block; margin-bottom: .4rem; }
.rec-btns  { display: flex; gap: .4rem; }
.btn-download, .btn-preview {
  padding: .3rem .6rem; font-size: .75rem; border-radius: 4px; cursor: pointer;
  text-decoration: none; font-family: var(--font-body);
}
.btn-download { background: var(--green); color: var(--black); font-weight: 700; }
.btn-preview  { background: var(--dark); border: 1px solid var(--border); color: var(--muted); }
.btn-preview:hover { color: var(--white); }

/* ----- PROMPTER WRAP ----- */
.prompter-wrap {
  flex: 1; position: relative; overflow: hidden;
  background: #000;
}
.prompter-scroll {
  position: absolute; inset: 0; overflow-y: scroll; overflow-x: hidden;
  scroll-behavior: auto; padding: 10vh 8vw;
  scrollbar-width: thin; scrollbar-color: rgba(245,166,35,.3) transparent;
}
.prompter-scroll::-webkit-scrollbar { width: 5px; }
.prompter-scroll::-webkit-scrollbar-track { background: transparent; }
.prompter-scroll::-webkit-scrollbar-thumb { background: rgba(245,166,35,.3); border-radius: 99px; }
.prompter-text {
  line-height: 1.55; font-weight: 400;
  word-break: break-word; white-space: pre-wrap;
  font-family: var(--font-body);
  transition: font-size .15s, color .2s, transform .2s;
  max-width: 900px; margin: 0 auto;
}
.prompter-end-pad { height: 50vh; }

.focus-guide {
  position: absolute; top: 50%; left: 0; right: 0;
  height: 4px; transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, rgba(245,166,35,.35), transparent);
  pointer-events: none;
}

/* Countdown overlay */
.countdown-overlay {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(0,0,0,.85); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.countdown-num {
  font-family: var(--font-display); font-size: 16rem; line-height: 1;
  color: var(--amber); text-shadow: 0 0 80px rgba(245,166,35,.6);
}
.countdown-num.pop { animation: pop .4s cubic-bezier(.2,.8,.4,1); }
@keyframes pop { from { transform: scale(1.4); opacity:.6; } to { transform: scale(1); opacity:1; } }

/* ----- CAMERA PANEL ----- */
.camera-panel {
  width: 320px; flex-shrink: 0;
  background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.camera-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; color: var(--muted);
}
.cam-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; transition: color var(--trans); }
.cam-close:hover { color: var(--red); }
.cam-preview { width: 100%; aspect-ratio: 16/9; background: var(--dark); object-fit: cover; }
.cam-status  { padding: .5rem 1rem; font-size: .8rem; color: var(--green); font-family: var(--font-mono); }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--panel); border: 1px solid var(--border);
  color: var(--white); padding: .7rem 1.4rem; border-radius: 99px;
  font-size: .88rem; z-index: 999; opacity: 0; pointer-events: none;
  transition: all .3s cubic-bezier(.2,.8,.4,1);
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(224,62,62,.5); background: rgba(224,62,62,.12); }

/* ---------- SCROLLBAR (global) ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  .controls-panel { width: 190px; }
  .camera-panel   { width: 240px; }
}
@media (max-width: 700px) {
  .prompter-layout { flex-direction: column; }
  .controls-panel  { width: 100%; flex-direction: row; flex-wrap: wrap; height: auto; overflow-x: auto; }
  .camera-panel    { width: 100%; height: 200px; }
  .auth-container  { margin: 1rem; padding: 1.8rem 1.5rem; }
  .dash-header     { flex-direction: column; gap: 1rem; align-items: flex-start; }
}
