:root {
  --ink: #102b38;
  --muted: #5d7380;
  --line: #dbe6ea;
  --surface: #ffffff;
  --canvas: #f3f7f8;
  --primary: #0f7c85;
  --primary-dark: #0b5f67;
  --accent: #e98b2c;
  --danger: #c2413b;
  --success: #23875d;
  --warning-bg: #fff6e8;
  --warning-ink: #8a5714;
  --shadow: 0 12px 32px rgba(16, 43, 56, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

.button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  padding: 12px 18px;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 124, 133, 0.2);
  width: 100%;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.button.ghost:hover {
  background: #eef4f5;
}

.button.small {
  font-size: 0.85rem;
  padding: 8px 12px;
  width: auto;
}

.button.danger {
  background: transparent;
  border: 1px solid #e9c4c2;
  color: var(--danger);
}

.icon-button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 10px 8px;
}

.icon-button:hover:not(:disabled) {
  background: #eef4f5;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--primary), #174e63);
  border-radius: 16px;
  color: #fff;
  display: inline-flex;
  font-size: 1.1rem;
  font-weight: 800;
  height: 56px;
  justify-content: center;
  letter-spacing: 0.05em;
  width: 56px;
}

.brand-mark.small {
  border-radius: 12px;
  font-size: 0.85rem;
  height: 40px;
  width: 40px;
}

/* Logo da escola */
.brand-logo {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  justify-content: center;
}

.brand-logo img {
  display: block;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.login-logo {
  display: flex;
  height: 76px;
  margin: 0 auto 10px;
  width: 91px;
}

.topbar-logo {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  height: 42px;
  padding: 4px;
  width: 46px;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 22px 0 6px;
  text-transform: uppercase;
}

/* Login */
.login-screen {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  margin-block: auto;
  max-width: 460px;
  padding: 28px;
  width: 100%;
}

.login-card h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0 0 8px;
}

.login-card .eyebrow {
  margin: 10px 0 4px;
}

.login-intro {
  color: var(--muted);
  margin: 0 0 16px;
}

.login-card form {
  display: grid;
  gap: 8px;
}

.login-card label {
  font-size: 0.9rem;
  font-weight: 700;
}

.login-card input {
  border: 1px solid #c9d8dd;
  border-radius: 12px;
  outline: none;
  padding: 11px 14px;
}

.login-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 124, 133, 0.14);
}

.form-error {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 4px 0 0;
  min-height: 1.3em;
}

.login-note {
  background: #eef6f6;
  border-radius: 14px;
  color: #315663;
  font-size: 0.88rem;
  margin-top: 16px;
  padding: 13px;
}

/* Layout */
.app-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px 24px 48px;
}

.topbar {
  align-items: center;
  background: var(--ink);
  border-radius: 18px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 14px 18px;
}

.topbar-brand,
.user-area,
.user-info {
  align-items: center;
  display: flex;
  gap: 12px;
}

.topbar-brand strong {
  display: block;
  font-size: 1.02rem;
}

.topbar-brand small {
  color: #9fc8cd;
}

.user-info {
  align-items: flex-end;
  flex-direction: column;
  gap: 0;
}

.user-info strong {
  font-size: 0.9rem;
}

.user-info code {
  color: #9fc8cd;
  font-size: 0.78rem;
}

.topbar .button.ghost {
  border-color: #3d6574;
  color: #fff;
}

.topbar .button.ghost:hover {
  background: #1c4252;
}

.welcome {
  margin: 28px 0 20px;
}

.welcome h1 {
  font-size: 1.8rem;
  margin: 0 0 4px;
}

.welcome p {
  color: var(--muted);
  margin: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  padding: 22px;
}

.section-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-heading h2 {
  align-items: center;
  display: flex;
  font-size: 1.1rem;
  gap: 10px;
  margin: 0;
}

.step {
  align-items: center;
  background: #e7f3f3;
  border-radius: 8px;
  color: var(--primary-dark);
  display: inline-flex;
  font-size: 0.82rem;
  height: 26px;
  justify-content: center;
  width: 26px;
}

/* Spaces */
.space-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.space-card {
  align-items: center;
  background: #f8fbfb;
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  padding: 14px;
  text-align: left;
  transition: border 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.space-card:hover {
  transform: translateY(-2px);
}

.space-card.active {
  background: #eaf6f6;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 124, 133, 0.12);
}

.space-icon {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: inline-flex;
  font-size: 1.35rem;
  height: 44px;
  justify-content: center;
  min-width: 44px;
}

.space-card strong,
.space-card small {
  display: block;
}

.space-card small {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

/* Calendar */
.content-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
}

.month-nav {
  align-items: center;
  display: flex;
  gap: 10px;
  text-transform: capitalize;
}

.calendar-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekday {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  padding-bottom: 4px;
  text-align: center;
  text-transform: uppercase;
}

.calendar-empty {
  min-height: 58px;
}

.calendar-day {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 62px;
  padding: 7px 4px;
  position: relative;
  transition: transform 0.12s ease, border 0.12s ease;
}

.calendar-day:hover:not(:disabled) {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.calendar-day.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 124, 133, 0.2);
}

