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

/* ── Design tokens ─────────────────────────────── */
:root {
  /* CTD-Africa brand */
  --amber:        #F5A623;
  --amber-dark:   #C97F0A;
  --amber-deeper: #8A5600;
  --amber-light:  #FEF3DC;
  --amber-mid:    #FAD27A;

  /* Neutrals */
  --bg:           #ffffff;
  --bg-secondary: #fafaf9;
  --bg-tertiary:  #f3f2ef;
  --text:         #1a1a18;
  --text-secondary: #5a5956;
  --text-muted:   #9a9894;
  --border:       rgba(0,0,0,0.09);
  --border-md:    rgba(0,0,0,0.15);

  /* Status */
  --green:  #3a7d17;
  --green-bg: #edf7e1;
  --green-border: #b4dea0;
  --red:    #c0392b;
  --red-bg: #fce8e6;
  --red-border: #f5b7b1;

  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --font: 'Inter', system-ui, sans-serif;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #18170f;
    --bg-secondary: #201e12;
    --bg-tertiary:  #2a2716;
    --text:         #f5ead6;
    --text-secondary: #b0a882;
    --text-muted:   #6e6848;
    --border:       rgba(245,166,35,0.12);
    --border-md:    rgba(245,166,35,0.22);
    --amber-light:  #2a2204;
    --amber-mid:    #7a5800;
    --green-bg:     #1a2e0a;
    --green-border: #3a5e20;
    --red-bg:       #2e0d0a;
    --red-border:   #6e2820;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
  }
}

/* ── Base ──────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg-tertiary);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────── */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 11px; }
.logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 50%;
  border: 2px solid var(--amber-mid);
  padding: 2px;
  background: var(--amber-light);
}
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-name { font-size: 15px; font-weight: 700; color: var(--amber-dark); letter-spacing: -.2px; }
.logo-sub  { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.powered-badge {
  font-size: 11px;
  color: var(--amber-deeper);
  background: var(--amber-light);
  border: 1px solid var(--amber-mid);
  border-radius: 20px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.powered-badge i { color: var(--amber); }

/* ── Layout ────────────────────────────────────── */
.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem;
}
.app-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 800px) {
  .app-grid { grid-template-columns: 1fr; }
  .panel-right { order: -1; }
}
.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow);
}
.panel-right {
  background: var(--bg-secondary);
  position: sticky;
  top: 74px;
}

/* ── Accent bar on left panel ──────────────────── */
.panel-left { border-top: 3px solid var(--amber); }

/* ── Typography helpers ────────────────────────── */
.label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  display: block;
}
.label-hint { font-weight: 400; color: var(--text-muted); }
.section-title { font-size: 13px; font-weight: 600; color: var(--text); }
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}
.label-row .label { margin: 0; }
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.link-small {
  font-size: 11px;
  color: var(--amber-dark);
  text-decoration: none;
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.link-small:hover { text-decoration: underline; }
.link-amber { color: var(--amber-dark); text-decoration: none; }
.link-amber:hover { text-decoration: underline; }

/* ── Forms ─────────────────────────────────────── */
textarea, select, input[type="password"], input[type="text"] {
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  padding: 8px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: none; line-height: 1.65; }
textarea:focus, select:focus, input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245,166,35,.15);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Buttons ───────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 11px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-md);
  background: var(--amber);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: opacity .15s, transform .1s;
  letter-spacing: .2px;
  box-shadow: 0 2px 8px rgba(245,166,35,.4);
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  font-family: var(--font);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background .15s;
}
.btn-sm:hover { background: var(--bg-tertiary); }

.enhance-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--font);
  border: 1px solid var(--amber-mid);
  border-radius: var(--radius-sm);
  background: var(--amber-light);
  color: var(--amber-deeper);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background .15s;
}
.enhance-btn:hover { background: var(--amber-mid); }
.enhance-btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-post {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  opacity: .5;
  transition: opacity .15s, background .15s;
}
.btn-post.enabled {
  background: var(--amber);
  color: #fff;
  border-color: transparent;
  cursor: pointer;
  opacity: 1;
  box-shadow: 0 2px 8px rgba(245,166,35,.35);
}
.btn-post.enabled:hover { opacity: .9; }

/* ── Platform buttons ──────────────────────────── */
.platform-btns { display: flex; gap: 6px; }
.platform-btn {
  flex: 1;
  padding: 7px 4px;
  font-size: 11px;
  font-family: var(--font);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all .15s;
}
.platform-btn i { font-size: 16px; }
.platform-btn.active {
  border-color: var(--amber);
  color: var(--amber-deeper);
  background: var(--amber-light);
  font-weight: 500;
}

