body {
  font-family: "Inter", sans-serif;
  margin: 0;
  background-color: #f1f5f9;
  color: #0f172a;
}

.dark body {
  background-color: #0b1629;
  color: #e2e8f0;
}

@media (max-width: 768px) {
  .cf-planner-event {
    padding: 0.15rem 0.25rem;
    font-size: 0.65rem;
    border-radius: 4px;
    gap: 0.05rem;
  }

  .cf-event-patient {
    font-size: 0.65rem;
  }

  .cf-event-time {
    font-size: 0.6rem;
  }

  .cf-hour-cell {
    padding: 0.2rem 0.3rem;
    gap: 0.15rem;
  }

  .cf-planner-space-header {
    padding: 0.6rem 0.8rem;
  }

  .cf-event-whatsapp,
  .cf-list-whatsapp {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.16);
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
  }

  .cf-event-whatsapp:hover,
  .cf-list-whatsapp:hover {
    background: rgba(14, 165, 233, 0.3);
  }

  .fc .fc-button {
    padding: 0.3rem 0.6rem !important;
    font-size: 0.75rem !important;
    line-height: 1.2 !important;
  }

  .fc-list-event-dot {
    border-width: 6px !important;
  }

  .fc-event-main {
    overflow: hidden !important;
  }
}

/* Estilos gerais do calendário para melhor visualização */
.fc-event-title-custom {
  padding: 2px 4px;
  line-height: 1.4;
}

.fc-event-title-custom strong {
  display: inline-block;
  margin-right: 4px;
}

/* Classes de cores para profissionais */
.prof-color-0 {
  background-color: #3498db !important;
  border-color: #2980b9 !important;
}
.prof-color-1 {
  background-color: #2ecc71 !important;
  border-color: #27ae60 !important;
}
.prof-color-2 {
  background-color: #e74c3c !important;
  border-color: #c0392b !important;
}
.prof-color-3 {
  background-color: #f1c40f !important;
  border-color: #f39c12 !important;
}
.prof-color-4 {
  background-color: #9b59b6 !important;
  border-color: #8e44ad !important;
}
.prof-color-5 {
  background-color: #1abc9c !important;
  border-color: #16a085 !important;
}
.prof-color-6 {
  background-color: #e67e22 !important;
  border-color: #d35400 !important;
}
.prof-color-default {
  background-color: #95a5a6 !important;
  border-color: #7f8c8d !important;
}

/* Garante que o texto seja sempre branco nas classes de cores */
.prof-color-0,
.prof-color-1,
.prof-color-2,
.prof-color-3,
.prof-color-4,
.prof-color-5,
.prof-color-6,
.prof-color-default {
  color: white !important;
}

/* Melhora o container do calendário */
#calendar {
  max-width: 100%;
  margin: 0 auto;
}

/* Planner diário customizado */
.cf-agenda-calendar {
  padding: 0;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  height: 100%;
  min-height: 600px;
  display: flex;
  flex-direction: column;
}

.dark .cf-agenda-calendar {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.24);
}

.cf-planner {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  color: #0f172a;
  --planner-columns: 1;
  position: relative;
  /* Removido overflow: hidden para permitir scroll sincronizado */
}

.cf-planner-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: visible; /* Permitir que os elementos internos controlem o scroll */
}

.dark .cf-planner {
  color: #e2e8f0;
}

.cf-planner-header {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
  /* Removido overflow: hidden para permitir scroll */
}

.dark .cf-planner-header {
  background: #12213b;
  border-color: rgba(148, 163, 184, 0.3);
}

.cf-planner-time-header {
  width: 88px;
  min-width: 88px;
  max-width: 88px;
  padding: 0.85rem 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  background: #f1f5f9;
  border-right: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  position: sticky;
  left: 0;
  z-index: 21; /* Maior z-index para ficar sempre visível */
}

.dark .cf-planner-time-header {
  color: rgba(203, 213, 225, 0.75);
  background: #15233d;
  border-right-color: rgba(148, 163, 184, 0.3);
}

.cf-planner-spaces-header {
  flex: 1;
  background: #f8fafc;
  display: grid;
  grid-template-columns: repeat(
    var(--planner-columns, 1),
    200px
  ); /* Largura fixa em vez de minmax */
  min-width: calc(var(--planner-columns, 1) * 200px);
  width: calc(
    var(--planner-columns, 1) * 200px
  ); /* Largura fixa para alinhamento */
  overflow: hidden; /* Header não deve ter scroll próprio */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.cf-planner-spaces-header::-webkit-scrollbar {
  display: none;
}

.dark .cf-planner-spaces-header {
  background: #101c31;
}

.cf-planner-space-header {
  padding: 0.85rem 1.1rem;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 200px; /* Largura fixa */
  min-width: 200px;
  max-width: 200px;
  white-space: nowrap;
}

.cf-planner-space-header:first-child {
  border-left: none;
}

.dark .cf-planner-space-header {
  background: #15233c;
  border-left-color: rgba(148, 163, 184, 0.18);
}

.cf-space-name {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  color: inherit;
}

.cf-planner-body {
  flex: 1;
  position: relative;
  background: #ffffff;
  overflow-x: auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  /* Scroll sincronizado será implementado via JavaScript */
}

.dark .cf-planner-body {
  background: #0b1629;
}

.cf-planner-rows {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: inherit;
  min-width: calc(
    88px + (var(--planner-columns, 1) * 200px)
  ); /* Largura fixa */
  height: 100%;
}

.cf-planner-row {
  display: flex;
  min-height: 52px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.cf-planner-row:last-child {
  border-bottom: 1px solid #e2e8f0;
}

.dark .cf-planner-row:last-child {
  border-bottom-color: rgba(148, 163, 184, 0.16);
}

.dark .cf-planner-row {
  border-bottom-color: rgba(148, 163, 184, 0.16);
}

.cf-planner-row-time {
  width: 88px;
  min-width: 88px;
  max-width: 88px;
  padding: 0.6rem 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  background: #f1f5f9;
  border-right: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-weight: 500;
  min-height: 52px;
  padding-top: 0.8rem;
  position: sticky;
  left: 0;
  z-index: 21; /* Mesmo z-index do header para alinhamento */
}

.dark .cf-planner-row-time {
  color: rgba(203, 213, 225, 0.7);
  background: #15233d;
  border-right-color: rgba(148, 163, 184, 0.3);
}

.cf-planner-row-spaces {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(
    var(--planner-columns, 1),
    200px
  ); /* Largura fixa em vez de minmax */
  background: inherit;
  min-width: calc(var(--planner-columns, 1) * 200px);
  width: calc(
    var(--planner-columns, 1) * 200px
  ); /* Largura fixa para alinhamento */
}

.dark .cf-planner-row-spaces {
  border-right-color: rgba(148, 163, 184, 0.3);
}

.cf-hour-cell {
  padding: 0.2rem 0.3rem;
  border-left: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 0.1rem;
  min-height: 52px;
  background: #ffffff;
  width: 200px; /* Largura fixa */
  min-width: 200px;
  max-width: 200px;
  position: relative;
  overflow: visible;
}

.cf-hour-cell:first-child {
  border-left: none;
}

.cf-hour-cell:last-child {
  border-right: 1px solid #e2e8f0;
}

.dark .cf-hour-cell:last-child {
  border-right-color: rgba(148, 163, 184, 0.14);
}

.dark .cf-hour-cell {
  border-left-color: rgba(148, 163, 184, 0.14);
  border-right-color: rgba(148, 163, 184, 0.14);
  border-bottom-color: rgba(148, 163, 184, 0.14);
  background: #0b1629;
}

.cf-planner-event {
  position: relative;
  padding: 0.15rem 0.25rem;
  border-radius: 3px;
  color: #0f172a;
  border-left: 3px solid rgba(45, 212, 191, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.02rem;
  cursor: pointer;
  transition: transform 0.15s ease;
  font-size: 0.6rem;
  line-height: 1;
  min-height: auto;
  margin-bottom: 0.08rem;
  flex-shrink: 0;
  max-height: none;
  overflow: hidden;
  /* Removida cor de fundo padrão para usar apenas o inline style */
}

.cf-event-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  gap: 0.25rem;
}

.cf-event-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.02rem;
  min-width: 0;
}

.dark .cf-planner-event {
  border-color: rgba(148, 163, 184, 0.26);
}

.cf-planner-event:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cf-event-patient {
  font-weight: 600;
  font-size: 0.6rem;
  line-height: 1;
  margin: 0;
  padding: 0;
}

.cf-event-time {
  font-weight: 500;
  font-size: 0.55rem;
  opacity: 0.8;
  margin: 0;
  padding: 0;
}

.cf-event-whatsapp,
.cf-list-whatsapp {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.16);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.cf-event-whatsapp:hover,
.cf-list-whatsapp:hover {
  background: rgba(14, 165, 233, 0.28);
}

.cf-agenda-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  background: #ffffff;
  min-height: 420px;
}