.calendar-day:disabled {
  cursor: not-allowed;
}

.day-number {
  font-size: 0.95rem;
  font-weight: 800;
}

.day-status {
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.1;
}

.calendar-day.partial {
  background: var(--warning-bg);
}

.calendar-day.full {
  background: #fdecea;
}

.calendar-day.closed {
  background: #eef1f2;
  opacity: 0.65;
}

.calendar-day.outside {
  background: #fafbfb;
  opacity: 0.45;
}

.calendar-day.available {
  background: #f2faf7;
}

.my-dot {
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  height: 9px;
  position: absolute;
  right: 5px;
  top: 5px;
  width: 9px;
}

.legend {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
}

.legend span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.76rem;
  gap: 6px;
}

.dot {
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.dot.available { background: var(--success); }
.dot.partial { background: var(--accent); }
.dot.full { background: var(--danger); }
.dot.closed { background: #9aa9af; }
.dot.outside { background: #d7dfe2; }
.dot.mine { background: var(--primary); }

/* Slots */
.selected-date {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: capitalize;
}

.slots-message {
  background: #eef6f6;
  border-radius: 10px;
  color: #315663;
  font-size: 0.85rem;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.slots-message.warning {
  background: var(--warning-bg);
  color: var(--warning-ink);
}

.slots-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.slot-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.slot-card.reserved {
  background: #f8f9fa;
}

.slot-card.mine {
  background: #eef6f6;
  border-color: #a8d2d2;
}

.slot-head {
  display: grid;
  gap: 3px;
}

.period {
  color: var(--primary-dark);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.slot-head strong {
  font-size: 1.02rem;
}

.slot-status {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0;
  min-height: 1.2em;
}

.slot-card .button {
  font-size: 0.82rem;
  padding: 9px 12px;
  width: 100%;
}

.slot-break {
  align-items: center;
  background: #f2f7f7;
  border: 1px dashed #c9d8dd;
  border-radius: 10px;
  color: var(--muted);
  display: flex;
  font-size: 0.8rem;
  font-weight: 700;
  grid-column: 1 / -1;
  justify-content: center;
  padding: 8px 12px;
}

/* My reservations */
.my-list {
  display: grid;
  gap: 10px;
}

.my-item {
  align-items: center;
  background: #f8fbfb;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  padding: 12px 14px;
}

.my-item-main {
  display: grid;
  gap: 2px;
}

.my-item-main strong {
  font-size: 0.95rem;
  text-transform: capitalize;
}

.my-item-main small {
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.footer {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* Toast */
.toast {
  background: var(--ink);
  border-radius: 12px;
  bottom: 22px;
  box-shadow: var(--shadow);
  color: #fff;
  left: 50%;
  max-width: min(90vw, 460px);
  opacity: 0;
  padding: 12px 18px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@media (max-width: 860px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 14px 12px 32px;
  }

  .panel {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-info {
    align-items: flex-start;
  }

  .calendar-grid {
    gap: 5px;
  }

  .calendar-day {
    min-height: 54px;
  }

  .day-status {
    font-size: 0.6rem;
  }

  .login-card {
    padding: 26px 20px;
  }
}

/* =========================================================
   Layout em etapas (telas horizontais, sem rolagem vertical)
   ========================================================= */
html,
body {
  height: 100%;
  overflow: hidden;
}

.login-screen {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-y: auto;
  align-items: flex-start;
}

.app-shell {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  max-width: 1180px;
  overflow: hidden;
  padding: 10px 18px 10px;
}

.app-shell .topbar {
  flex: 0 0 auto;
  padding: 8px 14px;
}

.app-shell .footer {
  display: none;
}

.wizard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  transition: transform 0.35s ease;
  width: 400%;
  will-change: transform;
}

.wizard-step {
  box-sizing: border-box;
  display: flex;
  flex: 0 0 25%;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 12px 16px;
  width: 25%;
}

.step-content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.step-content h2 {
  align-items: center;
  display: flex;
  font-size: 1.02rem;
  gap: 10px;
  margin: 0;
}

.step-subtitle {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0;
}

.step-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  justify-content: flex-end;
}

.wizard-dots {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
  justify-content: center;
  padding: 2px;
}

.wizard-dots button {
  background: #c9d8dd;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  height: 10px;
  padding: 0;
  width: 10px;
}

.wizard-dots button.active {
  background: var(--primary);
}

.window-line {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0;
}

/* ---------- Calendário: cada semana é uma linha que cabe no espaço ---------- */
.calendar-grid {
  display: grid;
  flex: 1 1 auto;
  gap: 5px;
  grid-auto-rows: minmax(0, 1fr);
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto;
  min-height: 0;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0 0 2px;
  text-align: center;
  text-transform: uppercase;
}

.calendar-empty {
  min-height: 0;
}

.calendar-day {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  justify-content: center;
  line-height: 1.08;
  min-height: 0;
  overflow: hidden;
  padding: 3px 2px;
  position: relative;
  text-align: center;
}

.calendar-day:hover:not(:disabled) {
  border-color: var(--primary);
  transform: none;
}

.calendar-day.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 124, 133, 0.22);
}

.calendar-day .day-number {
  font-size: clamp(0.72rem, 1.7vh, 0.95rem);
  font-weight: 700;
}

.calendar-day .day-status {
  color: var(--muted);
  display: block;
  font-size: clamp(0.46rem, 1.05vh, 0.64rem);
  line-height: 1.08;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cores da legenda aplicadas aos dias (sempre com opacidade cheia) */
.calendar-day.available { background: #eef6f6; }
.calendar-day.partial { background: #fff7e6; }
.calendar-day.full { background: #fdecea; }
.calendar-day.closed { background: #eef1f2; color: #52666f; opacity: 1; }
.calendar-day.outside { background: #f7f7f7; color: #78888f; opacity: 1; }
.calendar-day.outside .day-status,
.calendar-day.closed .day-status { color: #687a82; }
.calendar-day.outside,
.calendar-day.closed { cursor: not-allowed; }

.calendar-day:disabled { cursor: not-allowed; }

.my-dot {
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  height: 8px;
  position: absolute;
  right: 4px;
  top: 4px;
  width: 8px;
}

.legend {
  border-top: 0;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0;
  padding: 0;
}

.legend span {
  font-size: 0.62rem;
}

.legend .dot {
  height: 8px;
  width: 8px;
}

.legend .dot.available { background: #eef6f6; border: 1px solid #a8d2d2; }
.legend .dot.partial { background: #fff7e6; border: 1px solid #f0c36d; }
.legend .dot.full { background: #fdecea; border: 1px solid #e8a39a; }
.legend .dot.closed { background: #eef1f2; border: 1px solid #c9d5da; }
.legend .dot.outside { background: #f7f7f7; border: 1px solid #dfe5e8; }
.legend .dot.mine { background: var(--accent); }

/* ---------- Espaços ---------- */
.space-list {
  display: grid;
  flex: 1 1 auto;
  gap: 10px;
  grid-auto-rows: minmax(0, 1fr);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 0;
  overflow: hidden;
}

.space-card {
  min-height: 0;
  overflow: hidden;
}

/* ---------- Horários no estilo do calendário ---------- */
.selected-date {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
  text-transform: capitalize;
}

.slots-message {
  background: #eef6f6;
  border-radius: 10px;
  color: #315663;
  flex: 0 0 auto;
  font-size: 0.8rem;
  margin: 0;
  padding: 8px 12px;
}

.slots-message.warning {
  background: var(--warning-bg);
  color: var(--warning-ink);
}

.slots-grid {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.slot-period {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slot-period h3 {
  color: var(--primary-dark);
  font-size: 0.82rem;
  margin: 0;
}

.slot-cells {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.slot-cell {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  justify-content: center;
  min-height: 48px;
  padding: 4px;
  text-align: center;
}

.slot-cell.available { background: #eef6f6; }
.slot-cell.mine { background: #eef6f6; border-color: #a8d2d2; }
.slot-cell.taken { background: #f1f3f5; color: #7a8b93; cursor: not-allowed; }
.slot-cell:disabled { opacity: 1; }

.slot-ordinal {
  font-size: clamp(0.88rem, 1.9vh, 1.05rem);
  font-weight: 800;
}

.slot-cell .slot-status {
  color: var(--muted);
  font-size: clamp(0.52rem, 1.1vh, 0.68rem);
  line-height: 1.05;
}

/* ---------- Minhas reservas ---------- */
.my-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
}

.my-item {
  flex: 0 0 auto;
}

/* ---------- Telas pequenas / baixas ---------- */
@media (max-width: 640px) {
  .app-shell { padding: 8px 10px; }
  .space-list { grid-template-columns: 1fr; }
  .wizard-step { padding: 10px 10px; }
  .slot-cells { gap: 5px; }
}

/* Em telas baixas mostra só o número e a cor do status (legenda continua) */
@media (max-height: 540px) {
  .app-shell { gap: 4px; padding-top: 6px; padding-bottom: 6px; }
  .app-shell .topbar { padding: 6px 10px; }
  .wizard-step { gap: 5px; padding: 8px 10px; }
  .step-content { gap: 5px; }
  .calendar-day .day-status { display: none; }
  .calendar-day { padding: 2px; }
  .step-subtitle { display: none; }
  .legend { gap: 2px 8px; }
  .legend span { font-size: 0.56rem; }
}

/* Em telas muito baixas a legenda sai e as linhas ficam mais compactas */
@media (max-height: 480px) {
  .calendar-grid { gap: 3px; }
  .calendar-weekday { font-size: 0.58rem; }
  .legend { display: none; }
  .month-nav { gap: 6px; }
}

/* Em telas estreitas o status textual sai; a cor da célula continua indicando o estado */
@media (max-width: 460px) {
  .calendar-day .day-status { display: none; }
}
