/* ============================
   Stream Director - Global Styles
   ============================ */

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

:root {
  --bg: #0d0f14;
  --surface: #1a1d26;
  --surface2: #22263a;
  --border: #2e3352;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #ed4245;
  --success: #3ba55d;
  --warning: #faa61a;
  --text: #e8eaf0;
  --text-muted: #7a7f9a;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Login Screen ---- */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-box .logo {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.login-box h1 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.login-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
  justify-content: center;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c03537; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #2d8049; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

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

/* ---- Status Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-live { background: rgba(237,66,69,0.2); color: var(--danger); }
.badge-ready { background: rgba(59,165,93,0.2); color: var(--success); }
.badge-waiting { background: rgba(122,127,154,0.2); color: var(--text-muted); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.dot.pulse { animation: pulse 1.5s infinite; }

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

/* ---- Error message ---- */
.error-msg {
  background: rgba(237,66,69,0.15);
  border: 1px solid rgba(237,66,69,0.4);
  border-radius: 6px;
  color: #f47c7e;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-top: 12px;
  display: none;
}

/* ---- Header ---- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-title {
  font-size: 1rem;
  font-weight: 700;
}

.header-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- Main Layout ---- */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  font-weight: 600;
}

/* ---- Video Grid ---- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.video-card {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.video-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.video-card.active {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(237,66,69,0.3);
}

.video-card video {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  display: block;
}

.video-card .card-label {
  padding: 8px 10px;
  font-size: 0.83rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.5);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.video-card .active-badge {
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---- Streamer Big View ---- */
.stream-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stream-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.stream-preview .no-signal {
  color: var(--text-muted);
  text-align: center;
}

.stream-preview .no-signal .icon { font-size: 3rem; }
.stream-preview .no-signal p { margin-top: 8px; font-size: 0.9rem; }

/* ---- Auto Switch Controls ---- */
.switch-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.switch-controls label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.switch-controls input[type="number"] {
  width: 70px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 0.9rem;
}

.timer-bar {
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.timer-bar-fill {
  height: 100%;
  background: var(--danger);
  transition: width 0.5s linear;
}

/* ---- Streamer Page ---- */
.streamer-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}

.share-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.share-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  font-size: 3rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-btn.idle {
  background: var(--surface2);
  border: 3px solid var(--border);
  color: var(--text-muted);
}

.share-btn.idle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

.share-btn.streaming {
  background: rgba(237,66,69,0.15);
  border: 3px solid var(--danger);
  color: var(--danger);
  animation: ring 2s infinite;
}

@keyframes ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(237,66,69,0.4); }
  50% { box-shadow: 0 0 0 16px rgba(237,66,69,0); }
}

.streamer-info {
  font-size: 1rem;
  color: var(--text-muted);
}

/* ---- OBS View (Fullscreen) ---- */
body.view-mode {
  background: #000;
}

.view-video {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
}

.view-video video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- Loading ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  padding: 40px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 300px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--accent); }

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

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .main-content { padding: 12px; }
  .video-grid { grid-template-columns: 1fr 1fr; }
  .switch-controls { flex-direction: column; align-items: flex-start; }
}