.dark .cf-agenda-list {
  background: #0f172a;
}

.cf-agenda-card {
  border-radius: 14px;
  padding: 1rem 1.1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 6px solid rgba(45, 212, 191, 0.8);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: border-color 0.18s ease, transform 0.18s ease;
  cursor: pointer;
}

.dark .cf-agenda-card {
  background: #15233d;
  border-color: rgba(148, 163, 184, 0.16);
}

.cf-agenda-card:hover {
  transform: translateY(-2px);
  border-color: rgba(20, 184, 166, 0.7);
}

.cf-agenda-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #475569;
}

.dark .cf-agenda-card-header {
  color: rgba(203, 213, 225, 0.75);
}

.cf-agenda-card-header strong {
  color: #0f172a;
  letter-spacing: 0.04em;
}

.dark .cf-agenda-card-header strong {
  color: #e2e8f0;
}

.cf-agenda-card-status {
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  text-align: center;
  color: inherit;
}

.cf-agenda-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #334155;
}

.dark .cf-agenda-card-body {
  color: rgba(203, 213, 225, 0.9);
}

.cf-agenda-card-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.cf-agenda-card-subtitle {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 0.2rem;
}

.dark .cf-agenda-card-subtitle {
  color: rgba(148, 163, 184, 0.78);
}

.cf-agenda-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: #64748b;
  font-size: 0.92rem;
}

.dark .cf-agenda-empty {
  color: rgba(148, 163, 184, 0.7);
}

.cf-agenda-icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    rgba(13, 148, 136, 0.16),
    rgba(14, 165, 233, 0.22)
  );
  color: #0f766e;
  border: 1px solid rgba(14, 165, 233, 0.35);
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.cf-agenda-icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(14, 165, 233, 0.18);
}

.dark .cf-agenda-icon-btn {
  background: linear-gradient(
    135deg,
    rgba(13, 148, 136, 0.18),
    rgba(14, 165, 233, 0.25)
  );
  color: #99f6e4;
  border-color: rgba(45, 212, 191, 0.4);
}

.cf-agenda-pill-btn {
  height: 2.25rem;
  width: 2.5rem;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease-in-out;
}

.cf-agenda-pill-btn:hover {
  background: #f8fafc;
  border-color: #0f766e;
  color: #0f766e;
}

.dark .cf-agenda-pill-btn {
  background: rgba(15, 23, 42, 0.75);
  border-color: #334155;
  color: #e2e8f0;
}

.dark .cf-agenda-pill-btn:hover {
  background: rgba(15, 118, 110, 0.2);
  border-color: rgba(20, 184, 166, 0.5);
  color: #5eead4;
}

.cf-agenda-chip {
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: 9999px;
  border: 1px solid rgba(14, 165, 233, 0.35);
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
  font-weight: 600;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.cf-agenda-chip:hover {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.55);
  color: #0f172a;
}

.dark .cf-agenda-chip {
  background: rgba(14, 165, 233, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}

.dark .cf-agenda-chip:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: rgba(56, 189, 248, 0.6);
  color: #f8fafc;
}

.cf-agenda-calendar .e-schedule-layout {
  border-radius: 0 0 0.75rem 0.75rem;
  overflow: hidden;
}

.cf-agenda-calendar .e-day-view .e-schedule-table thead th,
.cf-agenda-calendar .e-week-view .e-schedule-table thead th,
.cf-agenda-calendar .e-work-week-view .e-schedule-table thead th {
  background: rgba(15, 118, 110, 0.08);
  color: #0f172a;
  font-weight: 600;
  border-color: rgba(15, 118, 110, 0.12);
}

.dark .cf-agenda-calendar .e-day-view .e-schedule-table thead th,
.dark .cf-agenda-calendar .e-week-view .e-schedule-table thead th,
.dark .cf-agenda-calendar .e-work-week-view .e-schedule-table thead th {
  background: rgba(15, 118, 110, 0.14);
  color: #e2e8f0;
  border-color: rgba(15, 118, 110, 0.2);
}

.cf-agenda-calendar .e-time-cells,
.cf-agenda-calendar .e-day-view .e-time-cells-wrap,
.cf-agenda-calendar .e-day-view .e-time-slots td {
  background-color: rgba(15, 23, 42, 0.02);
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: 500;
}

.dark .cf-agenda-calendar .e-time-cells,
.dark .cf-agenda-calendar .e-day-view .e-time-cells-wrap,
.dark .cf-agenda-calendar .e-day-view .e-time-slots td {
  background-color: rgba(30, 41, 59, 0.6);
  color: #cbd5f5;
}

.cf-agenda-calendar .e-work-cells {
  border-color: rgba(15, 23, 42, 0.1);
}

.dark .cf-agenda-calendar .e-work-cells {
  border-color: rgba(148, 163, 184, 0.08);
}

.cf-agenda-calendar .e-resource-cells {
  background-color: rgba(15, 118, 110, 0.08);
  color: #0f172a;
  font-weight: 600;
  border-right: 1px solid rgba(15, 118, 110, 0.12);
}

.dark .cf-agenda-calendar .e-resource-cells {
  background-color: rgba(15, 118, 110, 0.12);
  color: #e2e8f0;
  border-right: 1px solid rgba(45, 212, 191, 0.2);
}

.cf-agenda-calendar .e-schedule-table tbody tr td,
.cf-agenda-calendar .e-schedule-table tbody tr th {
  border-color: #e2e8f0;
}

.dark .cf-agenda-calendar .e-schedule-table tbody tr td,
.dark .cf-agenda-calendar .e-schedule-table tbody tr th {
  border-color: #334155;
}

.cf-agenda-calendar .e-appointment {
  border-radius: 0.75rem;
  padding: 0;
  transition: transform 0.15s ease-in-out, box-shadow 0.2s ease;
}

.cf-agenda-calendar .e-appointment:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.18);
}

.cf-agenda-calendar .e-agenda-view .e-appointment {
  border-radius: 0.75rem;
  overflow: hidden;
}

