/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6fa;
  --sidebar-bg: #1e2235;
  --sidebar-text: #b0b8d0;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #2e3650;
  --accent: #4f7ef8;
  --accent-hover: #3a64d8;
  --text: #1a1d2e;
  --text-muted: #6b7280;
  --border: #e2e6f0;
  --card-bg: #ffffff;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --topnav-h: 56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ===== Top Nav ===== */
.topnav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topnav-h);
  background: var(--sidebar-bg);
  display: flex; align-items: center;
  padding: 0 20px; gap: 4px;
  z-index: 100;
}

.topnav-logo {
  color: #fff; font-size: 16px; font-weight: 700;
  letter-spacing: -0.3px; white-space: nowrap; flex-shrink: 0;
}

.topnav-links {
  display: flex; list-style: none; gap: 2px;
  flex: 1; margin-left: 16px;
}

.topnav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: 14px; transition: background 0.15s, color 0.15s;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.topnav-item:hover  { background: rgba(255,255,255,0.06); color: #fff; }
.topnav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }
.nav-icon { font-size: 16px; line-height: 1; flex-shrink: 0; }

.topnav-badge { margin-left: auto; flex-shrink: 0; }

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

.main-content {
  flex: 1; min-height: 100vh;
  margin-top: var(--topnav-h);
}
.content-inner {
  padding: 32px 36px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ===== Typography ===== */
h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 14px; }
h3 { font-size: 15px; font-weight: 600; }

/* ===== Cards ===== */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-weight: 600; font-size: 15px; flex: 1; line-height: 1.4; }
.card-meta { font-size: 13px; color: var(--text-muted); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: flex-start; }
.card-body { margin-top: 10px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: none;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, transform 0.1s; text-decoration: none;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover   { background: var(--accent-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d4d9e8; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-ghost   { background: transparent; color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover   { background: var(--border); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Badges ===== */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-gray   { background: #f1f5f9; color: #64748b; }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; background: #fff; color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,126,248,0.15);
}
.form-textarea { min-height: 120px; resize: vertical; font-family: monospace; font-size: 13px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ===== Toggle ===== */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: #cbd5e1;
  border-radius: 24px; cursor: pointer; transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; top: 3px; background: white; border-radius: 50%;
  transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== Search / Filter bar ===== */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 180px; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 20px; justify-content: center; }
.page-info { font-size: 13px; color: var(--text-muted); }

/* ===== Progress bar ===== */
.progress-wrap { background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; margin: 12px 0; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 20px; transition: width 0.4s ease; }

/* ===== Log box ===== */
.log-box {
  background: #1e2235; color: #b0b8d0; font-family: monospace; font-size: 13px;
  padding: 14px; border-radius: var(--radius); max-height: 200px; overflow-y: auto;
  margin: 12px 0;
}
.log-box p { margin: 2px 0; }
.log-box p.ok   { color: #86efac; }
.log-box p.err  { color: #fca5a5; }
.log-box p.info { color: #93c5fd; }

/* ===== Modal ===== */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); position: relative;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title  { font-size: 17px; font-weight: 700; line-height: 1.3; padding-right: 12px; }
.modal-close  { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); line-height: 1; flex-shrink: 0; padding: 4px; -webkit-tap-highlight-color: transparent; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ===== Summary / Transcript ===== */
.summary-text    { white-space: pre-wrap; font-size: 14px; line-height: 1.8; }
.transcript-text { white-space: pre-wrap; font-size: 13px; line-height: 1.7; color: var(--text-muted); max-height: 300px; overflow-y: auto; }

/* ===== Toast ===== */
#toast-container {
  position: fixed; top: calc(var(--topnav-h) + 8px); right: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18); animation: slideIn 0.2s ease;
  max-width: 300px;
}
.toast-success { background: #1e2235; color: #86efac; }
.toast-error   { background: #1e2235; color: #fca5a5; }
.toast-info    { background: #1e2235; color: #93c5fd; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ===== Section divider ===== */
.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  margin: 28px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}


/* ============================================================
   MOBILE  ≤ 640px  (icon-only topnav)
   ============================================================ */
@media (max-width: 640px) {

  /* Hide logo and labels — show icons only */
  .topnav-logo { display: none; }
  .topnav-item .nav-label { display: none; }
  .topnav-badge { display: none; }
  .topnav-item { padding: 10px 12px; }
  .topnav-links { margin-left: 0; }

  /* Content padding */
  .content-inner { padding: 16px 12px; }
  h1 { font-size: 18px; margin-bottom: 14px; }

  /* ─── Cards ─── */
  .card { padding: 14px; border-radius: 12px; margin-bottom: 10px; }
  .card-title { font-size: 14px; }
  .card-meta  { font-size: 12px; gap: 6px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-actions {
    flex-direction: row; flex-wrap: wrap;
    gap: 6px; align-items: center; justify-content: flex-end;
    flex-basis: 100%;
  }

  /* ─── Buttons ─── */
  .btn    { padding: 9px 14px; font-size: 14px; border-radius: 9px; }
  .btn-sm { padding: 7px 12px; font-size: 13px; }

  /* ─── Filter bar ─── */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-bar .form-input,
  .filter-bar .form-select { width: 100% !important; font-size: 15px; }

  /* ─── Forms ─── */
  .form-row { flex-direction: column; gap: 0; }
  .form-input, .form-select { font-size: 16px; padding: 11px 12px; }
  .section-title { margin-top: 20px; }

  /* ─── Modal → bottom sheet ─── */
  .modal-backdrop { align-items: flex-end; }
  .modal {
    max-width: 100%; border-radius: 20px 20px 0 0;
    max-height: 92vh; padding: 20px 18px 32px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .modal::before {
    content: ''; display: block; width: 40px; height: 4px;
    background: var(--border); border-radius: 4px;
    margin: 0 auto 16px;
  }
  .modal-header { margin-bottom: 16px; }
  .modal-title  { font-size: 16px; }
  .modal-footer { flex-direction: column-reverse; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }

  /* ─── Log box ─── */
  .log-box { font-size: 12px; max-height: 150px; }

  /* ─── Progress ─── */
  .progress-wrap { height: 6px; }

  /* ─── Pagination ─── */
  .pagination { gap: 6px; }
  .btn.btn-secondary.btn-sm { min-width: 72px; justify-content: center; }

  /* ─── Toast ─── */
  #toast-container {
    top: calc(var(--topnav-h) + 6px);
    left: 12px; right: 12px;
  }
  .toast { max-width: 100%; text-align: center; }

  /* ─── Summary text ─── */
  .summary-text    { font-size: 14px; line-height: 1.9; }
  .transcript-text { font-size: 12px; }

  /* ─── Channels page header ─── */
  .page-header-row { flex-direction: column; align-items: stretch !important; gap: 10px; }
  .page-header-row .btn { width: 100%; justify-content: center; }
}

/* very small phones */
@media (max-width: 380px) {
  .content-inner { padding: 12px 10px; }
  .topnav-item { padding: 10px 10px; }
  .nav-icon { font-size: 18px; }
}
