/* ==========================================================================
   Design Tokens & Base Variables - Weekly Scheduler
   ========================================================================== */
:root {
  --ws-font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Primary & Accent colors */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  /* Neutral scale - Mapped to Global Theme */
  --bg-app: var(--dark-bg, #f8fafc);
  --bg-surface: var(--dark-card, #ffffff);
  --bg-subtle: var(--dark-card2, #f1f5f9);
  --border-color: var(--dark-border, #e2e8f0);
  --border-color-dark: var(--dark-border2, #cbd5e1);
  
  --text-main: var(--text-primary, #0f172a);
  --text-muted: var(--text-muted, #64748b);
  --text-light: var(--text-secondary, #94a3b8);
  
  /* Status Colors */
  --status-confirmed: #10b981;
  --status-confirmed-bg: #ecfdf5;
  --status-confirmed-border: #a7f3d0;
  
  --status-pending: #f59e0b;
  --status-pending-bg: #fffbeb;
  --status-pending-border: #fde68a;
  
  --status-progress: #0284c7;
  --status-progress-bg: #f0f9ff;
  --status-progress-border: #bae6fd;
  
  --status-completed: #64748b;
  --status-completed-bg: #f8fafc;
  --status-completed-border: #cbd5e1;
  
  --status-canceled: #ef4444;
  --status-canceled-bg: #fef2f2;
  --status-canceled-border: #fecaca;

  /* Categories Colors */
  --cat-consulta: #3b82f6;
  --cat-retorno: #10b981;
  --cat-procedimento: #8b5cf6;
  --cat-reuniao: #f59e0b;
  --cat-encaixe: #ec4899;

  /* Shadows & Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* App Container Layout for Section */
#section-weekly-schedule .app-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 90px);
  max-width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background-color: var(--bg-app);
}

/* ==========================================================================
   Header Section
   ========================================================================== */
#section-weekly-schedule .app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 20;
  gap: 16px;
  flex-wrap: wrap;
}

#section-weekly-schedule .header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

#section-weekly-schedule .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 500;
}

#section-weekly-schedule .logo-icon {
  font-size: 28px;
}

#section-weekly-schedule .logo-text strong {
  font-weight: 700;
  color: var(--text-main);
}

#section-weekly-schedule .week-navigation {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-subtle);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

#section-weekly-schedule .current-period {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

#section-weekly-schedule .current-period:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

#section-weekly-schedule .calendar-picker-icon {
  color: var(--text-muted);
  font-size: 20px;
}

#section-weekly-schedule .date-picker-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#section-weekly-schedule #currentPeriodLabel {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

#section-weekly-schedule .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Search Box */
#section-weekly-schedule .search-box {
  position: relative;
  display: flex;
  align-items: center;
}

#section-weekly-schedule .search-box input {
  width: 260px;
  padding: 8px 32px 8px 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

#section-weekly-schedule .search-box input:focus {
  outline: none;
  background-color: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  width: 300px;
}

#section-weekly-schedule .search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  font-size: 18px;
  pointer-events: none;
}

#section-weekly-schedule .btn-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
}

#section-weekly-schedule .btn-clear:hover {
  color: var(--text-main);
}

/* View switcher tabs */
#section-weekly-schedule .view-switch {
  display: flex;
  background-color: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

#section-weekly-schedule .btn-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

#section-weekly-schedule .btn-tab .material-symbols-outlined {
  font-size: 18px;
}

#section-weekly-schedule .btn-tab.active {
  background-color: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Button variants */
#section-weekly-schedule .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

#section-weekly-schedule .btn-primary {
  background-color: var(--primary);
  color: white;
}

#section-weekly-schedule .btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

#section-weekly-schedule .btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-main);
}

#section-weekly-schedule .btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-color-dark);
}

#section-weekly-schedule .btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
}

#section-weekly-schedule .btn-outline:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

#section-weekly-schedule .btn-icon {
  padding: 6px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
}