.cf-agenda-event {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem;
  min-height: 84px;
}

.cf-event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.cf-event-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  gap: 0.75rem;
}

.cf-event-professional::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background-color: var(--cf-prof-color, rgba(15, 118, 110, 0.9));
  margin-right: 0.45rem;
  vertical-align: middle;
}

.cf-event-status {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.85;
}

.cf-event-time {
  font-variant-numeric: tabular-nums;
}

.cf-event-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.cf-event-whatsapp:hover {
  background: rgba(255, 255, 255, 0.45);
}

.cf-event-readonly {
  opacity: 0.8;
}

.cf-resumo-item {
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: linear-gradient(
    135deg,
    rgba(14, 165, 233, 0.08),
    rgba(20, 184, 166, 0.08)
  );
}

.dark .cf-resumo-item {
  border-color: #334155;
  background: linear-gradient(
    135deg,
    rgba(14, 165, 233, 0.08),
    rgba(20, 184, 166, 0.12)
  );
}

@media (max-width: 1024px) {
  .cf-agenda-calendar .e-day-view .e-content-wrap,
  .cf-agenda-calendar .e-week-view .e-content-wrap,
  .cf-agenda-calendar .e-work-week-view .e-content-wrap {
    overflow-x: auto;
  }

  .cf-agenda-calendar .e-resource-cells {
    font-size: 0.85rem;
  }

  .cf-agenda-event {
    min-height: 72px;
    padding: 0.75rem;
  }
}
@media (max-width: 640px) {
  .cf-agenda-event {
    min-height: 64px;
    font-size: 0.85rem;
  }

  .cf-event-header {
    font-size: 0.9rem;
  }
}

/* Ajustes para tema escuro */
.dark .fc {
  --fc-border-color: #334155;
  --fc-button-bg-color: #0f766e;
  --fc-button-border-color: #0f766e;
  --fc-button-hover-bg-color: #0d9488;
  --fc-button-hover-border-color: #0d9488;
  --fc-button-active-bg-color: #0f766e;
  --fc-button-active-border-color: #0f766e;
  --fc-today-bg-color: rgba(20, 184, 166, 0.1);
}

.dark .fc-theme-standard td,
.dark .fc-theme-standard th {
  border-color: #334155;
}

.dark .fc-toolbar-title {
  color: #f1f5f9;
}

.dark .fc-col-header-cell-cushion,
.dark .fc-daygrid-day-number,
.dark .fc-list-day-text,
.dark .fc-list-day-side-text {
  color: #cbd5e1;
}

@media print {
  @page {
    size: A4;
    margin: 15mm;
  }

  /* Ocultar tudo EXCETO o contêiner temporário de impressão */
  body > *:not(#temp-print-container) {
    display: none !important;
  }

  /* Mostrar e formatar o contêiner de impressão */
  #temp-print-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }

  #cloned-print-content {
    display: block !important;
    width: 100% !important;
    padding: 10px !important;
  }

  /* Preservar cores */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .bg-blue-100 {
    background-color: #dbeafe !important;
  }
  .bg-yellow-100 {
    background-color: #fef3c7 !important;
  }
  .bg-red-100 {
    background-color: #fee2e2 !important;
  }
  .bg-slate-100 {
    background-color: #f1f5f9 !important;
  }
  .bg-gray-100 {
    background-color: #f3f4f6 !important;
  }
  .bg-amber-50 {
    background-color: #fffbeb !important;
  }
  .bg-teal-50 {
    background-color: #f0fdfa !important;
  }

  thead th {
    background-color: #e2e8f0 !important;
  }

  /* Quebras de página inteligentes */
  h1,
  h2,
  h3 {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .border,
  .rounded-lg,
  .p-3,
  .p-4 {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  table {
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  thead {
    display: table-header-group !important;
  }

  /* Expandir detalhes */
  details {
    display: block !important;
  }

  details > summary {
    display: none !important;
  }

  /* Fallback para #print-area (fichas antigas) */
  #print-area,
  #print-area * {
    visibility: visible !important;
  }
  #print-area {
    position: static !important;
    width: 100% !important;
  }
}

.body-modal-open {
  overflow: hidden;
}
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-container {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  width: 95%;
  max-width: 550px;
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
.dark .modal-container {
  background-color: #1e293b;
}
.modal-header {
  flex-shrink: 0;
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
}
.dark .modal-header {
  border-bottom-color: #334155;
}
.modal-body {
  overflow-y: auto;
  flex-grow: 1;
  padding: 1rem;
}
.modal-footer {
  flex-shrink: 0;
  padding: 1rem;
  text-align: right;
  border-top: 1px solid #e2e8f0;
}
.dark .modal-footer {
  border-top-color: #334155;
}
#preview-modal-body {
  overflow-y: auto;
}

/* Garantir fundo branco para print-area no modal */
#preview-modal-body #print-area {
  background-color: #ffffff !important;
  padding: 20px;
  min-height: 100%;
}

.tabela-demonstrativo-container {
  overflow-x: auto;
  padding-bottom: 10px;
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: searchfield-cancel-button;
  cursor: pointer;
}

.dark input[type="search"]::-webkit-search-cancel-button {
  filter: invert(1) grayscale(100%) brightness(200%);
}

#toast-notification {
  position: fixed;
  bottom: -150px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  color: white;
  font-weight: 600;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease-in-out;
  z-index: 10000;
  max-width: 90vw;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.4;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

#toast-notification.show {
  bottom: 30px;
}

#toast-notification[style*="background-color: rgb(229, 62, 62)"] {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  25% {
    transform: translateX(-50%) translateY(-5px);
  }
  75% {
    transform: translateX(-50%) translateY(5px);
  }
}

/* Responsividade para mobile */
@media (max-width: 768px) {
  #toast-notification {
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
    width: calc(100% - 20px);
    font-size: 0.85rem;
  }

  #toast-notification.show {
    bottom: 20px;
  }
}

