/* === Kiosk Design System === */
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@100;200;300&display=swap');

/* Theme: Moderno (default — dark blue/purple) */
:root,
[data-theme="moderno"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --bg-overlay: rgba(0, 0, 0, 0.85);
  --text-primary: #e4e4e4;
  --text-secondary: #a0a0b0;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --success: #2ecc71;
  --error: #e74c3c;
  --warning: #f39c12;
  --border: #2a2a4a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
  --touch-min: 44px;
  --header-height: 48px;
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Theme: Casio — retro LCD verde sobre preto */
[data-theme="casio"] {
  --bg-primary: #0a0e0a;
  --bg-secondary: #0d120d;
  --bg-card: #111811;
  --bg-overlay: rgba(0, 8, 0, 0.92);
  --text-primary: #00e000;
  --text-secondary: #00880a;
  --accent: #00ff44;
  --accent-hover: #44ff88;
  --success: #00ff44;
  --error: #ff4400;
  --warning: #ffcc00;
  --border: #004400;
  --radius: 4px;
  --radius-sm: 2px;
  --shadow: 0 0 8px rgba(0, 200, 0, 0.2);
  --font-display: "Courier New", "Lucida Console", monospace;
  --font-mono: "Courier New", "Lucida Console", monospace;
}

/* Theme: Citizen — relógio de pulso elegante, prata/escuro */
[data-theme="citizen"] {
  --bg-primary: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --bg-card: #3a3a3c;
  --bg-overlay: rgba(0, 0, 0, 0.9);
  --text-primary: #f5f5f0;
  --text-secondary: #aeaeb2;
  --accent: #c9a84c;
  --accent-hover: #e8c76a;
  --success: #30d158;
  --error: #ff453a;
  --warning: #ffd60a;
  --border: #48484a;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 1px rgba(201,168,76,0.3);
  --font-display: "Georgia", "Times New Roman", serif;
  --font-mono: "Georgia", "Times New Roman", serif;
}

/* Theme: Infantil — cores vivas, formas arredondadas, divertido */
[data-theme="infantil"] {
  --bg-primary: #fff9e6;
  --bg-secondary: #ffe066;
  --bg-card: #ffcce0;
  --bg-overlay: rgba(255, 140, 0, 0.88);
  --text-primary: #2d1a00;
  --text-secondary: #7a4400;
  --accent: #ff4da6;
  --accent-hover: #ff80c0;
  --success: #2dcc44;
  --error: #ff3333;
  --warning: #ff9900;
  --border: #ffb347;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 4px 12px rgba(255, 100, 0, 0.2);
  --font-display: "Comic Sans MS", "Chalkboard SE", cursive;
  --font-mono: "Comic Sans MS", "Chalkboard SE", cursive;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-display, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  user-select: none;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Theme-aware clock font */
.fullscreen-clock .clock-time,
.rest-clock {
  font-family: var(--font-mono, inherit);
}

/* Fullscreen: preencher atrás das barras do sistema */
:fullscreen {
  background: #000;
}

/* Quando #kiosk-app é o elemento fullscreen, garantir que ocupa tudo */
#kiosk-app:fullscreen,
#kiosk-app:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
}

::backdrop {
  background: #000;
}

/* === App Shell === */
#kiosk-app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* === Header === */
#kiosk-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
}

.header-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.header-btn:active {
  background: var(--border);
}

/* === Panel Indicators (dots) === */
#panel-indicators {
  display: flex;
  gap: 8px;
  align-items: center;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background var(--transition), transform var(--transition);
}

.indicator-dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

