/*
  Clínica Editorial — Auditório Hospital Municipal
  Paleta: azul-marinho para confiança, teal para cuidado e âmbar para atenção.
  Layout: navegação lateral, calendário operacional e formulário editorial.
*/

:root {
  --navy: #16283d;
  --navy-2: #213c55;
  --teal: #167c80;
  --teal-soft: #dff3f0;
  --amber: #e2a746;
  --amber-soft: #fff1d5;
  --ink: #263644;
  --muted: #778794;
  --paper: #f5f7f5;
  --white: #ffffff;
  --line: #e4e9e8;
  --danger: #b54b4b;
  --shadow: 0 16px 40px rgba(32, 54, 67, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

/* Navegação */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: 245px;
  flex-direction: column;
  padding: 29px 18px 20px;
  background: var(--navy);
  color: #d8e5e8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--amber);
  color: var(--navy);
  font-size: 20px;
}

.brand strong {
  display: block;
  color: #ffffff;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #9db5ba;
  font-size: 10px;
}

.side-label {
  margin: 59px 13px 15px;
  color: #78949e;
  font-size: 10px;
  letter-spacing: 0.16em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 13px;
  border-radius: 9px;
  color: #a9c1c4;
  transition: background 180ms ease, color 180ms ease;
}

.nav-link:hover,
.nav-link:first-child {
  background: #29475d;
  color: #ffffff;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid #345064;
}

.avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
  font-weight: 700;
}

.sidebar-foot b {
  display: block;
  color: #ffffff;
  font-size: 11px;
}

.sidebar-foot small {
  color: #8faab0;
  font-size: 10px;
}

.sidebar-foot > a {
  margin-left: auto;
  color: #aac1c3;
}

/* Estrutura geral */
.main {
  min-height: 100vh;
  margin-left: 245px;
  padding: 56px 6.5% 70px;
}

