/* ============================================================
   CICLO DO SONO — Estilos
   ============================================================ */

/* ===== VARIÁVEIS ===== */
:root {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --optimal: #10b981;
  --radius: 12px;
  --transition: 0.3s ease;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

/* ===== RESET ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* ===== BASE ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  line-height: 1.5;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.5); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== SKIP LINK ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  z-index: 1000;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; }

/* ===== FOCO ACESSÍVEL ===== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ===== CONTAINER ===== */
.app-container {
  width: 100%;
  max-width: 500px;
  background-color: var(--card-bg);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

/* ===== CABEÇALHO ===== */
header {
  text-align: center;
  margin-bottom: 2rem;
}

.app-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.75rem;
  display: block;
  filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.65));
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

header > p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* ===== INTRO ===== */
.intro-text {
  background-color: rgba(139, 92, 246, 0.1);
  border-left: 4px solid var(--primary);
  padding: 1rem;
  border-radius: 4px 8px 8px 4px;
  margin-bottom: 2rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ===== ABAS ===== */
.tabs {
  display: flex;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 1.5rem;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 0.85rem 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover { color: var(--text-main); }

.tab-btn.active {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

/* ===== PAINÉIS ===== */
.panel {
  display: none;
  animation: fadeIn 0.35s ease forwards;
}
.panel.active { display: block; }

.panel-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.55;
  text-align: center;
}

/* ===== INPUT ===== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.input-group label {
  font-size: 0.95rem;
  font-weight: 500;
}

input[type="time"] {
  width: 100%;
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 1.2rem;
  outline: none;
  transition: var(--transition);
  color-scheme: dark;
}

input[type="time"]:focus {
  border-color: var(--primary);
  background-color: rgba(255, 255, 255, 0.1);
}

/* ===== BOTÃO PRINCIPAL ===== */
.btn-action {
  width: 100%;
  padding: 1rem;
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-action:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

.btn-action:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ===== RESULTADOS ===== */
.results-container {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: none;
}

.results-container.visible {
  display: block;
  animation: fadeIn 0.4s ease forwards;
}

.results-container h2 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.results-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ===== LISTA DE HORÁRIOS ===== */
.times-list {
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.time-card {
  background-color: rgba(0, 0, 0, 0.2);
  padding: 1.1rem 1.2rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 4px solid transparent;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease;
  user-select: none;
}

.time-card:hover {
  background-color: rgba(0, 0, 0, 0.35);
  transform: translateX(3px);
}

.time-card:active { transform: translateX(1px); }

.time-card.optimal {
  border-left-color: var(--optimal);
  background-color: rgba(16, 185, 129, 0.08);
}

.time-card.optimal:hover { background-color: rgba(16, 185, 129, 0.14); }

.time-card-left {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.time-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.time-card.optimal .time-value { color: var(--optimal); }

.time-badge {
  display: inline-block;
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--optimal);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.copy-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.time-card:hover .copy-hint { opacity: 1; }

.time-info { text-align: right; }

.cycle-count {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.hours-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== NOTA INFORMATIVA ===== */
.info-note {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  background-color: rgba(255, 255, 255, 0.03);
  padding: 0.9rem;
  border-radius: 8px;
  line-height: 1.55;
}

/* ===== RODAPÉ ===== */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ===== BOTÃO DE INSTALAÇÃO ===== */
.btn-install {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  background-color: rgba(139, 92, 246, 0.1);
  color: var(--primary);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-install:hover {
  background-color: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.5);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background-color: #2d3748;
  color: var(--text-main);
  padding: 0.7rem 1.4rem;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== ANIMAÇÕES ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== MOVIMENTO REDUZIDO ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ===== RESPONSIVO ===== */
@media (max-width: 400px) {
  .app-container { padding: 1.5rem 1.2rem; }
  h1 { font-size: 1.55rem; }
  .time-value { font-size: 1.3rem; }
  .tab-btn { font-size: 0.82rem; padding: 0.75rem 0.35rem; }
}

/* ===== IMPRESSÃO ===== */
@media print {
  body { background: #fff; color: #000; }
  .skip-link, .tabs, .btn-action, .btn-install, .toast, .copy-hint { display: none !important; }
  .app-container { box-shadow: none; border: 1px solid #ddd; padding: 1rem; }
  footer { display: none; }
}

/* ============================================================
   PÁGINA DE TERMOS DE USO
   ============================================================ */
.terms-container { max-width: 620px; }

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}
.back-link:hover { color: var(--primary-hover); }

.terms-date { font-size: 0.85rem; }

.terms-content {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.terms-section h2 {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.7rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.terms-section p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 0.6rem;
}

.terms-section p:last-child { margin-bottom: 0; }

.terms-section ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.terms-section li {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 0.3rem;
}

.terms-section strong {
  color: var(--text-main);
  font-weight: 600;
}

.terms-section a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.terms-section a:hover { text-decoration: underline; }
