/* ===== VARIÁVEIS ===== */
:root {
  --bg: #FAF7F5;
  --card: #FFFFFF;
  --text: #4A4A4A;
  --text-secondary: #8A8A8A;
  --rose-gold: #C9A9A6;
  --rose-gold-dark: #B76E79;
  --border: #E8E4E1;
  --hover: #F5E9E6;
  --shadow: 0 10px 30px rgba(183, 110, 121, 0.08);
}

/* ===== RESET ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== LOGIN ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card,
.login-box,
.card {
  background: white;
  border-radius: 20px;
  padding: 36px 32px 32px;
  box-shadow: 0 8px 32px rgba(183, 110, 121, 0.10);
  border: 1px solid rgba(183, 110, 121, 0.12);
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}

.login-card img,
.login-box img {
  display: block;
  margin: 0 auto 20px;
}

.login-card .form-group,
.login-box .form-group {
  margin-bottom: 16px;
}

.login-card label,
.login-box label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
  color: var(--text);
}

.logo {
  text-align: center;
  margin-bottom: 36px;
}

.logo h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--rose-gold-dark);
}

.logo p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: #FCFBFB;
  color: var(--text);
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--rose-gold);
  background: white;
  box-shadow: 0 0 0 3px rgba(201, 169, 166, 0.15);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--rose-gold-dark);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: #A35D68;
}

.footer-text {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 28px;
}

/* ===== DASHBOARD ===== */
.dashboard-body {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--rose-gold-dark);
}

.sidebar-header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.sidebar-nav {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  padding: 11px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: var(--hover);
  color: var(--rose-gold-dark);
}

.sidebar-footer {
  margin-top: auto;
}

.btn-logout {
  width: 100%;
  padding: 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}

.btn-logout:hover {
  border-color: var(--rose-gold);
  color: var(--rose-gold-dark);
}

.main-content {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--rose-gold-dark);
  letter-spacing: -0.5px;
}

.topbar p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ===== WEEK CONTROLS ===== */
.week-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-secondary {
  padding: 7px 14px;
  background: var(--hover);
  border: none;
  border-radius: 20px;
  color: var(--rose-gold-dark);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.btn-icon:hover {
  background: var(--hover);
}

#week-label {
  font-size: 14px;
  font-weight: 500;
  min-width: 170px;
  text-align: center;
}

/* ===== CALENDÁRIO (ALINHADO DE VERDADE) ===== */
.calendar-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.calendar-header {
  display: grid;
  grid-template-columns: 64px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: #FCFBFB;
  flex-shrink: 0;
}

.calendar-header .time-gutter {
  border-right: 1px solid var(--border);
}

.calendar-header .day-header {
  padding: 12px 4px;
  text-align: center;
  border-right: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.calendar-header .day-header:last-child {
  border-right: none;
}

.calendar-header .day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.calendar-header .day-header.today .day-number {
  background: var(--rose-gold-dark);
  color: white;
}

.calendar-body {
  display: grid;
  grid-template-columns: 64px repeat(7, 1fr);
  max-height: 620px;
  overflow-y: scroll;          /* força a barra aparecer sempre */
  scrollbar-gutter: stable;     /* reserva espaço da barra */
}

.time-label {
  height: 56px;
  padding: 6px 8px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: right;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.calendar-cell {
  height: 56px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}

.calendar-cell:hover {
  background: var(--hover);
}

.calendar-cell:last-child {
  border-right: none;
}

/* Card do agendamento (estilo do exemplo) */
.appointment-card {
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  background: #F8F1EF;
  border-left: 3px solid var(--rose-gold-dark);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  overflow: hidden;
  cursor: pointer;
  line-height: 1.3;
}

.appointment-card .patient-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appointment-card .procedure {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appointment-card .time-range {
  color: var(--text-secondary);
  font-size: 10px;
}

.appointment-card.blocked {
  background: #F0F0F0;
  border-left-color: #999;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

/* Lista de procedimentos */
#procedures-list {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  max-height: 160px;
  overflow-y: auto;
  background: #FCFBFB;
}

#procedures-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

#procedures-list label:hover {
  background: var(--hover);
}

#procedures-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--rose-gold-dark);
}

.empty-state {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 50px 30px;
  text-align: center;
  color: var(--text-secondary);
}

/* ===== BLOQUEIO COM RAIAS (ROSE GOLD) ===== */
.calendar-cell.blocked-slot {
  background: repeating-linear-gradient(
    -45deg,
    #F5E9E6,
    #F5E9E6 5px,
    #EAD5D0 5px,
    #EAD5D0 10px
  ) !important;
  cursor: pointer;
}

.calendar-cell.blocked-slot:hover {
  background: repeating-linear-gradient(
    -45deg,
    #F0DFD9,
    #F0DFD9 5px,
    #E5CBC4 5px,
    #E5CBC4 10px
  ) !important;
}

/* ===== RESPONSIVO ===== */

/* Tablets e celulares grandes */
@media (max-width: 900px) {
  .dashboard-body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-header {
    margin-right: 12px;
  }

  .sidebar-header h2 {
    font-size: 15px;
  }

  .sidebar-header p {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    margin-top: 0;
    gap: 6px;
    flex: 1;
    justify-content: center;
  }

  .nav-item {
    padding: 8px 12px;
    font-size: 13px;
  }

  .sidebar-footer {
    margin-top: 0;
    margin-left: 8px;
  }

  .btn-logout {
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
  }

  .main-content {
    padding: 20px 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .calendar-header,
  .calendar-body {
    grid-template-columns: 50px repeat(7, minmax(70px, 1fr));
  }

  .time-label {
    font-size: 10px;
    padding-right: 4px;
  }

  .calendar-header .day-header {
    font-size: 11px;
    padding: 10px 2px;
  }

  .calendar-header .day-number {
    width: 26px;
    height: 26px;
    font-size: 13px;
  }

  .appointment-card {
    font-size: 10px;
    padding: 3px 4px;
  }
}

/* Celulares menores */
@media (max-width: 600px) {
  .sidebar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .sidebar-nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .nav-item {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
  }

  .main-content {
    padding: 16px 12px;
  }

  .week-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  #week-label {
    min-width: auto;
    width: 100%;
    text-align: center;
    order: -1;
  }

  .calendar-wrapper {
    overflow-x: auto;
  }

  .calendar-header,
  .calendar-body {
    min-width: 600px; /* permite rolar horizontalmente se precisar */
  }

  .modal-content {
    margin: 10px;
    max-height: 95vh;
  }

  .modal-body {
    padding: 18px;
  }
}

/* ===== PRONTUÁRIO ===== */
.card-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}

