/* ============================================================
   Tokens
   ============================================================ */
:root {
  --bg: #0b1120;
  --bg-elevated: #131c30;
  --bg-elevated-2: #1a2540;
  --line: #263252;
  --line-soft: #1c2740;

  --ink: #e7ecfb;
  --ink-dim: #8b96b8;
  --ink-faint: #5b6684;

  --posso: #4ade9a;
  --posso-dim: rgba(74, 222, 154, 0.16);
  --posso-ink: #06231a;

  --naoposso: #ff6b6b;
  --naoposso-dim: rgba(255, 107, 107, 0.16);

  --pending: #ffb648;
  --pending-ink: #2a1a02;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(74, 222, 154, 0.07), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(255, 107, 107, 0.06), transparent 40%);
  color: var(--ink);
  min-height: 100vh;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  padding-bottom: 60px;
}

h1, h2, h3 {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: -0.02em;
  margin: 0;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 32px;
}
.topbar-brand {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--posso);
  letter-spacing: -0.01em;
}

/* ============================================================
   Wrap containers
   ============================================================ */
.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}
.wrap-narrow { max-width: 520px; }

/* ============================================================
   Cards / glass panels
   ============================================================ */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.card-title-icon { font-size: 16px; }
.badge-count {
  margin-left: auto;
  background: var(--bg-elevated-2);
  color: var(--ink-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================
   Home / hero
   ============================================================ */
.hero {
  margin: 24px 0 28px;
}
.hero h1 {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.15;
}
.hero p {
  color: var(--ink-dim);
  font-size: 15px;
  margin-top: 12px;
}

/* ============================================================
   Form inputs
   ============================================================ */
label {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 6px;
  margin-top: 18px;
  font-weight: 500;
}
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="date"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, input[type="date"]:focus {
  border-color: var(--posso);
  box-shadow: 0 0 0 3px var(--posso-dim);
}
input::placeholder { color: var(--ink-faint); }

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  cursor: pointer;
  transition: transform .1s, opacity .15s, background .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--posso); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-block { width: 100%; }

.btn-primary {
  background: var(--posso);
  color: var(--posso-ink);
}
.btn-primary:hover:not(:disabled) { background: #5eeaad; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-faint); }

.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-pill {
  background: var(--bg-elevated-2);
  color: var(--ink);
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  padding: 10px 16px;
}
.btn-pill:hover { border-color: var(--posso); color: var(--posso); }

.btn-link {
  background: none;
  color: var(--posso);
  padding: 6px 4px;
  font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link-muted { color: var(--ink-dim); }
.btn-link-muted:hover { color: var(--naoposso); }

/* ============================================================
   Cabeçalho do evento
   ============================================================ */
.event-header {
  text-align: center;
  margin: 8px 0 28px;
}
.event-header h1 {
  font-size: 32px;
  font-weight: 800;
}
.event-range {
  color: var(--ink-dim);
  font-size: 15px;
  margin: 8px 0 18px;
}

/* ============================================================
   Identidade
   ============================================================ */
.identity-bar { max-width: 640px; margin: 0 auto 24px; }
.identity-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.identity-row input { flex: 1; min-width: 200px; }

.me-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-dim);
  flex: 1;
}
.me-badge strong { color: var(--ink); }

.avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--posso-dim);
  color: var(--posso);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ============================================================
   Layout de 2 colunas
   ============================================================ */
.role-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
@media (min-width: 920px) {
  .role-layout {
    grid-template-columns: 1.5fr 0.85fr;
    gap: 28px;
  }
  .col-side {
    position: sticky;
    top: 24px;
  }
}

/* ============================================================
   Toggle grande POSSO / NÃO POSSO
   ============================================================ */
.mode-toggle-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}
.mode-toggle {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 460px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px;
}
.mode-toggle-thumb {
  position: absolute;
  top: 5px;
  left: 5px;
  width: calc(50% - 5px);
  height: calc(100% - 10px);
  background: var(--posso);
  border-radius: 999px;
  transition: transform .25s cubic-bezier(.4,0,.2,1), background .25s;
  z-index: 0;
}
.mode-toggle.mode-naoposso .mode-toggle-thumb {
  transform: translateX(100%);
  background: var(--naoposso);
}
.mode-toggle-option {
  position: relative;
  z-index: 1;
  background: none;
  border: none;
  padding: 12px 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color .2s;
  border-radius: 999px;
}
.mode-icon { font-size: 13px; }
.mode-toggle-option[aria-selected="true"] { color: var(--posso-ink); }
.mode-toggle.mode-naoposso .mode-toggle-option#mode-naoposso[aria-selected="true"] { color: #2a0505; }

