@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Sora:wght@600;700;800&family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light dark;

  --font-heading: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --accent-500: #8b5cf6;

  --success-500: #10b981;
  --success-bg: #d1fae5;
  --success-fg: #065f46;
  --warning-500: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-fg: #92400e;
  --danger-500: #ef4444;
  --danger-bg: #fee2e2;
  --danger-fg: #991b1b;
  --info-500: #0ea5e9;
  --info-bg: #e0f2fe;
  --info-fg: #075985;
  --neutral-bg: #e2e8f0;
  --neutral-fg: #334155;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #131b2e;
    --surface-2: #1a2438;
    --border: #263145;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --success-bg: #06382a;
    --success-fg: #6ee7b7;
    --warning-bg: #422a06;
    --warning-fg: #fcd34d;
    --danger-bg: #450a0a;
    --danger-fg: #fca5a5;
    --info-bg: #0c2c3f;
    --info-fg: #7dd3fc;
    --neutral-bg: #1e293b;
    --neutral-fg: #cbd5e1;
  }
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  letter-spacing: -0.01em;
  margin: 0;
}

a {
  color: var(--primary-600);
}

/* Layout */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 18px;
  height: 18px;
  stroke: white;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card h2 svg {
  width: 18px;
  height: 18px;
  stroke: var(--primary-600);
  flex-shrink: 0;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--text);
}

label.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-600);
}

input[type="text"],
input[type="url"],
input[type="password"],
select {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

button, .btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.1rem;
  transition: transform 100ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

button:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  color: white;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-block {
  width: 100%;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary-600);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
}

.link-btn:hover {
  background: var(--surface-2);
}

.link-btn.danger {
  color: var(--danger-500);
}

.form-message {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.form-message.error {
  color: var(--danger-500);
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1.5px solid var(--border);
}

td {
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-recording::before {
  animation: pulse 1.4s ease-in-out infinite;
}

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

.badge-pending, .badge-cancelled { background: var(--neutral-bg); color: var(--neutral-fg); }
.badge-joining, .badge-uploading { background: var(--info-bg); color: var(--info-fg); }
.badge-recording { background: var(--danger-bg); color: var(--danger-fg); }
.badge-completed { background: var(--success-bg); color: var(--success-fg); }
.badge-failed { background: var(--danger-bg); color: var(--danger-fg); }

.badge-yt-connected { background: var(--success-bg); color: var(--success-fg); }
.badge-yt-disconnected { background: var(--neutral-bg); color: var(--neutral-fg); }

.error-hint {
  color: var(--text-muted);
  cursor: help;
}

/* YouTube panel */
.yt-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.yt-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Login page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.18), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.15), transparent 40%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 2.25rem 2rem;
}

.login-card .brand {
  justify-content: center;
  margin-bottom: 1.75rem;
}

.login-card h1 {
  font-size: 1.35rem;
  text-align: center;
}

.login-card p.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 1.5rem;
}

.password-field {
  position: relative;
}

.password-field input {
  width: 100%;
  padding-inline-end: 2.5rem;
}

.password-toggle {
  position: absolute;
  inset-inline-end: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.3rem;
  display: flex;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

/* Language switcher */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-switcher {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.login-shell .lang-switcher {
  position: absolute;
  top: 1.25rem;
  inset-inline-end: 1.25rem;
  background: var(--surface);
}

.lang-btn {
  background: none;
  border: none;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.lang-btn.active {
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  color: white;
}

/* Arabic / RTL */
:root[dir="rtl"] {
  --font-heading: 'Cairo', system-ui, sans-serif;
  --font-body: 'Cairo', system-ui, sans-serif;
}

/* Small screens */
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  th:nth-child(4), td:nth-child(4) { display: none; } /* bot name column */
  th:nth-child(6), td:nth-child(6) { display: none; } /* created column */
}