.fc-event-main-custom {
  padding: 2px 4px;
  font-size: 0.7rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Platzhalter für zukünftige Statusfarben */
.status-confirmado {
  background-color: #2ecc71 !important;
  border-color: #27ae60 !important;
  color: white !important;
}
.status-pendente {
  background-color: #f1c40f !important;
  border-color: #f39c12 !important;
  color: white !important;
}
.status-cancelado {
  background-color: #e74c3c !important;
  border-color: #c0392b !important;
  color: white !important;
}
.status-default {
  background-color: #3498db !important;
  border-color: #2980b9 !important;
  color: white !important;
}

/* Garante que o texto dentro dos eventos coloridos seja legível */
.fc-daygrid-event-dot,
.fc-list-event-dot {
  border-color: currentColor !important;
}

.dark .fc-col-header-cell {
  background-color: #1e293b; /* Cor de fundo escura do painel */
}

/* --- AJUSTE PARA EMPILHAMENTO DE AGENDAMENTOS --- */
/* Remove o comportamento padrão do FullCalendar de esticar o evento */
.fc-timegrid-event-harness {
  position: static !important;
}

.fc-timegrid-event {
  position: static !important;
  margin-bottom: 2px !important; /* Espaço entre eventos empilhados */
  border-radius: 4px; /* Bordas arredondadas */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Garante que o conteúdo interno não estique */
.fc-event-main {
  height: auto !important;
  min-height: 1.5em; /* Altura mínima para o bloquinho */
}

/* ======================================================================== */
/* === CÓDIGO CSS FINAL V3 PARA A AGENDA - COLE APENAS ESTE BLOCO === */
/* ======================================================================== */

/* --- CORREÇÃO TEMA ESCURO E DIA ATUAL --- */
.dark .fc-col-header-cell-cushion {
  color: #e2e8f0 !important;
  background-color: transparent !important;
}
.dark .fc-timegrid-slot-label,
.dark .fc-timegrid-axis-frame {
  color: #cbd5e1;
}
.fc-theme-standard .fc-day-today {
  background-color: rgba(20, 184, 166, 0.1) !important;
}
.dark .fc-theme-standard .fc-day-today {
  background-color: rgba(20, 184, 166, 0.2) !important;
}
.fc-col-header .fc-day-today {
  background-color: transparent !important;
}
.dark .fc-col-header.fc-day-today {
  background-color: transparent !important;
}

/* --- NOVO ESTILO SIMPLIFICADO: SCROLL HORIZONTAL --- */

/* 1. O container dos eventos se torna uma linha horizontal com scroll */
.fc-timegrid-col-events {
  display: flex !important;
  flex-wrap: nowrap !important; /* Força uma única linha, impedindo a quebra */
  align-items: center; /* Centraliza os 'pills' verticalmente na linha */
  gap: 8px; /* Espaçamento horizontal */
  overflow-y: hidden !important; /* Impede a "invasão" de horários */
  overflow-x: auto !important; /* Habilita o SCROLL HORIZONTAL */
  padding: 7px 4px; /* Adiciona um pequeno respiro nas laterais */
}
/* Estilo da barra de scroll */
.fc-timegrid-col-events::-webkit-scrollbar {
  height: 4px;
  background: transparent;
}
.fc-timegrid-col-events::-webkit-scrollbar-thumb {
  background: #a1a1aa;
  border-radius: 4px;
}
.dark .fc-timegrid-col-events::-webkit-scrollbar-thumb {
  background: #52525b;
}

/* 2. O wrapper do evento (harness) é tornado invisível e se comporta como um item flex */
.fc-timegrid-event-harness {
  position: static !important; /* Remove completamente o controle de posição da biblioteca */
  flex-shrink: 0 !important; /* Impede que os 'pills' encolham para caber */
  background: transparent !important;
  border: none !important;
  box-shadow: none !important; /* Remove qualquer sombra residual */
  padding: 0 !important;
  margin: 0 !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  height: auto !important;
}

/* 3. O evento em si (a "pílula" interna) é estilizado */
.fc-timegrid-event {
  position: static !important;
  display: inline-block;
  width: auto !important;
  float: none !important;
  padding: 1px 7px !important;
  border-radius: 9999px !important; /* Totalmente arredondado */
  white-space: nowrap;
  font-size: 0.65rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.e-schedule .e-timeline-view .e-header-cells {
  text-align: center !important; /* Centraliza os nomes dos espaços */
}

.e-schedule .e-header-cells,
.e-schedule .e-content-cells {
  border-color: #374151 !important; /* Linhas mais escuras no tema escuro */
}

/* Drag and Drop Styles */
.cf-drop-zone {
  position: relative;
  transition: all 0.2s ease;
}

.cf-drop-zone::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px dashed #0ea5e9;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1;
  pointer-events: none;
}

.cf-drop-zone-active::before {
  opacity: 1;
  background-color: rgba(14, 165, 233, 0.1);
}

.cf-drop-zone-active {
  background-color: rgba(14, 165, 233, 0.05) !important;
}

.dark .cf-drop-zone-active::before {
  background-color: rgba(14, 165, 233, 0.15);
  border-color: #0ea5e9;
}

.dark .cf-drop-zone-active {
  background-color: rgba(14, 165, 233, 0.1) !important;
}

.cf-planner-event[draggable="true"] {
  cursor: move !important;
  user-select: none;
  transition: all 0.2s ease;
}

.cf-planner-event[draggable="true"]:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

/* Touch feedback for mobile */
@media (max-width: 768px) {
  .cf-planner-event[draggable="true"] {
    touch-action: none;
  }

  .cf-drop-zone::before {
    border-width: 3px;
  }
}

/* Dragging state */
.cf-planner-event.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
  z-index: 1000;
}

/* Animation for successful drop */
@keyframes dropSuccess {
  0% {
    transform: scale(1.05);
    background-color: rgba(40, 167, 69, 0.2);
  }
  100% {
    transform: scale(1);
    background-color: transparent;
  }
}

.cf-hour-cell.drop-success {
  animation: dropSuccess 0.5s ease;
}

/* Estilos de Disponibilidade */
.cf-hour-cell {
  position: relative;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Efeito hover para células vazias clicáveis */
.cf-planner-slot:hover:not(:has(.cf-planner-event)) {
  background-color: rgba(20, 184, 166, 0.08) !important;
  box-shadow: inset 0 0 0 2px rgba(20, 184, 166, 0.3);
}

.dark .cf-planner-slot:hover:not(:has(.cf-planner-event)) {
  background-color: rgba(20, 184, 166, 0.12) !important;
  box-shadow: inset 0 0 0 2px rgba(20, 184, 166, 0.4);
}

/* Ícone de adicionar que aparece ao passar o mouse sobre células vazias */
.cf-planner-slot:not(:has(.cf-planner-event))::before {
  content: "+";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  font-weight: bold;
  color: rgba(20, 184, 166, 0);
  transition: color 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 1;
}

.cf-planner-slot:hover:not(:has(.cf-planner-event))::before {
  color: rgba(20, 184, 166, 0.6);
  transform: translate(-50%, -50%) scale(1.2);
}

.dark .cf-planner-slot:hover:not(:has(.cf-planner-event))::before {
  color: rgba(20, 184, 166, 0.8);
}

.cf-hour-cell.disponivel {
  border-left: 4px solid #10b981 !important;
  background-color: rgba(16, 185, 129, 0.05) !important;
}

.cf-hour-cell.indisponivel {
  border-left: 4px solid #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.05) !important;
}

.dark .cf-hour-cell.disponivel {
  background-color: rgba(16, 185, 129, 0.1) !important;
}

.dark .cf-hour-cell.indisponivel {
  background-color: rgba(239, 68, 68, 0.1) !important;
}

/* Indicador visual mais sutil para disponibilidade */
.cf-hour-cell.disponivel::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  opacity: 0.7;
}

.cf-hour-cell.indisponivel::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  border-radius: 50%;
  opacity: 0.7;
}

.cf-planner-event[draggable="true"]:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.dark .cf-planner-event[draggable="true"]:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
  .cf-planner-event[draggable="true"]:active {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

/* Loading Overlay Centralization */
#loading-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999 !important;
}

/* Only apply flex display when not explicitly hidden */
#loading-overlay:not([style*="display: none"]):not([style*="display:none"]) {
  display: flex !important;
}

/* Sub-horários - Sistema inteligente de disponibilidade */
.cf-sub-hour-row {
  min-height: 30px !important;
  border-bottom: 1px dashed #cbd5e1 !important;
}

.dark .cf-sub-hour-row {
  border-bottom-color: rgba(148, 163, 184, 0.3) !important;
}

.cf-sub-hour-time {
  min-height: 30px !important;
  padding: 0.4rem 0.75rem !important;
  font-size: 0.65rem !important;
  color: #64748b !important;
  font-weight: 400 !important;
  background: #f8fafc !important;
}

.dark .cf-sub-hour-time {
  color: rgba(203, 213, 225, 0.5) !important;
  background: #0f1629 !important;
}

