/* ============================================================
   SpeakGrid – Stylesheet
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #4f46e5;
  --primary-dk: #3730a3;
  --success:    #16a34a;
  --warning:    #d97706;
  --danger:     #dc2626;
  --secondary:  #6b7280;
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --text-muted: #64748b;
  --radius:     10px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg:  0 4px 6px rgba(0,0,0,.07), 0 10px 30px rgba(0,0,0,.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 7px; font-size: 14px; font-weight: 500;
  border: 2px solid transparent; cursor: pointer; transition: all .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { opacity: .88; text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--primary);   color: #fff; border-color: var(--primary); }
.btn-success  { background: var(--success);   color: #fff; border-color: var(--success); }
.btn-danger   { background: var(--danger);    color: #fff; border-color: var(--danger); }
.btn-warning  { background: var(--warning);   color: #fff; border-color: var(--warning); }
.btn-secondary{ background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-outline  { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--border); }
.btn-full     { width: 100%; justify-content: center; }
.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-xs  { padding: 4px 10px; font-size: 12px; border-radius: 5px; }

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.header-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; justify-content: space-between;
}
.header-logo {
  font-size: 18px; font-weight: 700; color: var(--primary);
  text-decoration: none; display: flex; align-items: center; gap: 8px;
}
.header-right  { display: flex; align-items: center; gap: 10px; }
.student-badge { font-size: 14px; color: var(--text-muted); }
.admin-name    { font-size: 14px; color: var(--text-muted); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px;
  font-size: 14px; font-weight: 500;
}
.alert-error   { background: #fef2f2; color: var(--danger);  border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success);  border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: var(--warning);  border: 1px solid #fde68a; }

/* ── Auth / Landing pages ─────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
}
.auth-card {
  background: var(--surface); border-radius: 16px;
  padding: 40px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.auth-logo h1 { font-size: 26px; color: var(--primary); margin-bottom: 4px; }
.auth-logo p  { color: var(--text-muted); }
.auth-footer  { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 14px; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 12px; border-radius: 7px;
  border: 1.5px solid var(--border); font-size: 15px;
  background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-group small { display: block; margin-top: 5px; color: var(--text-muted); font-size: 12px; }
.form-group input[type="file"] { padding: 8px; }
.required { color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }
.form-card { background: var(--surface); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }

/* ── Topic page ───────────────────────────────────────────── */
.topic-main { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }

.topic-hero { margin-bottom: 32px; }
.topic-hero h1 { font-size: 26px; margin-bottom: 8px; }
.topic-desc { color: var(--text-muted); margin-bottom: 20px; white-space: pre-wrap; }
.starter-label { font-weight: 600; margin-bottom: 10px; color: var(--primary); }
.starter-video-wrap { margin-bottom: 8px; }
.starter-video {
  width: 100%; max-height: 380px; border-radius: var(--radius);
  background: #000; box-shadow: var(--shadow);
}

/* ── Record section ───────────────────────────────────────── */
.record-section { margin-bottom: 40px; }
.record-section h2 { font-size: 20px; margin-bottom: 14px; }
.record-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); border: 2px solid var(--border);
}
.choose-btns { display: flex; gap: 12px; flex-wrap: wrap; }

.preview-wrap { position: relative; margin-bottom: 14px; }
.preview-video {
  width: 100%; max-height: 320px; border-radius: 8px;
  background: #1a1a2e; display: block;
}
.record-timer {
  position: absolute; bottom: 12px; right: 12px;
  background: rgba(0,0,0,.7); color: #fff;
  padding: 4px 10px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.record-timer.recording { color: #ff4444; }
.record-controls { display: flex; gap: 10px; flex-wrap: wrap; }

.review-label { font-weight: 500; margin-bottom: 10px; }
.review-controls { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.upload-progress { margin-top: 16px; }
.progress-bar { background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 20px; transition: width .3s; width: 0; }
#progress-label { font-size: 13px; color: var(--text-muted); }

.success-msg { text-align: center; padding: 20px 0; }
.success-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.success-msg h3 { font-size: 20px; margin-bottom: 8px; }
.success-msg p  { color: var(--text-muted); margin-bottom: 18px; }

.reply-banner {
  margin-top: 16px; padding: 10px 14px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 7px;
  display: flex; align-items: center; gap: 10px; font-size: 14px;
}

/* ── Video grid ───────────────────────────────────────────── */
.grid-section h2 { font-size: 20px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.count-badge {
  background: var(--primary); color: #fff;
  font-size: 13px; padding: 2px 10px; border-radius: 20px; font-weight: 600;
}
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.video-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.video-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.video-wrap { position: relative; background: #0f0f1a; }
.grid-video { width: 100%; max-height: 180px; display: block; object-fit: cover; }
.card-footer {
  padding: 10px 12px; display: flex; justify-content: space-between;
  align-items: center; font-size: 13px;
}
.student-name { font-weight: 600; color: var(--text); }
.card-time    { color: var(--text-muted); }
.btn-reply    { margin: 0 12px 12px; width: calc(100% - 24px); justify-content: center; }

.replies-wrap { border-top: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.reply-card { background: var(--bg); border-radius: 8px; overflow: hidden; }
.reply-video { width: 100%; max-height: 140px; display: block; }

.empty-msg { color: var(--text-muted); font-style: italic; padding: 24px 0; }

/* ── Admin pages ──────────────────────────────────────────── */
.admin-body { background: var(--bg); }
.admin-main { max-width: 900px; margin: 0 auto; padding: 32px 20px 60px; }
.admin-header-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.admin-header-row h1 { font-size: 24px; }

.topic-list { display: flex; flex-direction: column; gap: 14px; }
.topic-row {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
}
.topic-row.inactive { opacity: .6; }
.topic-info h3 { font-size: 17px; margin-bottom: 6px; }
.topic-info h3 a { color: var(--text); }
.topic-info h3 a:hover { color: var(--primary); text-decoration: none; }
.topic-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--text-muted); }
.topic-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge-inactive {
  background: var(--border); color: var(--text-muted);
  font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500;
}
.pending-badge { color: var(--warning); font-weight: 600; }

.empty-admin { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-admin p { margin-bottom: 20px; font-size: 16px; }
.admin-footer-links { margin-top: 32px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* Moderation grid */
.mod-count { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }
.mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.mod-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.mod-video-wrap { background: #0f0f1a; }
.mod-video { width: 100%; max-height: 200px; display: block; }
.mod-info { padding: 12px 14px; }
.mod-student { font-size: 15px; margin-bottom: 4px; }
.mod-topic, .mod-date { font-size: 13px; color: var(--text-muted); }
.mod-reply-badge {
  font-size: 12px; color: var(--primary);
  margin-top: 4px; font-style: italic;
}
.mod-actions { padding: 0 14px 14px; display: flex; gap: 8px; }
.mod-actions .btn { flex: 1; justify-content: center; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .topic-row { flex-direction: column; align-items: flex-start; }
  .topic-actions { width: 100%; }
  .auth-card { padding: 28px 20px; }
  .admin-header-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .choose-btns { flex-direction: column; }
  .form-actions { flex-direction: column; }
}