#section-weekly-schedule .btn-icon:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

#section-weekly-schedule .btn-danger {
  background-color: var(--status-canceled-bg);
  color: var(--status-canceled);
  border-color: var(--status-canceled-border);
}

#section-weekly-schedule .btn-danger:hover {
  background-color: var(--status-canceled);
  color: #fff;
}

/* ==========================================================================
   Toolbar & Stats Section
   ========================================================================== */
#section-weekly-schedule .toolbar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
  flex-wrap: wrap;
}

#section-weekly-schedule .stats-bar {
  display: flex;
  gap: 16px;
}

#section-weekly-schedule .stat-card {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background-color: var(--bg-surface);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

#section-weekly-schedule .stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

#section-weekly-schedule .stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#section-weekly-schedule .text-success { color: var(--status-confirmed); }
#section-weekly-schedule .text-warning { color: var(--status-pending); }
#section-weekly-schedule .text-info { color: var(--status-progress); }

#section-weekly-schedule .filters-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Legenda de Status e Cores */
#section-weekly-schedule .schedule-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  padding: 4px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

#section-weekly-schedule .legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  color: var(--text-muted);
}

#section-weekly-schedule .legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

#section-weekly-schedule .status-dot-confirmed { background-color: var(--status-confirmed); }
#section-weekly-schedule .status-dot-pending { background-color: var(--status-pending); }
#section-weekly-schedule .status-dot-progress { background-color: var(--status-progress); }
#section-weekly-schedule .status-dot-completed { background-color: var(--status-completed); }
#section-weekly-schedule .status-dot-blocked { background-color: rgba(239, 68, 68, 0.85); }

/* Slot Ativo / Disponível vs Bloqueado */
#section-weekly-schedule .grid-cell.slot-active {
  background-color: rgba(16, 185, 129, 0.05);
  border-left: 2px solid transparent;
}

#section-weekly-schedule .grid-cell.slot-active:hover {
  background-color: rgba(16, 185, 129, 0.12);
  border-left-color: #10b981;
}

#section-weekly-schedule .grid-cell.slot-blocked {
  background-color: rgba(239, 68, 68, 0.09);
  border-left: 2px solid rgba(239, 68, 68, 0.25);
  cursor: not-allowed;
}

#section-weekly-schedule .grid-cell.slot-past {
  background-color: rgba(0, 0, 0, 0.03);
  opacity: 0.55;
  cursor: not-allowed;
}

:root[data-theme="light"] #section-weekly-schedule .grid-cell.slot-past {
  background-color: rgba(0, 0, 0, 0.04);
  opacity: 0.6;
}

#section-weekly-schedule .filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#section-weekly-schedule .filter-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

#section-weekly-schedule .filter-group select {
  padding: 5px 10px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
}

#section-weekly-schedule .filter-group select:focus {
  outline: none;
  border-color: var(--primary);
}

#section-weekly-schedule .icon-small {
  font-size: 16px;
}

#section-weekly-schedule .blocked-cell-pattern {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  user-select: none;
}

#section-weekly-schedule .blocked-lock-icon {
  font-size: 16px;
  opacity: 0.65;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

#section-weekly-schedule .scheduler-container {
  flex: 1;
  overflow: auto;
  min-height: 0;
  position: relative;
  background-color: var(--bg-surface);
}

#section-weekly-schedule .scheduler-wrapper {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

#section-weekly-schedule .grid-table {
  display: grid;
  grid-template-columns: 70px repeat(var(--num-cols, 7), minmax(180px, 1fr));
  width: 100%;
  background-color: var(--bg-surface);
}

#section-weekly-schedule .grid-table.category-view {
  grid-template-columns: 70px repeat(var(--num-cols, 3), minmax(180px, 1fr));
}

/* Header Row (Days of the week) */
#section-weekly-schedule .grid-header-row {
  display: contents;
}