.radio-group {
  display: flex;
  gap: 20px;
  margin-top: 8px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 400;
}

.conditional {
  margin-top: 10px;
}

.conditional.hidden {
  display: none;
}

.patients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.patient-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.patient-card:hover {
  border-color: var(--rose-gold);
  box-shadow: var(--shadow);
}

.patient-card h3 {
  font-size: 16px;
  color: var(--rose-gold-dark);
  margin-bottom: 4px;
}

.patient-card p {
  font-size: 13px;
  color: var(--text-secondary);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 8px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 400;
  font-size: 14px;
}

/* Destaque nas perguntas do Prontuário */
.card-form .form-group > label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  display: block;
}

.card-form h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--rose-gold-dark);
  margin-bottom: 24px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--hover);
}

.procedure-ficha {
  background: #FCFBFB;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-top: 20px;
}

.procedure-ficha.hidden {
  display: none;
}

.anatomy-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 500px;
}

.anatomy-wrapper img {
  width: 100%;
  height: auto;
  display: block;
}

.anatomy-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;

}

.drawing-tools .tool-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 13px;
}

.drawing-tools .tool-btn.active {
  background: var(--rose-gold-dark);
  color: white;
  border-color: var(--rose-gold-dark);
}

.color-options {
  display: flex;
  gap: 6px;
}

.color-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-btn.active {
  border-color: var(--text);
  transform: scale(1.15);
}

.photo-card {
  background: #FCFBFB;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.photo-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.photo-card .photo-info {
  padding: 14px;
}

.photo-card .photo-info input,
.photo-card .photo-info textarea {
  width: 100%;
  margin-bottom: 8px;
  font-size: 13px;
}

.photo-card .btn-remove-photo {
  background: none;
  border: none;
  color: #c45c5c;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-parent {
  cursor: default;
  opacity: 0.7;
  font-size: 13px;
  padding-bottom: 4px;
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 8px;
  margin-bottom: 6px;
}

.nav-item.sub {
  font-size: 14px;
  padding: 9px 14px;
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 12px;
  margin-top: 4px;
  margin-bottom: 6px;
}

.nav-submenu.hidden {
  display: none;
}

.nav-item.sub {
  font-size: 14px;
  padding: 9px 14px;
}

/* ===== BALÕES DE PROCEDIMENTOS ===== */
.proc-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.proc-bubble {
  position: relative;
  cursor: pointer;
}

.proc-bubble input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.proc-bubble span {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s ease;
  user-select: none;
}

.proc-bubble input:checked + span {
  background: var(--rose-gold-dark);
  border-color: var(--rose-gold-dark);
  color: white;
  box-shadow: 0 2px 8px rgba(183, 110, 121, 0.25);
}

.proc-bubble:hover span {
  border-color: var(--rose-gold);
}

.form-etapa.hidden {
  display: none;
}

/* ===== ESTÉTICA DAS FICHAS ===== */
.ficha-titulo {
  font-size: 18px;
  font-weight: 700;
  color: var(--rose-gold-dark);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--hover);
}

.ficha-subtitulo {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 14px;
}

.ficha-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card-form .form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  display: block;
}

.card-form input,
.card-form textarea {
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 11px 14px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card-form input:focus,
.card-form textarea:focus {
  border-color: var(--rose-gold);
  box-shadow: 0 0 0 3px rgba(183, 110, 121, 0.12);
  outline: none;
}

@media (max-width: 600px) {
  .ficha-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-header img {
  display: block;
  margin: 0 auto;
}

.sidebar-header {
  padding: 14px 12px 8px !important;
  text-align: center;
}

.sidebar-header img {
  width: 200px !important;
  height: auto !important;
  display: block;
  margin: 0 auto;
}

.historico-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

.historico-item {
  background: #FCFBFB;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.historico-item label {
  font-size: 13px;
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}

.historico-item input[type="text"],
.historico-item input[type="number"] {
  margin-top: 8px;
  width: 100%;
  font-size: 13px;
}

@media (max-width: 700px) {
  .historico-grid {
    grid-template-columns: 1fr;
  }
}

.tabela-preenchimento {
  width: 100%;
  border-collapse: collapse;
  border: 1.5px solid var(--rose-gold-dark);
  border-radius: 0;
}

.tabela-preenchimento th {
  background: var(--rose-gold-dark);
  color: white;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--rose-gold-dark);
}

.tabela-preenchimento td {
  padding: 0;
  border: 1px solid #d4a5ab;
  background: white;
}

.tabela-preenchimento input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 13px;
  text-align: center;
}

.tabela-preenchimento input:focus {
  outline: none;
  background: #FCFBFB;
}

.page {
  display: none !important;
}

.page.active {
  display: block !important;
}