/* === Panels Container === */
#panels-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#panels-track {
  display: flex;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.panel {
  flex: 0 0 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Every widget fills the full panel — one at a time */
.panel .widget {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

/* === Widget Base === */
.widget {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition);
}

.widget:active {
  transform: scale(0.97);
}

.widget.fullscreen-clock:active {
  transform: none;
}

/* === Widget: Clock === */
.widget-clock .clock-time {
  font-size: 2.5rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}

/* === Widget: Fullscreen Clock (Rádio-Relógio) === */
.widget-clock.fullscreen-clock {
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.fullscreen-clock .clock-time {
  font-family: 'Raleway', -apple-system, sans-serif;
  font-weight: 100;
  color: #ffffff;
  text-shadow: 0 0 60px rgba(255, 255, 255, 0.12);
  letter-spacing: 0.06em;
  line-height: 1;
}

.fullscreen-clock .clock-date {
  font-family: 'Raleway', -apple-system, sans-serif;
  font-weight: 200;
  color: var(--text-secondary);
  text-transform: capitalize;
  letter-spacing: 0.2em;
  opacity: 0.75;
}

/* Portrait: altura sobra, largura é o limitante */
@media (orientation: portrait) {
  .fullscreen-clock .clock-time {
    font-size: clamp(3rem, 20vw, 14rem);
  }
  .fullscreen-clock .clock-date {
    font-size: clamp(0.9rem, 4vw, 1.8rem);
  }
}

/* Landscape: largura sobra, altura é o limitante — usar vh */
@media (orientation: landscape) {
  .fullscreen-clock .clock-time {
    font-size: clamp(3rem, 28vh, 20rem);
  }
  .fullscreen-clock .clock-date {
    font-size: clamp(0.8rem, 4vh, 2rem);
  }
}

/* Esconder header completamente quando fullscreen-clock está ativo */
.fullscreen-clock-active #kiosk-header {
  display: none !important;
}

.fullscreen-clock-active #kiosk-app {
  background: #000;
}

.fullscreen-clock-active #panels-container {
  height: 100vh;
  height: 100dvh;
}

.fullscreen-clock-active .panel {
  background: #000;
}

/* === Widget: Webhook Button === */
.widget-webhook-button {
  cursor: pointer;
}

.widget-webhook-button .btn-label {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

.widget-webhook-button.state-loading {
  opacity: 0.7;
}

.widget-webhook-button.state-success {
  border: 2px solid var(--success);
}

.widget-webhook-button.state-error {
  border: 2px solid var(--error);
}

/* === Widget: YouNews === */
.widget-younews {
  grid-column: span 2;
  min-height: 200px;
  padding: 12px;
  align-items: stretch;
}

.news-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.news-item:last-child {
  border-bottom: none;
}

.news-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.news-text {
  flex: 1;
  min-width: 0;
}

.news-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* === Widget: Grafana embed === */
.widget-grafana {
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #1a1a2e;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.grafana-iframe {
  width: 100%;
  flex: 1;
  min-height: 200px;
  border: none;
  display: block;
}

/* === Widget: YouTube Radio (fullscreen) === */
.widget-youtube-radio {
  background: #000 !important;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.yt-player-container {
  width: 100%;
  height: 100%;
}

.yt-player-container iframe {
  width: 100% !important;
  height: 100% !important;
  border: none;
  display: block;
}

.yt-title-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  pointer-events: none;
}

.yt-error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #0a0a0a;
  color: #e4e4e4;
  padding: 2rem;
  text-align: center;
}

.yt-error-icon { font-size: 3rem; }

.yt-error-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #ff6b6b;
}

.yt-error-msg {
  font-size: 1rem;
  opacity: 0.85;
}

.yt-error-url {
  font-size: 0.8rem;
  opacity: 0.5;
  font-family: monospace;
  word-break: break-all;
  max-width: 600px;
}

/* === Widget: YouNews Carousel (fullscreen) === */
.widget-younews-carousel {
  background: #000 !important;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  gap: 0;
  overflow: hidden;
  position: relative;
  container-type: size;
}

/* === Rest overlay (relógio entre carrosséis) === */
.carousel-rest-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  z-index: 10;
}

.rest-clock {
  font-size: clamp(3rem, 18cqw, 10rem);
  font-weight: 100;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1;
  text-align: center;
  width: 100%;
}

.rest-indicators {
  display: flex;
  align-items: center;
  gap: 2rem;
  font-size: clamp(1.1rem, 4vw, 2rem);
  color: var(--text-secondary);
  flex-wrap: wrap;
  justify-content: center;
}

.rest-weather-el,
.rest-dollar-el {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
}

/* Herdados do status bar mas precisam ser maiores no rest */
.rest-weather-el .ch-temp,
.rest-dollar-el .ch-usd-rate {
  font-size: 1em;
  color: var(--text-primary);
}

.rest-weather-el .ch-city,
.rest-weather-el .ch-hum,
.rest-weather-el .ch-aqi,
.rest-dollar-el .ch-usd-label {
  font-size: 0.85em;
}

@media (orientation: landscape) {
  .rest-clock {
    font-size: clamp(3rem, 28cqh, 10rem);
  }
}

/* Status bar: clock + weather + dollar */
.carousel-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  gap: 12px;
}

.ch-sep {
  color: rgba(255, 255, 255, 0.2);
  font-size: 1rem;
  margin: 0 4px;
}