#section-weekly-schedule .time-corner-cell {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 40;
  background-color: var(--bg-surface);
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#section-weekly-schedule .day-header-cell {
  position: sticky;
  top: 0;
  z-index: 30;
  background-color: var(--bg-surface);
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#section-weekly-schedule .day-header-cell.is-today {
  background-color: var(--bg-surface);
  background-image: linear-gradient(rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0.14));
}

#section-weekly-schedule .day-name {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

#section-weekly-schedule .day-header-cell.is-today .day-name {
  color: var(--primary);
}

#section-weekly-schedule .day-number {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

#section-weekly-schedule .day-header-cell.is-today .day-number {
  background-color: var(--primary);
  color: white;
}

#section-weekly-schedule .day-count-tag {
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 500;
  background-color: var(--bg-subtle);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  margin-top: 2px;
}

/* Time Grid Body */
#section-weekly-schedule .time-slot-label {
  position: sticky;
  left: 0;
  z-index: 20;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px dashed var(--border-color);
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  min-height: 64px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#section-weekly-schedule .grid-cell {
  position: relative;
  min-height: 64px;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px dashed var(--border-color);
  background-color: var(--bg-surface);
  transition: background-color var(--transition-fast);
  padding: 4px;
  overflow: hidden;
  box-sizing: border-box;
}

#section-weekly-schedule .grid-cell:hover {
  background-color: var(--bg-subtle);
}

#section-weekly-schedule .grid-cell.drag-over {
  background-color: rgba(59, 130, 246, 0.15) !important;
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

/* Quick add slot trigger */
#section-weekly-schedule .slot-quick-add {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  font-size: 14px;
}

#section-weekly-schedule .grid-cell:not(.has-appts):hover .slot-quick-add {
  opacity: 1;
}

/* ==========================================================================
   Schedule Card Components (Event Items)
   ========================================================================== */
#section-weekly-schedule .schedule-card {
  position: relative;
  background-color: var(--bg-surface);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: grab;
  user-select: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

#section-weekly-schedule .schedule-card:active {
  cursor: grabbing;
}

#section-weekly-schedule .schedule-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  z-index: 4;
}

#section-weekly-schedule .schedule-card.dragging {
  opacity: 0.4;
  transform: scale(0.98);
}

/* Etiqueta colorida cobrindo todo o fundo do card */
#section-weekly-schedule .schedule-card {
  position: relative;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  cursor: grab;
  user-select: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

#section-weekly-schedule .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  flex-wrap: wrap;
}

#section-weekly-schedule .card-time {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

#section-weekly-schedule .card-time .material-symbols-outlined {
  font-size: 13px;
  color: var(--text-muted);
}

#section-weekly-schedule .card-category-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-block;
}

#section-weekly-schedule .cat-consulta { background-color: rgba(29, 78, 216, 0.12); color: #2563eb; }
#section-weekly-schedule .cat-retorno { background-color: rgba(16, 185, 129, 0.12); color: #059669; }
#section-weekly-schedule .cat-procedimento { background-color: rgba(147, 51, 234, 0.12); color: #7c3aed; }
#section-weekly-schedule .cat-reuniao { background-color: rgba(217, 119, 6, 0.12); color: #d97706; }
#section-weekly-schedule .cat-encaixe { background-color: rgba(219, 39, 119, 0.12); color: #db2777; }

#section-weekly-schedule .card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.25;
  margin-top: 1px;
  margin-bottom: 1px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

#section-weekly-schedule .card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  width: 100%;
}

#section-weekly-schedule .card-professional {
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#section-weekly-schedule .card-professional .material-symbols-outlined {
  font-size: 13px;
}

#section-weekly-schedule .card-status-badge {
  font-size: 0.64rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
}

