/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --aws-orange:       #FF9900;
  --aws-orange-hover: #e68900;
  --sidebar-bg:       #0d1b2e;
  --header-bg:        #0d1b2e;
  --sidebar-active-bg:     rgba(255, 153, 0, 0.13);
  --sidebar-active-border: #FF9900;
  --content-bg:  #ffffff;
  --footer-bg:   #f2f3f3;
  --text-dark:   #232f3e;
  --text-muted:  #687078;
  --text-light:  #f0f0f0;
  --border:      #d5dbdb;
  --header-h:    52px;
  --footer-h:    36px;
  --sidebar-w:   90px;
  --radius:      8px;
}

html, body {
  height: 100%;
  font-family: 'Amazon Ember', 'Helvetica Neue', Arial, sans-serif;
  background: var(--content-bg);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ──────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}

.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.aws-logo-svg { height: 30px; width: auto; }

.header-title {
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

.header-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.2s;
  z-index: 1;
}
.header-btn:hover { background: rgba(255, 255, 255, 0.12); }
.header-btn svg   { width: 18px; height: 18px; }
.info-btn svg     { width: 20px; height: 20px; }

/* ── App body ───────────────────────────────────────────────────────────────── */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - var(--header-h) - var(--footer-h));
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding-top: 10px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 6px;
  cursor: pointer;
  border-left: 3px solid transparent;
  color: rgba(255, 255, 255, 0.6);
  transition: all 0.2s;
  user-select: none;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
  color: var(--aws-orange);
}

.nav-icon { margin-bottom: 5px; }
.nav-icon svg { width: 24px; height: 24px; }
.nav-label { font-size: 10px; text-align: center; line-height: 1.35; }

/* ── Main content ───────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  background: var(--content-bg);
  padding: 18px 16px 24px;
}

.section        { display: none; }
.section.active { display: block; }

.hidden { display: none !important; }

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 12px;
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-align: center;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.app-footer {
  height: var(--footer-h);
  background: var(--footer-bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  padding: 0 16px;
}
.app-footer a { color: var(--text-muted); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* ── Character selection ────────────────────────────────────────────────────── */
.character-bar    { margin-bottom: 14px; }
.character-title  { font-size: 15px; font-weight: 600; text-align: center; margin-bottom: 12px; }

.character-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.placeholder-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
  line-height: 1.7;
}
.placeholder-hint code {
  background: #f0f4f8;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.character-item {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid #d0d0d0;
  transition: border-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  background: #e8e8e8;
}
.character-item:hover   { border-color: var(--aws-orange); }
.character-item.selected {
  border-color: var(--aws-orange);
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.35);
}
.character-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Camera ─────────────────────────────────────────────────────────────────── */
.camera-wrapper { width: 100%; margin-bottom: 8px; }

.camera-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: #111827;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.camera-frame video,
.camera-frame canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.camera-frame canvas {
  position: absolute;
  top: 0; left: 0;
}

/* Corner brackets */
.cam-corners { position: absolute; inset: 0; pointer-events: none; }
.corner {
  position: absolute;
  width: 20px; height: 20px;
  border-color: rgba(255, 255, 255, 0.8);
  border-style: solid;
}
.corner.tl { top: 8px; left: 8px;   border-width: 2px 0 0 2px; border-radius: 2px 0 0 0; }
.corner.tr { top: 8px; right: 8px;  border-width: 2px 2px 0 0; border-radius: 0 2px 0 0; }
.corner.bl { bottom: 8px; left: 8px;  border-width: 0 0 2px 2px; border-radius: 0 0 0 2px; }
.corner.br { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; border-radius: 0 0 2px 0; }