.cf-sub-hour {
  min-height: 30px !important;
  border-bottom: 1px dashed #cbd5e1 !important;
  background: #f8fafc !important;
}

.dark .cf-sub-hour {
  border-bottom-color: rgba(148, 163, 184, 0.3) !important;
  background: #0f1629 !important;
}

/* Disponibilidade em sub-horários */
.cf-sub-hour.disponivel {
  border-left: 2px solid #10b981 !important;
  background: rgba(16, 185, 129, 0.03) !important;
}

.cf-sub-hour.indisponivel {
  border-left: 2px solid #ef4444 !important;
  background: rgba(239, 68, 68, 0.03) !important;
}

/* Transições suaves */
.cf-sub-hour,
.cf-sub-hour-row,
.cf-sub-hour-time {
  transition: all 0.2s ease !important;
}

/* ============================================================= */
/* ESTILOS PARA MODAL DE CONFIGURAÇÃO DE DISPONIBILIDADE        */
/* ============================================================= */

/* Container principal do modal */
#modalDisponibilidade {
  z-index: 1000 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(4px);
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important; /* Smooth scrolling no iOS */
}

#modalDisponibilidade .bg-white {
  min-height: 300px;
  max-height: 85vh;
  position: relative !important;
  margin: 20px auto !important;
  overflow: visible !important;
  /* CORRIGIDO: Garantir que o fundo se estenda por todo o conteúdo */
  background-color: white !important;
  display: flex !important;
  flex-direction: column !important;
}

.dark #modalDisponibilidade .bg-white {
  background-color: #1f2937 !important; /* gray-800 */
}

/* NOVO: Container para o conteúdo scrollable */
#modalDisponibilidade .modal-content-container {
  flex: 1 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  background-color: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* NOVO: Garantir que formDisponibilidade tenha fundo consistente */
#formDisponibilidade {
  background-color: transparent !important;
  min-height: 100% !important;
}

#formDisponibilidade > div {
  background-color: transparent !important;
}

/* Estilos responsivos para os períodos de disponibilidade */
.periodo-disponibilidade {
  transition: all 0.2s ease;
  position: relative !important;
  z-index: 1 !important;
}

.periodo-disponibilidade:hover {
  background-color: rgba(59, 130, 246, 0.05) !important;
}

.dark .periodo-disponibilidade:hover {
  background-color: rgba(59, 130, 246, 0.1) !important;
}

/* CORRIGIDO: Garantir que inputs de time funcionem corretamente em mobile */
input[type="time"] {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.025em;
  position: relative !important;
  z-index: 2 !important;
}

/* CORRIGIDO: Prevenir problemas de posicionamento em mobile */
input[type="time"]::-webkit-calendar-picker-indicator {
  background: transparent !important;
  bottom: 0 !important;
  color: transparent !important;
  cursor: pointer !important;
  height: 100% !important;
  left: 0 !important;
  position: absolute !important;
  right: 0 !important;
  top: 0 !important;
  width: 100% !important;
  z-index: 3 !important;
}

/* Melhorar visibilidade dos números dos horários em mobile */
@media (max-width: 768px) {
  /* CORRIGIDO: Prevenir problemas de overflow e posicionamento */
  #modalDisponibilidade {
    padding: 10px !important;
  }

  #modalDisponibilidade .bg-white {
    width: calc(100% - 20px) !important;
    max-width: none !important;
    margin: 10px auto !important;
    max-height: calc(100vh - 20px) !important;
    /* Em mobile, mantém o comportamento de scroll padrão */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Em mobile, o modal-content-container não precisa de altura fixa */
  #modalDisponibilidade .modal-content-container {
    flex: none !important;
    overflow: visible !important;
    max-height: none !important;
  }

  input[type="time"] {
    font-size: 16px !important; /* Evita zoom no iOS */
    padding: 12px 8px !important;
    min-height: 44px !important; /* Touch target mínimo */
    position: relative !important;
    z-index: 10 !important;
    /* CORRIGIDO: Prevenir que o picker apareça em local errado */
    transform: none !important;
    margin: 0 !important;
  }

  /* CORRIGIDO: Garantir que o picker funcione apenas no input correto */
  input[type="time"]:focus {
    position: relative !important;
    z-index: 50 !important;
  }

  /* Garantir que o placeholder/números sejam visíveis */
  input[type="time"]::-webkit-datetime-edit-text,
  input[type="time"]::-webkit-datetime-edit-hour-field,
  input[type="time"]::-webkit-datetime-edit-minute-field {
    color: inherit !important;
    font-size: 16px !important;
    position: relative !important;
    z-index: 5 !important;
  }

  /* Corrigir seletor de espaços em mobile */
  select {
    font-size: 16px !important;
    padding: 12px 8px !important;
    min-height: 44px !important;
    position: relative !important;
    z-index: 10 !important;
  } /* Botões com tamanho adequado para touch */
  .periodo-disponibilidade button {
    min-height: 44px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    position: relative !important;
    z-index: 10 !important;
  }

  /* Checkbox com tamanho adequado */
  input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    position: relative !important;
    z-index: 10 !important;
  }

  /* CORRIGIDO: Melhorar espaçamento e prevenir sobreposições */
  .periodo-disponibilidade {
    padding: 16px !important;
    margin-bottom: 12px !important;
    position: relative !important;
    z-index: 1 !important;
    /* Prevenir problemas de touch */
    touch-action: manipulation !important;
  }

  /* Labels mais visíveis em mobile */
  .periodo-disponibilidade label {
    font-weight: 500 !important;
    color: #374151 !important;
    position: relative !important;
    z-index: 10 !important;
    /* Prevenir seleção acidental */
    user-select: none !important;
    -webkit-user-select: none !important;
  }

  .dark .periodo-disponibilidade label {
    color: #d1d5db !important;
  }

  /* NOVO: Corrigir problemas específicos de mobile */

  /* Prevenir que elementos flutuem incorretamente */
  .periodo-disponibilidade * {
    position: relative !important;
  }

  /* Melhorar controle de scroll no modal */
  #modalDisponibilidade .modal-body,
  #modalDisponibilidade .overflow-y-auto {
    scroll-behavior: smooth !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Prevenir interferência com inputs */
  .periodo-disponibilidade .grid > div {
    z-index: auto !important;
    position: relative !important;
    contain: layout !important;
    isolation: isolate !important; /* Cria novo contexto de stacking */
  }

  /* Garantir que dropdowns funcionem corretamente */
  select:focus {
    z-index: 100 !important;
    isolation: isolate !important;
  }

  /* Prevenir problemas com webkit datetime picker */
  input[type="time"]:focus::-webkit-calendar-picker-indicator {
    z-index: 1000 !important;
  }

  /* NOVO: Corrigir problemas de posicionamento do time picker */
  input[type="time"]:focus {
    isolation: isolate !important;
    transform: translateZ(0) !important; /* Force layer creation */
  }

  /* Prevenir múltiplos pickers ativos simultaneamente */
  input[type="time"]:not(:focus) {
    z-index: 1 !important;
  }

  /* Garantir que body não tenha scroll quando modal aberto */
  body:has(#modalDisponibilidade) {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
  }

  /* Melhorar o backdrop do modal */
  #modalDisponibilidade {
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
  }
}

/* Corrigir problemas específicos com input[type="time"] */
input[type="time"]::-webkit-calendar-picker-indicator {
  background: transparent;
  bottom: 0;
  color: transparent;
  cursor: pointer;
  height: auto;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: auto;
}