.main-public {
  margin-left: 0;
  padding: 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.topbar.compact {
  align-items: center;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.topbar h1 {
  margin: 0;
  color: var(--navy);
  font-family: Fraunces, Georgia, serif;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 17px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(24, 57, 70, 0.12);
}

.button:active {
  transform: scale(0.98);
}

.button.primary {
  background: var(--teal);
  color: #ffffff;
}

.button.secondary {
  background: var(--teal-soft);
  color: var(--teal);
}

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

.button.full {
  width: 100%;
  margin-top: 9px;
}

/* Dashboard */
.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.metric,
.calendar-card,
.upcoming-card,
.form-card,
.report-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.metric {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 20px;
}

.metric-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  font-size: 17px;
}

.metric-icon.teal {
  background: var(--teal-soft);
  color: var(--teal);
}

.metric-icon.amber {
  background: var(--amber-soft);
  color: #a66e14;
}

.metric-icon.navy {
  background: #e7edf2;
  color: var(--navy);
}

.metric b {
  display: block;
  color: var(--navy);
  font-size: 22px;
}

.metric span:last-child {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 20px;
}

.calendar-card,
.upcoming-card {
  padding: 25px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.card-heading h2 {
  margin: 0;
  color: var(--navy);
  font-family: Fraunces, Georgia, serif;
  font-size: 25px;
  letter-spacing: -0.025em;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-nav a {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--navy);
}

.month-nav a:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.month-nav .today-link {
  width: auto;
  padding: 0 10px;
  font-size: 11px;
}

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

.calendar-weekdays {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.calendar-weekdays span {
  color: #96a5aa;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
}

.calendar-grid {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.day-cell {
  min-height: 82px;
  overflow: hidden;
  padding: 7px 5px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.day-number {
  display: block;
  margin-bottom: 4px;
  color: #829197;
  font-size: 11px;
}

.day-cell.today .day-number {
  display: grid;
  width: 23px;
  height: 23px;
  margin-top: -2px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
}

.event-chip {
  display: block;
  overflow: hidden;
  margin: 3px 0;
  padding: 4px;
  border-left: 3px solid var(--teal);
  border-radius: 0 4px 4px 0;
  background: #eaf7f5;
  color: #24595d;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-chip.particular {
  border-color: var(--amber);
  background: #fff5e5;
  color: #815a1c;
}

.calendar-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 17px;
  color: var(--muted);
  font-size: 10px;
}

.calendar-legend i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
}

.dot.instituicao {
  background: var(--teal);
}

.dot.particular {
  background: var(--amber);
}

.legend-hint {
  margin-left: auto;
}

.upcoming-card {
  display: flex;
  flex-direction: column;
}

.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upcoming-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.date-block {
  min-width: 41px;
  padding: 5px 3px;
  border-radius: 7px;
  background: #f1f5f4;
  text-align: center;
}

.date-block b {
  display: block;
  color: var(--navy);
  font-size: 17px;
}

.date-block span {
  color: var(--muted);
  font-size: 8px;
}

.upcoming-item strong {
  display: block;
  max-width: 170px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upcoming-item div:nth-child(2) span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.item-arrow {
  margin-left: auto;
  color: var(--teal);
}

.text-link {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 22px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

.empty-state,
.empty-report {
  padding: 50px 15px;
  color: var(--muted);
  text-align: center;
}

.empty-state span,
.empty-report span {
  color: #bbd9d6;
  font-size: 32px;
}

.empty-state p {
  font-size: 12px;
}

.empty-state a {
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

/* Formulários */
.form-card,
.report-card {
  max-width: 980px;
  padding: 34px;
}

.booking-form {
  max-width: 800px;
}

.form-section {
  display: flex;
  gap: 16px;
  margin: 2px 0 22px;
}

.section-number {
  padding-top: 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.form-section h2 {
  margin: 0;
  color: var(--navy);
  font-family: Fraunces, Georgia, serif;
  font-size: 20px;
}

.form-section p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.form-grid {
  display: grid;
  gap: 15px;
  margin: 0 0 32px;
}

.form-grid.two {
  grid-template-columns: 1.4fr 0.8fr;
}

.form-grid.three {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #52646d;
  font-size: 11px;
  font-weight: 700;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 12px 13px;
  outline: 0;
  border: 1px solid #dce5e3;
  border-radius: 7px;
  background: #fbfcfb;
  color: var(--ink);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.form-grid textarea {
  resize: vertical;
}

.optional {
  color: #a2afb1;
  font-weight: 400;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.delete-form {
  margin-top: 26px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.danger-link {
  background: none;
  color: var(--danger);
  font-size: 11px;
}

/* Relatórios */
.action-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.report-month {
  padding: 0 7px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}

.report-summary {
  display: flex;
  gap: 60px;
  margin-bottom: 22px;
  padding-bottom: 25px;
  border-bottom: 1px solid var(--line);
}

.report-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
}

.report-summary b {
  color: var(--navy);
  font-family: Fraunces, Georgia, serif;
  font-size: 25px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: #8a9a9c;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-align: left;
}

td {
  padding: 15px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  vertical-align: top;
}

td strong {
  display: block;
  color: var(--navy);
}

td small {
  display: block;
  max-width: 170px;
  margin-top: 5px;
  color: var(--muted);
}

.type-pill {
  padding: 5px 8px;
  border-radius: 20px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 9px;
}

.type-pill.particular {
  background: var(--amber-soft);
  color: #986c22;
}

.table-action {
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
}

.empty-report h2 {
  margin: 14px 0 5px;
  color: var(--navy);
  font-family: Fraunces, Georgia, serif;
}

.empty-report p {
  margin-bottom: 20px;
}

/* Mensagens */
.flash-stack {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.flash {
  padding: 12px 14px;
  border-left: 4px solid var(--teal);
  border-radius: 4px;
  background: #ffffff;
  box-shadow: var(--shadow);
  font-size: 12px;
}

.flash.error {
  border-color: var(--danger);
}

.flash button {
  margin-left: 16px;
  background: none;
  color: #829197;
}

/* Tela de login */
.login-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--navy);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 9vh 12%;
  background: #f7f9f7;
}

.brand-dark {
  margin-bottom: 70px;
  padding: 0;
}

.brand-dark strong {
  color: var(--navy);
}

.brand-dark span {
  color: var(--muted);
}

.login-panel h1 {
  margin: 0 0 17px;
  color: var(--navy);
  font-family: Fraunces, Georgia, serif;
  font-size: 52px;
  line-height: 1.04;
  letter-spacing: -0.05em;
}

.login-panel h1 em {
  color: var(--teal);
  font-style: normal;
}

.login-intro {
  max-width: 350px;
  margin-bottom: 30px;
  color: var(--muted);
  line-height: 1.7;
}

.login-panel .form-grid {
  max-width: 360px;
  margin-bottom: 0;
}

.login-note {
  margin-top: 20px;
  color: #98a8aa;
  font-size: 10px;
}

.login-aside {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: 100vh;
  overflow: hidden;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12%;
  background-color: #0e5b64;
  background-image:
    linear-gradient(rgba(14, 45, 62, 0.55), rgba(14, 45, 62, 0.72)),
    url('/static/images/login-bg.png');
  /* Mostra mais da parte esquerda da imagem, onde está o nome institucional. */
  background-position: 30% center;
  background-repeat: no-repeat;
  background-size: cover;
  color: #ffffff;
}

.login-aside::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: '';
  background:
    radial-gradient(circle at 72% 32%, rgba(225, 170, 70, 0.24), transparent 23%),
    radial-gradient(circle at 35% 70%, rgba(38, 175, 164, 0.25), transparent 28%);
  pointer-events: none;
}

.aside-orbit {
  position: absolute;
  z-index: -1;
  top: 21%;
  left: 23%;
  width: 410px;
  height: 410px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  box-shadow:
    0 0 0 36px rgba(255, 255, 255, 0.025),
    0 0 0 74px rgba(255, 255, 255, 0.02);
  pointer-events: none;
}

.quote {
  position: relative;
  max-width: 430px;
  margin-bottom: 42px;
  font-family: Fraunces, Georgia, serif;
  font-size: 35px;
  line-height: 1.15;
}

.aside-meta {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #b2d0d0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Responsividade */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    display: flex;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 18px;
  }

  .side-label,
  .sidebar-foot {
    display: none;
  }

  .sidebar nav {
    display: flex;
    margin-left: auto;
  }

  .nav-link {
    padding: 8px;
  }

  .nav-link span {
    display: none;
  }

  .main {
    margin-left: 0;
    padding: 35px 5%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

  .upcoming-card {
    min-height: 320px;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-aside {
    display: none;
  }

  .login-panel {
    min-height: 100vh;
    padding: 50px 9%;
  }

  .login-panel h1 {
    font-size: 44px;
  }
}

@media (max-width: 600px) {
  .topbar,
  .topbar.compact {
    display: block;
  }

  .topbar .button,
  .action-row {
    margin-top: 20px;
  }

  .action-row {
    flex-wrap: wrap;
  }

  .topbar h1 {
    font-size: 32px;
  }

  .calendar-card,
  .upcoming-card,
  .form-card,
  .report-card {
    padding: 18px;
  }

  .day-cell {
    min-height: 68px;
  }

  .event-chip {
    font-size: 8px;
  }

  .legend-hint {
    display: none;
  }

  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions .button {
    flex: 1;
  }

  .report-summary {
    gap: 30px;
  }

  .aside-meta {
    flex-direction: column;
  }
}

@media print {
  .sidebar,
  .topbar .button,
  .action-row,
  .flash-stack,
  .table-action,
  .delete-form {
    display: none !important;
  }

  .main {
    margin: 0;
    padding: 0;
  }

  .report-card {
    max-width: none;
    border: 0;
    box-shadow: none;
  }

  .report-summary {
    margin-top: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