/* ============================================================
   Calendário
   ============================================================ */
.calendar-card { padding: 22px; }
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.calendar-actions { display: flex; gap: 4px; }

.cal-scroll {
  max-height: 620px;
  overflow-y: auto;
  padding-right: 4px;
  margin-top: 12px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
}
.cal-dow {
  font-size: 11px;
  text-align: center;
  color: var(--ink-faint);
  text-transform: uppercase;
  font-weight: 600;
  padding-bottom: 4px;
  letter-spacing: 0.04em;
}
.cal-month-label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin: 18px 0 6px;
  grid-column: 1 / -1;
}
.cal-grid > .cal-month-label:first-child { margin-top: 0; }

.cal-day {
  aspect-ratio: 1;
  min-height: 52px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  user-select: none;
  transition: background .12s, border-color .12s, transform .1s;
  position: relative;
}
.cal-day:hover:not(.out-of-range):not(.locked) {
  border-color: var(--ink-faint);
  transform: translateY(-1px);
}
.cal-day.out-of-range { visibility: hidden; cursor: default; }
.cal-day.locked { cursor: default; opacity: 0.5; }

/* salvo: posso */
.cal-day.saved-yes {
  background: var(--posso-dim);
  border-color: rgba(74, 222, 154, 0.45);
  color: var(--posso);
  font-weight: 700;
}
/* salvo: não posso */
.cal-day.saved-no {
  background: var(--naoposso-dim);
  border-color: rgba(255, 107, 107, 0.45);
  color: var(--naoposso);
  font-weight: 700;
}
/* alterado e ainda não salvo (independente da direção) */
.cal-day.pending {
  background: var(--pending);
  border-color: var(--pending);
  color: var(--pending-ink);
  font-weight: 700;
  box-shadow: 0 0 0 3px rgba(255, 182, 72, 0.18);
}

.cal-day .count {
  font-size: 9px;
  font-weight: 600;
  margin-top: 2px;
  color: var(--ink-faint);
}
.cal-day.saved-yes .count { color: rgba(74, 222, 154, 0.75); }
.cal-day.saved-no .count { color: rgba(255, 107, 107, 0.75); }
.cal-day.pending .count { color: rgba(42, 26, 2, 0.6); }

/* pré-visualização de arraste de intervalo */
.cal-day.range-preview {
  background: rgba(255, 182, 72, 0.25);
  border-color: var(--pending);
}

.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-dim);
  margin-top: 16px;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.dot-saved-yes { background: var(--posso); }
.dot-saved-no { background: var(--naoposso); }
.dot-pending { background: var(--pending); }

.hint-text {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin: 14px 0 0;
}

/* ============================================================
   Barra de salvar
   ============================================================ */
.save-bar {
  position: sticky;
  bottom: 16px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--posso);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.save-bar-msg { font-size: 14px; }
.save-bar-msg strong { color: var(--posso); }
.save-bar-actions { display: flex; gap: 8px; }

/* ============================================================
   Melhores dias
   ============================================================ */
.best-days-list { display: flex; flex-direction: column; gap: 8px; }
.best-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.best-day-row.is-top {
  border-color: rgba(74, 222, 154, 0.5);
  background: var(--posso-dim);
}
.best-day-info { display: flex; flex-direction: column; }
.best-day-date { font-size: 13px; font-weight: 700; }
.best-day-count { font-size: 12px; color: var(--ink-dim); }
.best-day-row.is-top .best-day-count { color: var(--posso); }
.best-day-flame { font-size: 15px; }

/* ============================================================
   Lista de pessoas
   ============================================================ */
.people-list { display: flex; flex-direction: column; }
.person-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  gap: 10px;
}
.person-row:last-child { border-bottom: none; }
.person-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-name { font-size: 14px; font-weight: 500; }
.person-meta { font-size: 12px; color: var(--ink-dim); white-space: nowrap; }

.empty-note {
  color: var(--ink-faint);
  font-size: 14px;
  padding: 6px 0;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Estados utilitários
   ============================================================ */
.hidden { display: none !important; }

.loading-note, .error-note {
  text-align: center;
  padding: 60px 0;
  font-size: 14px;
}
.loading-note { color: var(--ink-dim); }
.error-note { color: var(--naoposso); }

/* ============================================================
   Responsivo
   ============================================================ */
@media (max-width: 600px) {
  .hero h1 { font-size: 28px; }
  .event-header h1 { font-size: 24px; }
  .cal-day { min-height: 42px; font-size: 13px; }
  .save-bar { flex-direction: column; align-items: stretch; }
  .save-bar-actions { justify-content: stretch; }
  .save-bar-actions .btn { flex: 1; }
}