#section-weekly-schedule .badge-confirmado { background-color: var(--status-confirmed-bg); color: var(--status-confirmed); border: 1px solid var(--status-confirmed-border); }
#section-weekly-schedule .badge-pendente { background-color: var(--status-pending-bg); color: var(--status-pending); border: 1px solid var(--status-pending-border); }
#section-weekly-schedule .badge-em-atendimento { background-color: var(--status-progress-bg); color: var(--status-progress); border: 1px solid var(--status-progress-border); }
#section-weekly-schedule .badge-concluido { background-color: var(--status-completed-bg); color: var(--status-completed); border: 1px solid var(--status-completed-border); }
#section-weekly-schedule .badge-cancelado { background-color: var(--status-canceled-bg); color: var(--status-canceled); border: 1px solid var(--status-canceled-border); }

/* Quick card actions on hover */
#section-weekly-schedule .card-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1px;
}

#section-weekly-schedule .schedule-card:hover .card-actions {
  opacity: 1;
}

#section-weekly-schedule .btn-card-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#section-weekly-schedule .btn-card-action:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

#section-weekly-schedule .btn-card-action.danger:hover {
  background-color: var(--status-canceled-bg);
  color: var(--status-canceled);
}

/* Empty slot placeholder indicator */
#section-weekly-schedule .empty-slot-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  font-size: 0.75rem;
  font-style: italic;
}

/* ==========================================================================
   Modals
   ========================================================================== */
#eventModal.modal-overlay,
.modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background-color: rgba(15, 23, 42, 0.75) !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
  transition: opacity var(--transition-fast) !important;
}

#eventModal.modal-overlay.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  z-index: -1 !important;
}

#eventModal.modal-overlay:not(.hidden) {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  z-index: 9999999 !important;
}

#eventModal .modal-content,
#section-weekly-schedule .modal-content {
  background-color: var(--dark-card) !important;
  border-radius: 16px !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2) !important;
  width: 100% !important;
  max-width: 580px !important;
  overflow: hidden !important;
  animation: modalSlideUp 0.25s ease !important;
  color: var(--text-primary) !important;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#eventModal .modal-header,
#section-weekly-schedule .modal-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 18px 24px !important;
  border-bottom: 1px solid var(--dark-border) !important;
  background-color: var(--dark-bg) !important;
}

#eventModal .modal-header h3,
#section-weekly-schedule .modal-header h3 {
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: var(--text-primary) !important;
  margin: 0 !important;
  font-family: var(--ws-font-family) !important;
}

#eventModal .btn-close,
#section-weekly-schedule .btn-close {
  background: transparent !important;
  border: none !important;
  color: #64748b !important;
  cursor: pointer !important;
  padding: 6px 10px !important;
  border-radius: 6px !important;
  display: flex !important;
  font-size: 1.25rem !important;
  font-weight: bold !important;
  line-height: 1 !important;
}

#eventModal .btn-close:hover,
#section-weekly-schedule .btn-close:hover {
  background-color: var(--bg-subtle) !important;
  color: var(--text-primary) !important;
}

#eventModal .modal-body,
#section-weekly-schedule .modal-body {
  padding: 24px !important;
  background-color: var(--dark-card) !important;
}

#eventModal .form-grid,
#section-weekly-schedule .form-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 16px !important;
}

#eventModal .col-span-2,
#section-weekly-schedule .col-span-2 {
  grid-column: span 2 !important;
}

#eventModal .form-group,
#section-weekly-schedule .form-group {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
}

#eventModal .form-group label,
#section-weekly-schedule .form-group label {
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  color: var(--text-muted) !important;
  font-family: var(--ws-font-family) !important;
}

#eventModal .form-group input,
#eventModal .form-group select,
#eventModal .form-group textarea,
#section-weekly-schedule .form-group input,
#section-weekly-schedule .form-group select,
#section-weekly-schedule .form-group textarea {
  padding: 10px 12px !important;
  border: 1.5px solid var(--dark-border) !important;
  border-radius: 8px !important;
  font-family: var(--ws-font-family) !important;
  font-size: 0.9rem !important;
  color: var(--text-primary) !important;
  background-color: var(--dark-bg) !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

