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

:root {
  --bg-dark: #0a0a0a;
  --bg-panel: #141414;
  --bg-card: #1e1e1e;
  --accent: #00d4aa;
  --accent-dim: #00a882;
  --accent-red: #e74c3c;
  --accent-yellow: #f39c12;
  --text-primary: #f0f0f0;
  --text-secondary: #999;
  --border: #2a2a2a;
  --shadow: rgba(0, 212, 170, 0.15);
}

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  overflow: hidden;
  height: 100vh;
}

/* ============================================================
   LAYOUT — MAIN PAGE
   ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Left control panel */
.control-panel {
  width: 320px;
  min-width: 280px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.panel-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.panel-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.panel-header .subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 3px;
  letter-spacing: 0.5px;
}

.panel-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-section h2 {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* Clock */
.clock-display {
  font-size: 2.8rem;
  font-weight: 300;
  color: var(--accent);
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 6px 0;
}

.clock-date {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 1px;
}

/* Buttons */
.btn-row {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 10px 14px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.5px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover {
  background: #00f0c0;
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-warning {
  background: var(--accent-yellow);
  color: #000;
}

.btn-warning:hover {
  background: #e67e22;
}

/* Sliders */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.slider-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 90px;
  flex-shrink: 0;
}

.slider-value {
  font-size: 0.75rem;
  color: var(--accent);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

/* Script textarea */
.script-textarea {
  width: 100%;
  height: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

.script-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--shadow);
}

.save-indicator {
  font-size: 0.7rem;
  color: var(--accent);
  text-align: right;
  margin-top: 4px;
  height: 16px;
  transition: opacity 0.5s;
}

/* Connection status */
.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 10px 20px;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}

.status-dot.connected {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.status-dot.disconnected {
  background: var(--accent-red);
}

/* ============================================================
   TELEPROMPTER DISPLAY
   ============================================================ */
.teleprompter-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

/* Gradient fade at top and bottom */
.teleprompter-wrap::before,
.teleprompter-wrap::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 120px;
  z-index: 5;
  pointer-events: none;
}

.teleprompter-wrap::before {
  top: 0;
  background: linear-gradient(to bottom, #000 30%, transparent);
}

.teleprompter-wrap::after {
  bottom: 0;
  background: linear-gradient(to top, #000 30%, transparent);
}

.teleprompter-scroll {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 60vh 8% 100vh;
  transition: none;
}

.script-text {
  color: #fff;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Reading line indicator */
.reading-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 3px;
  background: rgba(0, 212, 170, 0.35);
  z-index: 4;
  pointer-events: none;
}

.reading-line::before,
.reading-line::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.reading-line::before { left: 20px; }
.reading-line::after  { right: 20px; }

/* ============================================================
   REMOTE MESSAGES OVERLAY
   ============================================================ */
.remote-messages-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-height: 40vh;
  overflow: hidden;
}

.remote-message {
  background: rgba(0, 212, 170, 0.22);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  padding: 16px 22px;
  font-size: 2rem;
  color: #fff;
  font-weight: 800;
  backdrop-filter: blur(6px);
  animation: slideInUp 0.3s ease;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
  letter-spacing: 0.3px;
  line-height: 1.3;
}

.remote-message .msg-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   REMOTE PAGE
   ============================================================ */
.remote-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
  background: var(--bg-dark);
}

.remote-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 560px;
  margin-bottom: 24px;
}

.remote-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.remote-card p.subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.input-group {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.remote-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  font-family: inherit;
}

.remote-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--shadow);
}

.remote-history {
  margin-top: 20px;
}

.remote-history h2 {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.history-item {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.history-item .msg-time {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.remote-script-editor {
  width: 100%;
  min-height: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  line-height: 1.6;
}

.remote-script-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--shadow);
}

.remote-save-indicator {
  font-size: 0.7rem;
  color: var(--accent);
  margin-top: 6px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.remote-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 10px 0 0;
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ============================================================
   SPEECH TRACKING
   ============================================================ */
.speech-status {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 8px;
  height: 16px;
  letter-spacing: 0.5px;
}

.btn-mic-active {
  background: #e74c3c !important;
  color: #fff !important;
  animation: mic-pulse 1.5s ease-in-out infinite;
}

.btn-mic-active:hover {
  background: #c0392b !important;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
}

.word-current {
  color: #fff;
  background: rgba(0, 212, 170, 0.35);
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  text-shadow: 0 0 12px rgba(0, 212, 170, 0.6);
  transition: background 0.3s, color 0.3s;
}