/* Garantir que o texto dos horários seja sempre visível */
input[type="time"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0 4px;
}

input[type="time"]::-webkit-datetime-edit-text,
input[type="time"]::-webkit-datetime-edit-hour-field,
input[type="time"]::-webkit-datetime-edit-minute-field {
  color: #1f2937;
  font-weight: 500;
}

.dark input[type="time"]::-webkit-datetime-edit-text,
.dark input[type="time"]::-webkit-datetime-edit-hour-field,
.dark input[type="time"]::-webkit-datetime-edit-minute-field {
  color: #f9fafb !important;
}

/* Estilos para botão remover período */
.periodo-disponibilidade button[onclick*="removerPeriodoDisponibilidade"] {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  border: none !important;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2) !important;
  transition: all 0.2s ease !important;
}

.periodo-disponibilidade
  button[onclick*="removerPeriodoDisponibilidade"]:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3) !important;
  transform: translateY(-1px) !important;
}

.periodo-disponibilidade
  button[onclick*="removerPeriodoDisponibilidade"]:active {
  background: linear-gradient(135deg, #b91c1c, #991b1b) !important;
  transform: translateY(0) !important;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2) !important;
}

/* Garantir que o gradiente funcione em todos os navegadores */
.periodo-disponibilidade button[onclick*="removerPeriodoDisponibilidade"] {
  background-color: #ef4444 !important; /* Fallback */
  background-image: linear-gradient(135deg, #ef4444, #dc2626) !important;
}

/* Corrigir z-index e posicionamento do modal */
#modalDisponibilidade {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(4px);
}

/* Responsividade melhorada para o modal */
@media (max-width: 768px) {
  #modalDisponibilidade .bg-white {
    width: calc(100% - 20px) !important;
    max-width: none !important;
    margin: 10px auto !important;
    max-height: calc(100vh - 20px) !important;
    /* Em mobile, mantém o comportamento de scroll padrão */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Em mobile, o modal-content-container não precisa de altura fixa */
  #modalDisponibilidade .modal-content-container {
    flex: none !important;
    overflow: visible !important;
    max-height: none !important;
  }

  #modalDisponibilidade h3 {
    font-size: 18px !important;
    line-height: 1.3 !important;
  }

  /* Melhorar botões de ação do modal */
  #modalDisponibilidade .flex.gap-2.mt-6 button {
    padding: 14px 20px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    min-height: 48px !important;
  }
}

/* NOVO: Estilos específicos para desktop (telas maiores que 768px) */
@media (min-width: 769px) {
  #modalDisponibilidade .bg-white {
    /* Garantir que o container principal tenha altura adequada */
    min-height: 400px !important;
    max-height: 85vh !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #modalDisponibilidade .modal-content-container {
    /* Container scrollable que se estende até o final */
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background-color: inherit !important;
    /* Garantir altura mínima para que o fundo apareça */
    min-height: 300px !important;
  }

  /* Garantir que todos os elementos filhos tenham fundo consistente */
  #modalDisponibilidade .modal-content-container > * {
    background-color: transparent !important;
  }

  /* Específico para período de disponibilidade em desktop */
  .periodo-disponibilidade {
    background-color: rgba(
      31,
      41,
      55,
      0.05
    ) !important; /* gray-800 com opacity */
  }

  .dark .periodo-disponibilidade {
    background-color: rgba(
      55,
      65,
      81,
      0.3
    ) !important; /* gray-700 com opacity */
  }
}

/* =================================
   RESPONSIVIDADE DAS TABELAS
   ================================= */

/* Estilo base para tabelas responsivas */
.responsive-table {
  width: 100%;
  border-collapse: collapse;
}