#eventModal .form-group input:focus,
#eventModal .form-group select:focus,
#eventModal .form-group textarea:focus,
#section-weekly-schedule .form-group input:focus,
#section-weekly-schedule .form-group select:focus,
#section-weekly-schedule .form-group textarea:focus {
  outline: none !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

#eventModal .modal-footer,
#section-weekly-schedule .modal-footer {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding-top: 18px !important;
  margin-top: 10px !important;
  border-top: 1px solid var(--dark-border) !important;
}

#eventModal .footer-actions,
#section-weekly-schedule .footer-actions {
  display: flex !important;
  gap: 12px !important;
  margin-left: auto !important;
}

#eventModal .btn-danger {
  background-color: var(--status-canceled-bg) !important;
  color: var(--status-canceled) !important;
  border: 1px solid var(--status-canceled-border) !important;
  padding: 8px 16px !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
}

#eventModal .btn-danger:hover {
  background-color: var(--status-canceled) !important;
  color: #fff !important;
}

#eventModal .btn-secondary {
  background-color: var(--bg-subtle) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--dark-border) !important;
  padding: 8px 18px !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
}

#eventModal .btn-primary {
  background-color: #3b82f6 !important;
  color: #ffffff !important;
  border: none !important;
  padding: 8px 20px !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3) !important;
}

#eventModal .btn-primary:hover {
  background-color: #2563eb !important;
}

/* ==========================================================================
   Toasts Notifications
   ========================================================================== */
#section-weekly-schedule .toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

#section-weekly-schedule .toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background-color: var(--text-main);
  color: white;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#section-weekly-schedule .toast.success { background-color: #065f46; }
#section-weekly-schedule .toast.info { background-color: #0369a1; }
#section-weekly-schedule .toast.warning { background-color: #92400e; }
#section-weekly-schedule .toast.danger { background-color: #991b1b; }

/* Utility Helpers */
#section-weekly-schedule .hidden { display: none !important; }

/* Responsive Adjustments */
@media (max-width: 1024px) {
  #section-weekly-schedule .app-header { padding: 12px 16px; }
  #section-weekly-schedule .toolbar-section { padding: 10px 16px; }
  #section-weekly-schedule .search-box input { width: 180px; }
  #section-weekly-schedule .search-box input:focus { width: 220px; }
}

@media (max-width: 768px) {
  #btn-toggle-sidebar { display: none !important; }
  
  #section-weekly-schedule .app-container {
    height: calc(100vh - 65px);
    border-radius: 0;
  }

  #section-weekly-schedule .app-header {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #section-weekly-schedule .header-left, 
  #section-weekly-schedule .header-right {
    width: 100%;
    justify-content: space-between;
  }

  #section-weekly-schedule .search-box {
    flex: 1;
  }

  #section-weekly-schedule .search-box input {
    width: 100% !important;
  }

  #section-weekly-schedule .toolbar-section {
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #section-weekly-schedule .stats-bar {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  #section-weekly-schedule .stat-card {
    flex-shrink: 0;
  }

  #section-weekly-schedule .filters-bar {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  #section-weekly-schedule .schedule-legend {
    margin-left: 0;
    width: 100%;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 6px;
  }

  #section-weekly-schedule .scheduler-container {
    -webkit-overflow-scrolling: touch;
  }

  #section-weekly-schedule .form-grid { grid-template-columns: 1fr; }
  #section-weekly-schedule .col-span-2 { grid-column: span 1; }
}

/* ══════════════════════════════════════════════════════════
   MOBILE ENHANCEMENTS & LANDSCAPE (CELULAR DEITADO) SYSTEM
   ══════════════════════════════════════════════════════════ */

/* Mobile Days Switcher (1 Dia | 3 Dias | 7 Dias) */
.mobile-days-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-subtle, #f1f5f9);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 2px;
  margin-left: 6px;
}