/* Loading spinner overlay */
.cam-spinner {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--aws-orange);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cam-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ── Capture button ─────────────────────────────────────────────────────────── */
.capture-controls {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.capture-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--aws-orange);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 11px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.capture-btn:hover    { background: var(--aws-orange-hover); transform: scale(1.02); }
.capture-btn:disabled { background: #aaa; cursor: not-allowed; transform: none; }
.capture-btn svg { width: 20px; height: 20px; }

/* ── Photo result ───────────────────────────────────────────────────────────── */
.result-split {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.result-main { flex: 2; min-width: 0; }
.result-side { flex: 1;  min-width: 0; }

.result-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.result-img-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  background: #f5f5f5;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.result-img-wrap img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.result-caption {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Action buttons ─────────────────────────────────────────────────────────── */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--aws-orange);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}
.action-btn:hover    { background: var(--aws-orange-hover); }
.secondary-btn       { background: #e8eaed; color: var(--text-dark); }
.secondary-btn:hover { background: #d0d3d8; }

/* ── Video section ──────────────────────────────────────────────────────────── */
.video-frame {
  aspect-ratio: 3 / 4;
  max-width: 360px;
}

/* Grid overlay (camera guide lines) */
.grid-overlay { position: absolute; inset: 0; pointer-events: none; }
.grid-line    { position: absolute; background: rgba(255, 255, 255, 0.2); }
.grid-line.h1 { top: 33.33%; left: 0; right: 0; height: 1px; }
.grid-line.h2 { top: 66.66%; left: 0; right: 0; height: 1px; }
.grid-line.v1 { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.grid-line.v2 { left: 66.66%; top: 0; bottom: 0; width: 1px; }

/* Record controls */
.record-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-top: 18px;
}

.timer-display {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-dark);
  font-variant-numeric: tabular-nums;
  min-width: 54px;
  text-align: center;
}

.record-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #c8c8c8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: border-color 0.2s, transform 0.1s;
}
.record-btn:hover        { border-color: #e74c3c; transform: scale(1.06); }
.record-btn.recording    { border-color: #e74c3c; }
.record-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e74c3c;
  transition: border-radius 0.3s;
}
.record-btn.recording .record-dot { border-radius: 5px; }

.record-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 7px;
}

.recorded-wrap { margin-top: 18px; }
.recorded-wrap h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
#recordedVideo {
  width: 100%;
  max-width: 360px;
  display: block;
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.download-btn { font-size: 13px; padding: 8px 16px; }

/* ── Fake or Real quiz ──────────────────────────────────────────────────────── */
.image-quiz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.quiz-img-card {
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s, transform 0.12s;
  background: #f0f0f0;
  aspect-ratio: 3 / 4;
  position: relative;
}
.quiz-img-card:hover { transform: scale(1.03); border-color: var(--aws-orange); }
.quiz-img-card img   { width: 100%; height: 100%; object-fit: cover; display: block; }

.quiz-img-card.correct { border-color: #27ae60; }
.quiz-img-card.wrong   { border-color: #e74c3c; }

.img-result-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  display: none;
}
.quiz-img-card.correct .img-result-badge,
.quiz-img-card.wrong   .img-result-badge { display: block; }

.quiz-feedback {
  text-align: center;
  padding: 14px 8px;
}
.quiz-feedback p {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

.demo-msg {
  background: #f0f4f8;
  border-radius: var(--radius);
  padding: 18px;
  font-size: 13px;
  line-height: 2;
  color: var(--text-muted);
  margin-top: 8px;
}
.demo-msg p    { font-size: 14px; margin-bottom: 6px; }
.demo-msg code {
  display: inline-block;
  background: #dde6f0;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
}

/* ── Video Deepfake processing state ─────────────────────────────────────────── */
.videodf-processing-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 24px;
}
.videodf-processing-box .spinner {
  width: 52px;
  height: 52px;
}
.videodf-processing-msg {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
  line-height: 1.6;
}
.videodf-processing-msg span {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Toast notification ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: #232f3e;
  color: #fff;
  padding: 9px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; }

/* ── Info modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.modal-box h2 { font-size: 18px; margin-bottom: 10px; }
.modal-box p  { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5; }
.modal-box ul { padding-left: 18px; margin-bottom: 12px; }
.modal-box li { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; line-height: 1.5; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.modal-close:hover { color: var(--text-dark); }

.modal-warning {
  font-size: 12px !important;
  color: #c0392b !important;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 8px;
  margin-bottom: 0 !important;
}

/* ── Responsive tweaks ──────────────────────────────────────────────────────── */
@media (max-width: 420px) {
  :root { --sidebar-w: 72px; }
  .nav-label { font-size: 9px; }
  .header-title { font-size: 13px; }
  .result-split { flex-direction: column; }
  .result-main, .result-side { flex: none; width: 100%; }
}