.ch-clock {
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.ch-weather {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(0.7rem, 1.8vw, 0.95rem);
  color: var(--text-secondary);
}
.ch-city  { color: var(--text-secondary); opacity: 0.75; font-size: 0.9em; }
.ch-temp  { color: var(--text-primary); font-weight: 600; }
.ch-hum   { opacity: 0.8; }
.ch-aqi   { font-weight: 600; font-size: 0.85em; }

.ch-dollar {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: clamp(0.7rem, 1.8vw, 0.95rem);
  color: var(--text-secondary);
}
.ch-usd-label { opacity: 0.6; font-size: 0.85em; text-transform: uppercase; }
.ch-usd-rate  { color: var(--text-primary); font-weight: 700; font-variant-numeric: tabular-nums; }

.carousel-slide {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
  text-align: center;
  width: 100%;
  overflow: hidden;
}

/* Portrait: DOM order is image→desc→title; reorder to image→title→desc */
.carousel-title { order: 1; }
.carousel-desc  { order: 2; }

/* === Calendar slide === */
.carousel-slide.calendar-slide {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 24px 32px;
  background: rgba(15, 20, 40, 0.6);
}

.calendar-slide-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 600px;
}

.calendar-slide-header {
  font-size: clamp(1rem, 3vw, 1.5rem);
  color: var(--text-secondary);
  text-transform: capitalize;
  letter-spacing: 0.1em;
}

.calendar-slide-icon {
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 1;
}

.calendar-events-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.calendar-event-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 8px 16px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.calendar-event-time {
  font-size: clamp(0.75rem, 2vw, 1rem);
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.calendar-event-title {
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  color: var(--text-primary);
}

.calendar-slide-empty {
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: var(--text-secondary);
  font-style: italic;
}

.carousel-image {
  max-width: 80%;
  max-height: 45vh;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

@media (orientation: landscape) {
  .carousel-slide {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: center;
    text-align: left;
    padding: 20px 40px;
    gap: 6px 24px;
  }
  .carousel-image {
    flex: 0 0 auto;
    max-width: 35%;
    max-height: 55vh;
  }
  /* Landscape: image(DOM 1st)→desc(DOM 2nd, beside image)→title(DOM 3rd, full-width below) */
  .carousel-desc {
    order: 0;
    flex: 1 1 0;
    align-self: center;
    font-size: clamp(0.75rem, 1.8vw, 1rem);
    -webkit-line-clamp: 6;
  }
  .carousel-title {
    order: 1;
    flex: 0 0 100%;
    font-size: clamp(1rem, 2.8vw, 1.8rem);
    -webkit-line-clamp: 3;
  }
}

.carousel-title {
  font-size: clamp(1.2rem, 4vw, 2.2rem);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.carousel-desc {
  font-size: clamp(0.85rem, 2.5vw, 1.2rem);
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.carousel-counter {
  padding: 8px 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  text-align: center;
  opacity: 0.6;
}

.carousel-progress {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.carousel-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
}

/* === Widget: Custom HTML === */
.widget-custom-html iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius-sm);
}

/* === FAB Settings Button (always visible) === */
#btn-fab-settings {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s, background 0.2s;
  opacity: 0.4;
  -webkit-tap-highlight-color: transparent;
}

#btn-fab-settings:active {
  background: rgba(255, 255, 255, 0.2);
  opacity: 1;
}

/* === Widget blocker (non-interactive mode) === */
.widget-blocker {
  position: absolute;
  inset: 0;
  z-index: 10;
  cursor: pointer;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

/* === Kiosk Nav Overlay (shown when non-interactive widget is tapped) === */
.kiosk-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity 0.2s ease;
  opacity: 1;
}

.kiosk-nav-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.nav-btn-large {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.85);
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.nav-btn-large:active {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}
.nav-btn-widget {
}
.nav-btn-overlay-settings {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-btn-overlay-settings:active {
  background: rgba(255, 255, 255, 0.25);
}

/* === CodeMirror 6 editor === */
.cm-editor-mount {
  width: 100%;
  font-size: 0.85rem;
}

.cm-editor-mount .cm-editor {
  height: 100%;
}

.cm-editor-mount .cm-scroller {
  overflow: auto;
  font-family: 'Fira Code', 'Consolas', monospace;
}

.cm-fallback-textarea {
  width: 100%;
  height: 300px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  resize: vertical;
  tab-size: 2;
  box-sizing: border-box;
}

/* === Overlay (Settings — VS Code layout) === */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 100;
  transition: opacity 0.2s ease;
  opacity: 1;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  position: absolute;
  inset: 0;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: row;
}