.mobile-days-btn {
  background: transparent;
  border: none;
  padding: 4px 8px;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-days-btn.active {
  background: var(--bg-surface, #ffffff);
  color: var(--primary, #3b82f6);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  font-weight: 700;
}

/* Rotate / Landscape Mode Button */
.btn-rotate-mode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(59, 130, 246, 0.1) !important;
  color: #3b82f6 !important;
  border: 1px solid rgba(59, 130, 246, 0.3) !important;
  font-weight: 600 !important;
}

.btn-rotate-mode.active,
.btn-rotate-mode:hover {
  background: #3b82f6 !important;
  color: #ffffff !important;
}

/* Mobile Toolbar Collapsible Toggle Button */
.mobile-toolbar-toggle {
  display: none;
}

/* Floating Exit Landscape Button */
.btn-exit-landscape {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 9999999;
  background: #ef4444;
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════════
   FULLSCREEN LANDSCAPE MODE (.mobile-landscape-active)
   Rotaciona 90 graus na vertical ou expande na horizontal
   ══════════════════════════════════════════════════════════ */
#section-weekly-schedule.mobile-landscape-active {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 999999 !important;
  background-color: var(--bg-app, #0f172a) !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

/* Rotação 90° quando o celular estiver na VERTICAL (Portrait) */
@media (max-width: 900px) and (orientation: portrait) {
  #section-weekly-schedule.mobile-landscape-active {
    width: 100vh !important;
    height: 100vw !important;
    transform-origin: top left !important;
    transform: rotate(90deg) translateY(-100vw) !important;
  }

  #section-weekly-schedule.mobile-landscape-active .app-container {
    width: 100vh !important;
    height: 100vw !important;
    border-radius: 0 !important;
  }
}

/* Widescreen total quando o celular estiver na HORIZONAL (Landscape) */
@media (orientation: landscape) {
  #section-weekly-schedule.mobile-landscape-active {
    width: 100vw !important;
    height: 100vh !important;
    transform: none !important;
  }

  #section-weekly-schedule.mobile-landscape-active .app-container {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
  }
}

#section-weekly-schedule.mobile-landscape-active .toolbar-section {
  display: none !important; /* Esconde métricas no modo deitado para dar 100% de tela à grade */
}

#section-weekly-schedule.mobile-landscape-active .app-header {
  padding: 6px 14px !important;
  gap: 8px !important;
}

#section-weekly-schedule.mobile-landscape-active .logo-text,
#section-weekly-schedule.mobile-landscape-active .search-box,
#section-weekly-schedule.mobile-landscape-active .view-switch {
  display: none !important;
}

#section-weekly-schedule.mobile-landscape-active .grid-table {
  grid-template-columns: 55px repeat(var(--num-cols, 7), minmax(130px, 1fr)) !important;
  min-width: 100% !important;
}

/* ══════════════════════════════════════════════════════════
   AJUSTES VERTICAIS NO CELULAR (< 768px): MENU OCULTO POR PADRÃO
   ══════════════════════════════════════════════════════════ */
.btn-text-full { display: inline; }
.btn-text-mobile { display: none; }

