/* =========================================================================
   SmartSlides — style.css
   Design tokens live on :root. Change these to re-theme the whole app.
   ========================================================================= */

:root {
  /* -- Color: cool, quiet neutrals with two purposeful accents --
     Blue = the "pointer" color, used for primary actions and focus.
     Amber = the "live signal" color, used only for things that are
     actively listening/recording (camera on, mic on, flashes). */
  --color-bg: #F5F6F8;
  --color-surface: #FFFFFF;
  --color-ink: #1B1F27;
  --color-muted: #5B6472;
  --color-border: #E1E4EA;
  --color-accent: #3454D1;
  --color-accent-ink: #FFFFFF;
  --color-live: #E8590C;
  --color-live-soft: #FDECE3;
  --color-danger: #C4351D;

  /* -- Type -- */
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;

  /* -- Layout -- */
  --sidebar-width: 260px;
  --radius: 10px;
  --header-height: 56px;
  --status-height: 34px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-ink);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

button {
  font-family: var(--font-body);
}

/* ============================= HEADER ================================= */

#app-header {
  height: var(--header-height);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-live));
  display: inline-block;
}

/* ============================ BUTTONS ================================= */

.btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--color-bg); }
.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-ink);
}
.btn-primary:hover:not(:disabled) { background: #2c46b8; }

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.btn-ghost {
  background: transparent;
  border-color: var(--color-border);
}

.btn.is-live {
  background: var(--color-live-soft);
  border-color: var(--color-live);
  color: var(--color-live);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}

/* ============================= LAYOUT ================================== */

.app-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width);
  min-height: 0;
}

.sidebar {
  background: var(--color-surface);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-left { border-right: 1px solid var(--color-border); }
.sidebar-right { border-left: 1px solid var(--color-border); }

.panel {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}
.panel:last-child { border-bottom: none; }

.panel h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin: 0 0 8px;
}

.panel-hint {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin: 6px 0 0;
  line-height: 1.4;
}

.panel label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 8px;
}

/* -------- Upload zone -------- */

.upload-zone {
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  color: var(--color-muted);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: var(--color-accent);
  background: #F0F3FF;
  outline: none;
}
.upload-zone.drag-over {
  border-color: var(--color-accent);
  background: #E9EEFF;
}
.upload-icon {
  width: 26px;
  height: 26px;
  color: var(--color-accent);
  margin-bottom: 6px;
}
.upload-zone p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* -------- Thumbnails -------- */

.thumbnail-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.thumbnail {
  position: relative;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  display: block;
  width: 100%;
}
.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  display: block;
}
.thumbnail span {
  position: absolute;
  bottom: 4px;
  right: 6px;
  background: rgba(27, 31, 39, 0.72);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 999px;
}
.thumbnail.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(52, 84, 209, 0.25);
}
.thumbnail:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ============================ VIEWER =================================== */

.viewer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  gap: 12px;
}

.slide-container {
  position: relative;
  flex: 1 1 auto;
  background: #1B1F27;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.zoom-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease-out;
  transform-origin: center center;
}

#slide-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #A7ADB8;
  text-align: center;
  padding: 20px;
}
.empty-state p {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0;
  color: #E5E7EB;
}
.empty-state span { font-size: 0.85rem; }

.zoom-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(27, 31, 39, 0.75);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
}

.gesture-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  color: #fff;
  background: rgba(52, 84, 209, 0.85);
  padding: 10px 22px;
  border-radius: 999px;
  pointer-events: none;
}
.gesture-flash.flash-anim {
  animation: flash-pop 0.55s ease-out;
}
.gesture-flash.flash-snap { background: rgba(232, 89, 12, 0.88); }
.gesture-flash.flash-zoom { background: rgba(52, 84, 209, 0.88); }

@keyframes flash-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

.viewer-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.slide-counter {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--color-muted);
  min-width: 64px;
  text-align: center;
}

/* --------- Fullscreen presentation mode --------- */
body.presentation-mode #app-header,
body.presentation-mode .sidebar-left,
body.presentation-mode .sidebar-right,
body.presentation-mode #status-bar,
body.presentation-mode .viewer-toolbar {
  display: none !important;
}
body.presentation-mode .app-layout {
  grid-template-columns: 1fr;
}
body.presentation-mode .viewer {
  padding: 0;
}
body.presentation-mode .slide-container {
  border-radius: 0;
}

/* ========================== RIGHT-SIDE PANELS =========================== */

.token-row, .ask-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.token-row input,
.ask-row input,
#question-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-family: var(--font-body);
}
.token-row input:focus,
.ask-row input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.ai-output {
  margin-top: 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.82rem;
  line-height: 1.5;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  min-height: 20px;
}
.ai-output:empty { display: none; }

.webcam-wrap {
  position: relative;
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  background: #10131A;
  aspect-ratio: 4 / 3;
}
#webcam-video, #gesture-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#gesture-canvas { pointer-events: none; }

/* ============================ STATUS BAR ================================ */

#status-bar {
  height: var(--status-height);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--color-ink);
  color: #C9CDD6;
  font-size: 0.72rem;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}
#status-bar span::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #545B69;
  margin-right: 6px;
  vertical-align: middle;
}
#status-voice.on::before,
#status-gesture.on::before { background: var(--color-live); }
#status-tts.on::before { background: var(--color-accent); }
#status-last-command { color: #8B93A3; margin-left: auto; }

/* ============================ RESPONSIVE ================================ */

@media (max-width: 1080px) {
  :root { --sidebar-width: 220px; }
}

@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }
  .sidebar-left, .sidebar-right {
    border: none;
    border-top: 1px solid var(--color-border);
    max-height: 260px;
  }
  .thumbnail-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .thumbnail { flex: 0 0 100px; }
  .viewer { order: -1; min-height: 50vh; }
  #status-bar {
    flex-wrap: wrap;
    height: auto;
    padding: 6px 20px;
    gap: 8px 20px;
  }
  #status-last-command { margin-left: 0; }
}