/* === Activity Bar (left icon strip) === */
.settings-activitybar {
  width: 48px;
  flex-shrink: 0;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 2px;
  overflow: hidden;
}

.nav-icon {
  width: 44px;
  height: 44px;
  border: none;
  border-left: 2px solid transparent;
  background: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.nav-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.nav-icon.active {
  color: var(--text-primary);
  border-left-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
}

.nav-close {
  font-size: 1rem;
  color: var(--text-secondary);
}

.nav-spacer {
  flex: 1;
}

.version-badge-side {
  font-size: 0.6rem;
  color: var(--text-secondary);
  opacity: 0.55;
  text-align: center;
  line-height: 1.3;
  padding: 2px 0;
  user-select: none;
  word-break: break-all;
}

/* === Settings Main Content === */
.settings-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  height: 100%;
}

input::placeholder {
  color: var(--text-muted, #555);
  opacity: 1;
}

.panel-name-input {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.panel-editor-back {
  padding-bottom: 0;
}

.version-badge {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
  vertical-align: middle;
  margin-left: 6px;
}

/* === Settings === */
.settings-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.panel-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  min-height: var(--touch-min);
}

.panel-list-item .panel-name {
  font-size: 0.9rem;
}

.panel-drag-handle {
  cursor: grab;
  color: var(--text-secondary);
  font-size: 1.1rem;
  padding-right: 8px;
  user-select: none;
}

.panel-list-item.dragging {
  opacity: 0.4;
}

.panel-list-item.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.btn-action {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  transition: background var(--transition);
}

.btn-action:active {
  background: var(--accent-hover);
}

.btn-action.btn-small {
  min-width: 32px;
  min-height: 32px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.btn-action.btn-danger {
  background: var(--error);
}

/* === Utilities === */
.hidden {
  display: none !important;
}

.offline-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--warning);
  color: #000;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* === Empty State === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  text-align: center;
  padding: 32px;
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 16px;
}

/* === Theme Switcher === */
.theme-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.theme-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.theme-btn:active {
  transform: scale(0.9);
}

.theme-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-hover);
}

.theme-btn[data-theme="moderno"]  { background: #1a1a2e; }
.theme-btn[data-theme="casio"]    { background: #0a0e0a; color: #00e000; }
.theme-btn[data-theme="citizen"]  { background: #2c2c2e; }
.theme-btn[data-theme="infantil"] { background: #ffe066; }

/* === Widget: Radio Stream === */
.widget-radio-stream {
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 140px;
  padding: 16px;
  position: relative;
}

.radio-stream-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.radio-stream-name {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
}

.radio-stream-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.radio-stream-controls audio {
  flex: 1;
  min-width: 0;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  /* Chromium audio player inherits some accent */
  accent-color: var(--accent);
}

.radio-stream-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.radio-stream-status.playing {
  color: var(--success);
}

.radio-stream-status.error {
  color: var(--error);
}

/* === Start Overlay (autoplay gate — first session load) === */
#start-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.5s ease;
}
#start-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}
.start-prompt {
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  font-family: 'Raleway', sans-serif;
  font-weight: 300;
  animation: start-pulse 2.5s ease-in-out infinite;
}
@keyframes start-pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1; }
}

/* === Widget: Alert === */
.widget-alert {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  color: #fff;
  transition: background 0.4s ease;
}
.alert-countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.alert-timer {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: clamp(3rem, 12vw, 10rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #e0e0e0;
}
.alert-message {
  font-size: clamp(1rem, 3vw, 2rem);
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  max-width: 80%;
}
.alert-triggered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
}
.alert-triggered-message {
  font-size: clamp(2rem, 6vw, 5rem);
  font-weight: 800;
  text-transform: uppercase;
  text-align: center;
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
  max-width: 90%;
}
.alert-dismiss {
  padding: 0.8rem 2.5rem;
  font-size: 1.2rem;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}
.alert-dismiss:hover {
  background: rgba(255, 255, 255, 0.3);
}
.widget-alert.alert-active {
  animation: alert-pulse 1s ease-in-out infinite;
}
@keyframes alert-pulse {
  0%, 100% { background: #d32f2f; }
  50%      { background: #ff6f00; }
}

/* === Pulse Indicator (corner badge) === */
.pulse-badge {
  position: fixed;
  bottom: 68px;
  left: 16px;
  font-size: 0.65rem;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  z-index: 50;
  opacity: 0.7;
  pointer-events: none;
}