@media (max-width: 768px) {
  .btn-text-full { display: none !important; }
  .btn-text-mobile { display: inline !important; font-size: 0.73rem !important; }

  #section-weekly-schedule .header-right {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    width: 100% !important;
    margin-top: 4px !important;
  }

  #section-weekly-schedule .header-right > .btn,
  #section-weekly-schedule .header-right > button {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    padding: 6px 8px !important;
    font-size: 0.73rem !important;
    justify-content: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #section-weekly-schedule .week-navigation {
    padding: 2px 4px !important;
    gap: 4px !important;
  }

  #section-weekly-schedule .scheduler-wrapper {
    min-width: 0 !important;
    width: 100% !important;
  }

  #section-weekly-schedule .grid-table {
    width: 100% !important;
  }

  /* Quando em 1 Dia no Celular: Ocupa 100% da tela sem rolagem horizontal */
  #section-weekly-schedule .grid-table[style*="--num-cols: 1"],
  #section-weekly-schedule .grid-table[style*="--num-cols:1"] {
    grid-template-columns: 50px 1fr !important;
    min-width: 100% !important;
  }

  /* Quando em 3 Dias no Celular: 3 colunas perfeitas adaptadas à tela */
  #section-weekly-schedule .grid-table[style*="--num-cols: 3"],
  #section-weekly-schedule .grid-table[style*="--num-cols:3"] {
    grid-template-columns: 45px repeat(3, 1fr) !important;
    min-width: 100% !important;
  }

  /* Quando em 7 Dias no Celular: 7 colunas com rolagem lateral fluida */
  #section-weekly-schedule .grid-table[style*="--num-cols: 7"],
  #section-weekly-schedule .grid-table[style*="--num-cols:7"] {
    grid-template-columns: 45px repeat(7, minmax(95px, 1fr)) !important;
    min-width: 710px !important;
  }

  /* Por padrão na vertical, o menu superior extra e toolbar ficam OCULTOS */
  #section-weekly-schedule .toolbar-section,
  #section-weekly-schedule .search-box,
  #section-weekly-schedule .view-switch {
    display: none !important;
  }

  /* Quando o usuário clica no botão "Opções ▾", exibe os menus */
  #section-weekly-schedule .app-container.mobile-menu-expanded .toolbar-section {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  #section-weekly-schedule .app-container.mobile-menu-expanded .search-box,
  #section-weekly-schedule .app-container.mobile-menu-expanded .view-switch {
    display: flex !important;
  }

  .mobile-toolbar-toggle {
    display: inline-flex !important;
  }

  .btn-rotate-mode .btn-text {
    display: inline !important;
    font-size: 0.72rem !important;
  }

  #section-weekly-schedule .time-slot-label {
    min-height: 48px;
    font-size: 0.78rem;
  }

  #section-weekly-schedule .grid-cell {
    min-height: 48px;
  }

  #section-weekly-schedule .slot-quick-add {
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
  }

  #section-weekly-schedule #currentPeriodLabel {
    font-size: 0.82rem !important;
    line-height: 1.2 !important;
    max-width: 100% !important;
    word-break: break-word !important;
  }

  #section-weekly-schedule .day-header-cell {
    padding: 6px 2px !important;
  }

  #section-weekly-schedule .day-name {
    font-size: 0.68rem !important;
    letter-spacing: 0 !important;
  }

  #section-weekly-schedule .day-number {
    font-size: 0.95rem !important;
    width: 24px !important;
    height: 24px !important;
  }

  #section-weekly-schedule .day-count-tag {
    font-size: 0.6rem !important;
    padding: 1px 4px !important;
    white-space: nowrap !important;
  }

  #section-weekly-schedule .schedule-card {
    padding: 4px 6px !important;
    gap: 2px !important;
  }

  #section-weekly-schedule .card-title {
    font-size: 0.75rem !important;
    line-height: 1.2 !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  #section-weekly-schedule .card-category-tag {
    font-size: 0.58rem !important;
    padding: 1px 4px !important;
  }

  #section-weekly-schedule .card-status-badge {
    font-size: 0.58rem !important;
    padding: 1px 4px !important;
  }
}

/* ══════════════════════════════════════════════════════════
   ANTI-TEXT CUTOFF & BOUNDARY PROTECTION (UNIVERSAL)
   ══════════════════════════════════════════════════════════ */
#section-weekly-schedule .schedule-card,
#section-weekly-schedule .grid-cell,
#section-weekly-schedule .day-header-cell,
#section-weekly-schedule .app-header,
#section-weekly-schedule .toolbar-section {
  box-sizing: border-box !important;
  max-width: 100% !important;
  overflow-wrap: break-word;
}

#section-weekly-schedule .card-header {
  max-width: 100% !important;
  flex-wrap: wrap !important;
  gap: 4px !important;
}

#section-weekly-schedule .card-meta {
  max-width: 100% !important;
  flex-wrap: wrap !important;
  gap: 4px !important;
}

#section-weekly-schedule .card-professional {
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