/* Em telas médias e grandes - LAYOUT TRADICIONAL DA TABELA */
@media (min-width: 769px) {
  .responsive-table {
    display: table !important;
  }

  .responsive-table thead {
    display: table-header-group !important;
  }

  .responsive-table tbody {
    display: table-row-group !important;
  }

  .responsive-table tr {
    display: table-row !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .responsive-table th {
    display: table-cell !important;
    padding: 12px 16px !important;
    font-weight: 600 !important;
    text-align: left !important;
    border-bottom: 2px solid #e2e8f0 !important;
    background: #f8fafc !important;
    color: #374151 !important;
    font-size: 0.875rem !important;
    white-space: nowrap !important;
  }

  .dark .responsive-table th {
    background: #374151 !important;
    color: #f3f4f6 !important;
    border-bottom-color: #4b5563 !important;
  }

  .responsive-table td {
    display: table-cell !important;
    padding: 12px 16px !important;
    border-bottom: 1px solid #e2e8f0 !important;
    vertical-align: middle !important;
    font-size: 0.875rem !important;
    /* Remove propriedades mobile */
    justify-content: initial !important;
    align-items: initial !important;
    min-height: auto !important;
    flex-direction: initial !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: initial !important;
  }

  .dark .responsive-table td {
    border-bottom-color: #374151 !important;
  }

  /* Remove o pseudo-elemento de labels em desktop */
  .responsive-table td:before {
    display: none !important;
  }

  /* Ações alinhadas à direita em desktop */
  .responsive-table td.actions-cell {
    text-align: right !important;
    margin-top: 0 !important;
    padding-top: 12px !important;
    border-top: none !important;
    white-space: nowrap !important;
  }

  /* Botões de ação com espaçamento adequado para desktop */
  .responsive-table .actions-cell .flex {
    justify-content: flex-end !important;
    gap: 8px !important;
  }

  /* Zebra striping para melhor legibilidade em desktop */
  .responsive-table tbody tr:nth-child(even) {
    background-color: #f9fafb !important;
  }

  .dark .responsive-table tbody tr:nth-child(even) {
    background-color: #1f2937 !important;
  }

  .responsive-table tbody tr:hover {
    background-color: #f0f9ff !important;
    transition: background-color 0.15s ease !important;
  }

  .dark .responsive-table tbody tr:hover {
    background-color: #1e3a8a !important;
  }
}

/* Em telas pequenas - layout compacto melhorado */
@media (max-width: 768px) {
  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table th,
  .responsive-table td,
  .responsive-table tr {
    display: block;
  }

  /* Esconde o cabeçalho da tabela */
  .responsive-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  /* Cada linha vira um card compacto */
  .responsive-table tr {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 6px;
    padding: 8px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  .dark .responsive-table tr {
    background: #1e293b;
    border-color: #475569;
  }

  /* Cada célula compacta com texto em linha única */
  .responsive-table td {
    border: none !important;
    padding: 3px 0 !important;
    position: relative;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    min-height: 22px;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Labels compactos */
  .responsive-table td:before {
    content: attr(data-label);
    font-weight: 600;
    color: #64748b;
    width: 40%;
    flex-shrink: 0;
    text-align: left;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: visible;
    text-overflow: initial;
  }

  .dark .responsive-table td:before {
    color: #94a3b8;
  }

  /* Célula de ações compacta */
  .responsive-table td.actions-cell {
    justify-content: flex-end;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
    white-space: normal;
  }

  .dark .responsive-table td.actions-cell {
    border-top-color: #475569;
  }

  .responsive-table td.actions-cell:before {
    display: none;
  }

  /* Botões de ação compactos */
  .responsive-table .actions-cell .flex {
    justify-content: flex-end !important;
    gap: 12px !important;
  }

  /* Textos em linha única - SEM quebra */
  .responsive-table td {
    word-wrap: normal;
    word-break: normal;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Status badges compactos */
  .responsive-table td span {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 2px 6px;
    white-space: nowrap;
  }

  /* Containers mais compactos APENAS em mobile */
  .bg-white.rounded-lg.shadow,
  .dark .bg-white.rounded-lg.shadow {
    padding: 8px 12px !important;
  }

  /* Espaçamentos reduzidos APENAS em mobile */
  .mb-6 {
    margin-bottom: 12px !important;
  }

  .mb-4 {
    margin-bottom: 8px !important;
  }

  /* Inputs compactos APENAS em mobile */
  input[type="search"],
  select {
    padding: 6px 10px !important;
    font-size: 0.875rem !important;
  }
}

/* ESTILOS PARA TELAS MAIORES - Melhor aproveitamento do espaço */
@media (min-width: 769px) {
  /* Containers com padding adequado para desktop */
  .bg-white.rounded-lg.shadow {
    padding: 20px 24px !important;
  }

  .dark .bg-white.rounded-lg.shadow {
    padding: 20px 24px !important;
  }

  /* Headers com espaçamento adequado */
  .flex.items-center.justify-between {
    margin-bottom: 20px !important;
  }

  /* Inputs e selects com tamanho adequado para desktop */
  input[type="search"],
  select,
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="date"],
  input[type="number"],
  textarea {
    padding: 10px 14px !important;
    font-size: 0.9rem !important;
    min-height: 42px !important;
  }

  /* Botões com dimensões adequadas para desktop */
  .bg-teal-600,
  .bg-emerald-600,
  .bg-blue-600,
  .bg-red-600,
  .bg-yellow-600 {
    padding: 10px 20px !important;
    font-size: 0.9rem !important;
    min-height: 42px !important;
  }

  /* Grid layouts mais eficientes em desktop */
  .grid.grid-cols-2.md\\:grid-cols-3.lg\\:grid-cols-4 {
    grid-template-columns: repeat(5, 1fr) !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-2 {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  .grid.grid-cols-1.gap-4,
  .grid.grid-cols-1.gap-6 {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Cards de funcionalidades com melhor layout */
  .main-menu-button {
    min-height: 120px !important;
    padding: 20px !important;
  }

  /* Melhor aproveitamento do espaço para formulários */
  .modal-container {
    max-width: 700px !important;
    width: 90% !important;
  }

  /* Search bars mais largos em desktop */
  .container.mx-auto {
    max-width: 1200px !important;
    margin: 0 auto !important;
  }

  /* Correção específica para tabelas de profissionais e pacientes */
  .responsive-table th:first-child,
  .responsive-table td:first-child {
    min-width: 200px !important;
  }

  .responsive-table th:last-child,
  .responsive-table td:last-child {
    width: 120px !important;
    text-align: center !important;
  }

  /* Melhor distribuição de colunas para dados importantes */
  .responsive-table th:nth-child(2),
  .responsive-table td:nth-child(2) {
    min-width: 150px !important;
  }

  .responsive-table th:nth-child(3),
  .responsive-table td:nth-child(3) {
    min-width: 180px !important;
  }

  /* Header com info adicional melhor posicionado */
  .flex.items-start.justify-between {
    align-items: center !important;
  }

  /* Filtros em linha em desktop */
  .grid.grid-cols-1.lg\\:grid-cols-5 {
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr !important;
    align-items: end !important;
    gap: 16px !important;
  }

  /* Status badges mais visíveis */
  .text-xs.px-2.py-1.rounded-full {
    font-size: 0.8rem !important;
    padding: 4px 12px !important;
    font-weight: 600 !important;
  }

  /* CORREÇÃO CRÍTICA: Prevenir overflow horizontal */
  .overflow-x-auto {
    overflow-x: visible !important;
  }

  /* Garantir que tabelas usem toda a largura disponível */
  .min-w-full {
    min-width: 100% !important;
    width: 100% !important;
  }

  /* Correção para containers que estão muito estreitos */
  .w-full.max-w-md,
  .w-full.max-w-lg,
  .w-full.max-w-xl {
    max-width: none !important;
    width: 100% !important;
  }

  /* Ajuste para headers que podem estar ocupando pouco espaço */
  .bg-white.rounded-lg.shadow .p-4,
  .bg-white.rounded-lg.shadow .p-5,
  .bg-white.rounded-lg.shadow .p-6 {
    padding: 24px !important;
  }

  .dark .bg-white.rounded-lg.shadow .p-4,
  .dark .bg-white.rounded-lg.shadow .p-5,
  .dark .bg-white.rounded-lg.shadow .p-6 {
    padding: 24px !important;
  }
}

/* ESTILOS PARA TELAS EXTRA GRANDES (1200px+) */
@media (min-width: 1200px) {
  /* Container principal mais largo */
  .container.mx-auto {
    max-width: 1400px !important;
  }

  /* Tabelas com mais espaço para as colunas */
  .responsive-table th,
  .responsive-table td {
    padding: 16px 24px !important;
  }

  /* Grid principal do dashboard com mais colunas */
  .grid.grid-cols-2.md\\:grid-cols-3.lg\\:grid-cols-4 {
    grid-template-columns: repeat(6, 1fr) !important;
  }

  /* Modal maior para formulários complexos */
  .modal-container {
    max-width: 900px !important;
  }

  /* Melhor aproveitamento vertical */
  .min-h-screen {
    min-height: calc(100vh - 40px) !important;
    padding: 20px !important;
  }
}

/* Layout ainda mais compacto para telas muito pequenas */
@media (max-width: 480px) {
  .responsive-table tr {
    margin-bottom: 4px;
    padding: 6px 8px;
  }

  .responsive-table td:before {
    width: 30%;
    font-size: 0.75rem;
  }

  .responsive-table td {
    font-size: 0.8rem;
    min-height: 18px;
    padding: 2px 0 !important;
    /* MANTÉM em linha - não empilha */
    flex-direction: row;
    align-items: center;
  }

  .responsive-table td.actions-cell {
    margin-top: 4px;
    padding-top: 4px;
  }

  .responsive-table .actions-cell .flex {
    gap: 8px !important;
  }

  /* Botões menores */
  .responsive-table .actions-cell i {
    font-size: 0.875rem;
  }

  /* Container principal mais compacto */
  .container.mx-auto {
    padding: 8px !important;
  }
}

/* ========================================================================== */
/* CORREÇÃO DO LAYOUT DE LOGIN PARA DESKTOP                                  */
/* ========================================================================== */

/* Layout de login responsivo - funciona bem em mobile por padrão */
#auth-view {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%) !important;
  padding: 16px !important;
  z-index: 1000 !important;
}

.dark #auth-view {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
}

/* Container do formulário de login */
#auth-view .bg-white {
  width: 100% !important;
  max-width: 380px !important;
  margin: 0 auto !important;
  padding: 24px !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
  border: 1px solid rgba(226, 232, 240, 0.8) !important;
  backdrop-filter: blur(10px) !important;
  position: relative !important;
  z-index: 1 !important;
}

.dark #auth-view .bg-white {
  background-color: rgba(30, 41, 59, 0.95) !important;
  border-color: rgba(71, 85, 105, 0.8) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
}

/* Logo e título centralizados */
#auth-view .text-center {
  text-align: center !important;
  margin-bottom: 20px !important;
}

#auth-view .text-center img {
  margin: 0 auto 12px auto !important;
  width: 48px !important;
  height: 48px !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

#auth-view .text-3xl {
  font-size: 24px !important;
  font-weight: 700 !important;
  margin-bottom: 6px !important;
  background: linear-gradient(135deg, #0f766e, #0891b2) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}

.dark #auth-view .text-3xl {
  background: linear-gradient(135deg, #14b8a6, #0ea5e9) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}

/* Campos de entrada melhorados */
#auth-view input[type="email"],
#auth-view input[type="password"] {
  width: 100% !important;
  padding: 10px 12px !important;
  border: 2px solid #e2e8f0 !important;
  border-radius: 6px !important;
  font-size: 14px !important;
  transition: all 0.2s ease !important;
  background: #ffffff !important;
}

#auth-view input[type="email"]:focus,
#auth-view input[type="password"]:focus {
  outline: none !important;
  border-color: #0f766e !important;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1) !important;
}

.dark #auth-view input[type="email"],
.dark #auth-view input[type="password"] {
  background: #374151 !important;
  border-color: #4b5563 !important;
  color: #f9fafb !important;
}