/* ── Tabs ──────────────────────────────────────── */
.tab-bar {
  display: flex;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.tab {
  flex: 1;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  text-align: center;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background .15s, color .15s;
}
.tab:not(:last-child) { border-right: 1px solid var(--border-md); }
.tab.active { background: var(--amber-light); color: var(--amber-deeper); }

/* ── Segmented control ─────────────────────────── */
.seg-group {
  display: flex;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.seg {
  flex: 1;
  padding: 6px 3px;
  font-size: 11px;
  font-family: var(--font);
  text-align: center;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  transition: background .15s;
}
.seg:not(:last-child) { border-right: 1px solid var(--border-md); }
.seg.active { background: var(--amber-light); color: var(--amber-deeper); font-weight: 500; }

/* ── Key row ───────────────────────────────────── */
.key-row { display: flex; gap: 7px; align-items: center; margin-bottom: 5px; }
.key-row input { flex: 1; }

/* ── Notices ───────────────────────────────────── */
.notice {
  padding: 7px 11px;
  border-radius: var(--radius-md);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
}
.notice-success { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.notice-error   { background: var(--red-bg);   border: 1px solid var(--red-border);   color: var(--red); }
.notice-warn    { background: var(--amber-light); border: 1px solid var(--amber-mid); color: var(--amber-deeper); }

/* ── Drop zone ─────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-md);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-align: center;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--amber);
  background: var(--amber-light);
}
.drop-icon { font-size: 26px; color: var(--amber); }
.drop-title { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.drop-sub   { font-size: 11px; color: var(--text-muted); }
.drop-zone img {
  max-height: 180px;
  max-width: 100%;
  border-radius: var(--radius-md);
  object-fit: cover;
}

/* ── Video preview ─────────────────────────────── */
.video-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  transition: border-color .2s;
}
.video-preview.active-gen { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245,166,35,.15); }
.preview-logo { width: 56px; height: 56px; object-fit: contain; opacity: .35; }
.preview-text { font-size: 13px; color: var(--text-muted); text-align: center; padding: 0 1.5rem; }
.preview-video { width: 100%; display: block; border-radius: var(--radius-md); }
.preview-actions { padding: 6px 0 2px; display: flex; gap: 7px; }

/* ── Progress ──────────────────────────────────── */
.progress-wrap { width: 75%; }
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-dark), var(--amber));
  border-radius: 3px;
  transition: width .5s ease;
}
.progress-label { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: center; }
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border-md);
  border-top: 2.5px solid var(--amber);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Caption ───────────────────────────────────── */
.caption-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.65;
  min-height: 54px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ── Tags ──────────────────────────────────────── */
.tags-box { display: flex; flex-wrap: wrap; gap: 5px; min-height: 26px; }
.tag {
  padding: 3px 10px;
  background: var(--amber-light);
  color: var(--amber-deeper);
  border: 1px solid var(--amber-mid);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.tags-empty { font-size: 12px; color: var(--text-muted); }

/* ── Gallery ───────────────────────────────────── */
.gallery-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.gallery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gallery-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  transition: border-color .2s, transform .15s;
}
.gallery-card:hover { border-color: var(--amber); transform: translateY(-1px); }
.gallery-card video {
  width: 100%;
  aspect-ratio: 9/16;
  object-fit: cover;
  display: block;
  background: var(--bg-secondary);
}
.card-meta { padding: 6px 8px; }
.card-prompt { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-date   { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 13px;
}
.gallery-empty i { font-size: 28px; display: block; margin-bottom: 8px; color: var(--amber-mid); }

/* ── Usage ─────────────────────────────────────── */
.generate-footer { display: flex; flex-direction: column; gap: 6px; margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--border); }
.usage-row { display: flex; align-items: center; justify-content: space-between; }
.usage-label { font-size: 12px; color: var(--text-secondary); }
.usage-bar-wrap { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.usage-bar-fill { height: 100%; background: linear-gradient(90deg, var(--amber-dark), var(--amber)); border-radius: 3px; transition: width .4s; }
.usage-note { font-size: 11px; color: var(--text-muted); }

/* ── Misc ──────────────────────────────────────── */
.divider { height: 1px; background: var(--border); flex-shrink: 0; }
.section  { display: flex; flex-direction: column; }
.post-note { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: center; line-height: 1.5; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; opacity: .6; }
  .progress-fill, .btn-primary { transition: none; }
}