.dark #auth-view input[type="email"]:focus,
.dark #auth-view input[type="password"]:focus {
  border-color: #14b8a6 !important;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1) !important;
}

/* Labels dos campos melhorados */
#auth-view label {
  display: block !important;
  margin-bottom: 6px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  color: #374151 !important;
}

.dark #auth-view label {
  color: #d1d5db !important;
}

/* Botões melhorados */
#auth-view button {
  width: 100% !important;
  padding: 10px 20px !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  transition: all 0.2s ease !important;
  position: relative !important;
  overflow: hidden !important;
}

#auth-view .bg-teal-600 {
  background: linear-gradient(135deg, #0f766e, #0891b2) !important;
  border: none !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3) !important;
}

#auth-view .bg-teal-600:hover {
  background: linear-gradient(135deg, #0d9488, #0369a1) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.4) !important;
}

#auth-view .bg-slate-500 {
  background: linear-gradient(135deg, #64748b, #475569) !important;
  border: none !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3) !important;
}

#auth-view .bg-slate-500:hover {
  background: linear-gradient(135deg, #475569, #334155) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 16px rgba(100, 116, 139, 0.4) !important;
}

/* Link "Esqueci minha senha" */
#auth-view .text-teal-600 {
  color: #0f766e !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  transition: color 0.2s ease !important;
}

#auth-view .text-teal-600:hover {
  color: #0d9488 !important;
  text-decoration: underline !important;
}

.dark #auth-view .text-teal-600 {
  color: #14b8a6 !important;
}

.dark #auth-view .text-teal-600:hover {
  color: #5eead4 !important;
}

/* Divisor entre seções */
#auth-view .border-t {
  border-top: 1px solid #e2e8f0 !important;
  margin-top: 16px !important;
  padding-top: 16px !important;
}

.dark #auth-view .border-t {
  border-top-color: #4b5563 !important;
}

/* Garante que quando auth-view está visível, o app fica completamente escondido */
#auth-view:not([style*="display: none"]) ~ #app {
  display: none !important;
}

/* Garante que quando app está visível, auth-view fica escondido */
#app:not([style*="display: none"]) ~ #auth-view {
  display: none !important;
}

/* Força posicionamento correto das telas principais */
#app {
  position: relative !important;
  z-index: 1 !important;
}

/* Esconde telas quando explicitamente definido */
[style*="display: none"],
.hidden-screen {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Responsividade específica para desktop */
@media (min-width: 1024px) {
  #auth-view .bg-white {
    max-width: 400px !important;
    padding: 28px !important;
  }

  #auth-view .text-3xl {
    font-size: 26px !important;
  }
}

/* Responsividade para tablets */
@media (min-width: 768px) and (max-width: 1023px) {
  #auth-view .bg-white {
    max-width: 390px !important;
    padding: 26px !important;
  }
}

/* === CALENDÁRIO PERSONALIZADO DE AGENDAMENTOS === */
#calendario-personalizado [data-date] {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

#calendario-personalizado [data-date]:not(.cursor-not-allowed):hover {
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#calendario-personalizado [data-date].bg-teal-500 {
  background-color: #14b8a6;
  color: white;
  font-weight: 600;
}

.dark #calendario-personalizado [data-date].bg-teal-500 {
  background-color: #0d9488;
}

#calendario-personalizado .grid {
  min-height: 200px;
}

@media (max-width: 768px) {
  #calendario-personalizado {
    padding: 0.75rem !important;
  }

  #calendario-personalizado [data-date] {
    padding: 0.4rem !important;
    font-size: 0.75rem !important;
  }
}

/* === ESTILOS PARA GERAÇÃO DE PDF === */
/* Garantir que PDFs tenham cores fortes e legíveis */
#temp-pdf-container,
#demonstrativo-content-area,
#extrato-content-area,
#print-area,
#receipt-content,
#saude-financeira-content-area,
#lista-compras-content-area {
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
  color-adjust: exact !important;
}

/* Forçar textos escuros em containers de PDF */
#temp-pdf-container *,
#demonstrativo-content-area *,
#extrato-content-area *,
#print-area *,
#receipt-content *,
#saude-financeira-content-area *,
#lista-compras-content-area * {
  color: #000000 !important;
}

/* Exceções para elementos com cores específicas importantes */
#temp-pdf-container .text-emerald-600,
#temp-pdf-container .text-green-600,
#demonstrativo-content-area .text-emerald-600,
#demonstrativo-content-area .text-green-600 {
  color: #059669 !important;
}

#temp-pdf-container .text-red-600,
#temp-pdf-container .text-rose-600,
#demonstrativo-content-area .text-red-600,
#demonstrativo-content-area .text-rose-600 {
  color: #dc2626 !important;
}

#temp-pdf-container .text-amber-600,
#temp-pdf-container .text-yellow-600,
#demonstrativo-content-area .text-amber-600,
#demonstrativo-content-area .text-yellow-600 {
  color: #d97706 !important;
}

/* Fundos em PDFs */
#temp-pdf-container [class*="bg-slate-"],
#demonstrativo-content-area [class*="bg-slate-"] {
  background-color: #f1f5f9 !important;
}

/* Bordas de tabelas visíveis */
#temp-pdf-container table,
#temp-pdf-container th,
#temp-pdf-container td,
#demonstrativo-content-area table,
#demonstrativo-content-area th,
#demonstrativo-content-area td {
  border-color: #000000 !important;
}

/* Títulos em negrito */
#temp-pdf-container h1,
#temp-pdf-container h2,
#temp-pdf-container h3,
#demonstrativo-content-area h1,
#demonstrativo-content-area h2,
#demonstrativo-content-area h3 {
  font-weight: 700 !important;
  color: #000000 !important;
}

/* Evitar quebra de página no meio de elementos importantes */
#print-area h1,
#print-area h2,
#print-area h3,
#print-area h4,
#print-area table,
#print-area header,
#print-area footer {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* Garantir que footer fique junto */
#print-area footer {
  page-break-before: auto !important;
  margin-top: 30px !important;
}

/* Melhorar qualidade de imagens em PDFs */
#print-area img,
#demonstrativo-content-area img,
#temp-pdf-container img {
  image-rendering: -webkit-optimize-contrast !important;
  image-rendering: crisp-edges !important;
  image-rendering: high-quality !important;
  max-width: 100% !important;
  height: auto !important;
}

/* Logos maiores e mais nítidas */
#print-area img[alt="Logo"],
#print-area img[alt*="logo"] {
  max-height: 120px !important;
  width: auto !important;
}
