/* Calendar App Styles - AgendaClínica
 * Uses design-system.css variables for consistent medical branding
 */

/* CSS Variables - Calendar specific, referencing design system */
.calendar-app {
  /* Base colors - Using medical design system 2026 (Teal/Emerald) */
  --cal-background: var(--bg-primary, #ffffff);
  --cal-foreground: var(--text-primary, #0f172a);
  --cal-card: var(--bg-primary, #ffffff);
  --cal-primary: var(--medical-primary, #0d9488);
  --cal-primary-foreground: var(--text-inverse, #ffffff);
  --cal-secondary: var(--bg-tertiary, #f1f5f9);
  --cal-muted: var(--bg-tertiary, #f1f5f9);
  --cal-muted-foreground: var(--text-tertiary, #64748b);
  --cal-border: var(--border-light, #e2e8f0);
  --cal-destructive: var(--error, #ef4444);
  --cal-radius: var(--radius-md, 8px);
  --cal-weekend: var(--bg-medical, #ccfbf1);
  --cal-grid: var(--border-light, #e2e8f0);
  --cal-today: var(--medical-primary, #0d9488);

  /* Appointment colors - Strong colors like Google Calendar */
  --apt-teal: #0d9488;
  --apt-teal-bg: #0d9488;
  --apt-teal-text: #ffffff;
  --apt-rose: #e11d48;
  --apt-rose-bg: #e11d48;
  --apt-rose-text: #ffffff;
  --apt-blue: #2563eb;
  --apt-blue-bg: #2563eb;
  --apt-blue-text: #ffffff;
  --apt-green: #16a34a;
  --apt-green-bg: #16a34a;
  --apt-green-text: #ffffff;
  --apt-orange: #ea580c;
  --apt-orange-bg: #ea580c;
  --apt-orange-text: #ffffff;
  --apt-purple: #9333ea;
  --apt-purple-bg: #9333ea;
  --apt-purple-text: #ffffff;
  --apt-cyan: #0891b2;
  --apt-cyan-bg: #0891b2;
  --apt-cyan-text: #ffffff;
}

/* Calendar App Layout */
.calendar-app {
  display: flex;
  flex: 1;
  /* Fill available space in parent */
  height: 100%;
  min-height: 0;
  /* Important: allows flex children to be scrollable */
  overflow: hidden;
  background: var(--cal-background);
}

/* Calendar Sidebar */
.calendar-sidebar {
  width: 260px;
  border-right: 1px solid var(--cal-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  flex-shrink: 0;
  background: var(--cal-background);
  position: relative;
}

.calendar-sidebar.hidden {
  display: none;
}

.sidebar-toggle-btn {
  position: absolute;
  left: 248px;
  top: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cal-background);
  border: 1px solid var(--cal-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle-btn:hover {
  background: var(--cal-muted);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* When sidebar is hidden, move button to left edge */
.calendar-app:has(.calendar-sidebar.hidden) .sidebar-toggle-btn {
  left: 8px;
}

.calendar-app:has(.calendar-sidebar.hidden) .sidebar-toggle-btn .toggle-icon-close {
  display: none;
}

.calendar-app:has(.calendar-sidebar.hidden) .sidebar-toggle-btn .toggle-icon-open {
  display: block;
}

/* Mini Calendar */
.mini-calendar {
  background: var(--cal-card);
}

.mini-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.mini-month-title {
  font-size: 14px;
  font-weight: 600;
}

.mini-nav-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--cal-muted-foreground);
}

.mini-nav-btn:hover {
  background: var(--cal-muted);
}

.mini-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.mini-calendar-day-name {
  font-size: 10px;
  font-weight: 500;
  color: var(--cal-muted-foreground);
  padding: 4px;
}

.mini-calendar-day {
  font-size: 12px;
  padding: 6px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  background: transparent;
}

.mini-calendar-day:hover {
  background: var(--cal-muted);
}

.mini-calendar-day.today {
  border: 2px solid var(--cal-today);
  color: var(--cal-today);
  font-weight: 600;
}

.mini-calendar-day.selected {
  background: var(--cal-primary);
  color: var(--cal-primary-foreground);
  border: none;
}

/* Cuando hoy está seleccionado, priorizar el estilo de selected */
.mini-calendar-day.today.selected {
  background: var(--cal-primary);
  color: var(--cal-primary-foreground);
  border: none;
}

.mini-calendar-day.outside {
  color: var(--cal-muted-foreground);
  opacity: 0.5;
}

/* Professionals Section */
.professionals-section {
  margin-top: 8px;
}

.professionals-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--cal-muted-foreground);
  margin-bottom: 12px;
}

.professionals-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.professional-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--cal-radius);
  cursor: pointer;
  transition: background 0.2s;
}

.professional-item:hover {
  background: var(--cal-muted);
}

/* Pending Invitation Styles */
.professional-item.pending-invitation {
  cursor: pointer;
  position: relative;
  background: var(--bg-secondary);
  border: 1px dashed var(--border-light);
  padding: 10px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.professional-item.pending-invitation:hover {
  background: rgba(var(--warning-rgb, 245, 158, 11), 0.08);
  border-color: var(--warning, #f59e0b);
}

.professional-item.pending-invitation .professional-color {
  opacity: 0.5;
}

.professional-item.pending-invitation .professional-color.pending {
  position: relative;
}

.professional-item.pending-invitation .professional-color.pending::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: var(--warning, #f59e0b);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.professional-item.pending-invitation .professional-name {
  color: var(--text-secondary);
  font-weight: 500;
}

.invitation-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--warning, #f59e0b);
  font-weight: 500;
  margin-top: 2px;
}

.invitation-status svg {
  animation: pulse-opacity 2s ease-in-out infinite;
}

@keyframes pulse-opacity {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }
}

.invitation-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s;
}

.professional-item.pending-invitation:hover .invitation-actions {
  opacity: 1;
}

.invitation-action-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}

.invitation-action-btn.resend {
  color: var(--cal-primary);
}

.invitation-action-btn.resend:hover {
  background: var(--medical-primary-bg);
  color: var(--medical-primary-dark);
}

.invitation-action-btn.cancel {
  color: var(--text-muted);
}

.invitation-action-btn.cancel:hover {
  background: var(--error-bg, #fef2f2);
  color: var(--error, #ef4444);
}

.professional-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--cal-primary);
}

/* Current Professional Card (for invited users) */
.current-professional-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--medical-primary-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--medical-primary);
}

.professional-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--text-inverse);
  flex-shrink: 0;
}

.professional-avatar.teal {
  background: var(--professional-teal);
}

.professional-avatar.rose {
  background: var(--professional-rose);
}

.professional-avatar.blue {
  background: var(--professional-blue);
}

.professional-avatar.green {
  background: var(--professional-green);
}

.professional-avatar.orange {
  background: var(--professional-orange);
}

.professional-avatar.purple {
  background: var(--professional-purple);
}

.professional-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.professional-details .professional-name {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.professional-details .professional-specialty {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.professional-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.professional-color.teal {
  background: var(--apt-teal);
}

.professional-color.rose {
  background: var(--apt-rose);
}

.professional-color.blue {
  background: var(--apt-blue);
}

.professional-color.green {
  background: var(--apt-green);
}

.professional-color.orange {
  background: var(--apt-orange);
}

.professional-color.purple {
  background: var(--apt-purple);
}

.professional-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.professional-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.professional-specialty {
  font-size: 11px;
  color: var(--cal-muted-foreground);
}

.no-professionals {
  font-size: 13px;
  color: var(--cal-muted-foreground);
  padding: 8px;
}

.no-professionals a {
  color: var(--cal-primary);
  text-decoration: none;
}

.add-professional-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: transparent;
  border: 1px dashed var(--cal-border);
  border-radius: var(--cal-radius);
  font-size: 13px;
  color: var(--cal-muted-foreground);
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
  transition: background 0.2s, border-color 0.2s;
}

.add-professional-btn:hover {
  background: var(--cal-muted);
  border-color: var(--cal-primary);
  color: var(--cal-foreground);
}

/* Main Calendar Area */
.calendar-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  /* Important: allows flex children to shrink and be scrollable */
  overflow: hidden;
}

/* Calendar Header */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--cal-border);
  gap: 16px;
  flex-wrap: wrap;
  background: var(--cal-background);
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--cal-border);
  border-radius: var(--cal-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  background: var(--cal-muted);
}

.nav-btn.arrow-btn {
  padding: 8px;
  width: 36px;
  height: 36px;
}

.nav-arrows {
  display: flex;
  gap: 4px;
}

.current-period {
  font-size: 18px;
  font-weight: 600;
  min-width: 200px;
  margin: 0;
}

.view-controls {
  display: flex;
  background: var(--cal-muted);
  border-radius: var(--cal-radius);
  padding: 4px;
}

.view-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: calc(var(--cal-radius) - 2px);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--cal-muted-foreground);
}

.view-btn:hover {
  color: var(--cal-foreground);
}

.view-btn.active {
  background: var(--cal-background);
  color: var(--cal-foreground);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Calendar Container - MUST have fixed height for scrollable time grid */
.calendar-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Important: allows flex child to shrink below content size */
  /* Fallback fixed height if flex doesn't work properly */
  height: calc(100vh - 180px);
  /* 180px = header + calendar header + margins */
}

/* Week/Day View */
.week-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  /* Important: allows flex child to shrink below content size */
  overflow: hidden;
}

.week-header {
  display: grid;
  border-bottom: 1px solid var(--cal-border);
  flex-shrink: 0;
  background: var(--cal-background);
}

.week-header-cell {
  padding: 12px 8px;
  text-align: center;
  border-left: 1px solid var(--cal-border);
}

.week-header-cell:first-child {
  border-left: none;
}

.week-header-cell.weekend {
  background: var(--cal-weekend);
}

.day-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--cal-muted-foreground);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.day-number {
  font-size: 24px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.day-number.today {
  background: var(--cal-today);
  color: var(--cal-primary-foreground);
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

/* Time Grid Wrapper - SCROLLABLE CONTAINER (like Google Calendar)
   This is the key element: fixed/constrained height with overflow-y: auto
   The inner .time-grid has the full 24-hour height (1536px) */
.time-grid-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  /* Important: allows this flex child to be scrollable */
  scrollbar-gutter: stable;
  position: relative;
  /* Ensure scroll is possible - max height prevents infinite expansion */
  max-height: 100%;
}

/* Time Grid - Full 24-hour content (creates scrollable area) */
.time-grid {
  position: relative;
  height: 1536px;
  /* 24 hours * 64px per hour */
  min-height: 1536px;
  /* Force this height - prevents collapse */
}

.time-row {
  display: grid;
  height: 64px;
}

.time-label {
  padding-right: 8px;
  text-align: right;
}

.time-label span {
  font-size: 11px;
  color: var(--cal-muted-foreground);
  transform: translateY(-8px);
  display: block;
}

.time-cell {
  position: relative;
  border-left: 1px solid var(--cal-grid);
  border-top: 1px solid var(--cal-grid);
  cursor: crosshair;
  transition: background 0.2s;
}

.time-cell:hover {
  background: rgba(59, 130, 246, 0.05);
}

.time-cell.weekend {
  background: var(--cal-weekend);
}

.time-cell.weekend:hover {
  background: rgba(250, 250, 250, 0.9);
}

.time-cell.drag-over {
  background: rgba(59, 130, 246, 0.15) !important;
  box-shadow: inset 0 0 0 2px var(--cal-primary);
}

/* Legacy support */
.week-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  position: relative;
}

.day-column {
  border-left: 1px solid var(--cal-grid);
  position: relative;
}

.day-column.weekend {
  background: var(--cal-weekend);
}

.time-slot {
  height: 64px;
  border-top: 1px solid var(--cal-grid);
  cursor: crosshair;
  transition: background 0.2s;
}

.time-slot:hover {
  background: rgba(59, 130, 246, 0.05);
}

.time-slot.drag-over {
  background: rgba(59, 130, 246, 0.15);
  box-shadow: inset 0 0 0 2px var(--cal-primary);
}

/* Appointments */
.appointment {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 6px;
  padding: 4px 8px;
  border-left: 3px solid;
  cursor: grab;
  overflow: hidden;
  transition: box-shadow 0.2s, opacity 0.2s;
  z-index: 10;
  user-select: none;
}

.appointment:active {
  cursor: grabbing;
}

.appointment.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.appointment.resizing {
  opacity: 0.8;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.appointment:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.appointment.teal {
  background: var(--apt-teal-bg);
  border-left-color: rgba(0, 0, 0, 0.15);
  color: var(--apt-teal-text);
}

.appointment.rose {
  background: var(--apt-rose-bg);
  border-left-color: rgba(0, 0, 0, 0.15);
  color: var(--apt-rose-text);
}

.appointment.blue {
  background: var(--apt-blue-bg);
  border-left-color: rgba(0, 0, 0, 0.15);
  color: var(--apt-blue-text);
}

.appointment.green {
  background: var(--apt-green-bg);
  border-left-color: rgba(0, 0, 0, 0.15);
  color: var(--apt-green-text);
}

.appointment.orange {
  background: var(--apt-orange-bg);
  border-left-color: rgba(0, 0, 0, 0.15);
  color: var(--apt-orange-text);
}

.appointment.purple {
  background: var(--apt-purple-bg);
  border-left-color: rgba(0, 0, 0, 0.15);
  color: var(--apt-purple-text);
}

.appointment-title {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appointment-time {
  font-size: 10px;
  opacity: 0.9;
}

.appointment-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  background: transparent;
  border-radius: 0 0 6px 6px;
  transition: background 0.2s;
}

.appointment:hover .appointment-resize-handle {
  background: rgba(0, 0, 0, 0.1);
}

/* Blocked Hours on Calendar */
.blocked-hour {
  position: absolute;
  left: 2px;
  right: 2px;
  background: repeating-linear-gradient(
    -45deg,
    rgba(100, 116, 139, 0.08),
    rgba(100, 116, 139, 0.08) 4px,
    rgba(100, 116, 139, 0.16) 4px,
    rgba(100, 116, 139, 0.16) 8px
  );
  border-left: 3px solid var(--text-muted);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 1;
  overflow: hidden;
  transition: all 0.15s ease;
}

.blocked-hour:hover {
  background: repeating-linear-gradient(
    -45deg,
    rgba(100, 116, 139, 0.12),
    rgba(100, 116, 139, 0.12) 4px,
    rgba(100, 116, 139, 0.22) 4px,
    rgba(100, 116, 139, 0.22) 8px
  );
  border-left-color: var(--text-primary);
}

.blocked-hour-content {
  background: rgba(215, 222, 230, 0.8);
  padding: 3px 8px;
  line-height: 1.3;
}

.blocked-hour-title {
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.blocked-hour-reason {
  font-size: 10px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

.blocked-hour-time {
  font-size: 10px;
  opacity: 0.6;
}

/* Recurrence indicator on calendar items */
.appointment.recurring,
.blocked-hour.recurring {
  position: relative;
}

.appointment.recurring::after,
.blocked-hour.recurring::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 4px;
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='17 1 21 5 17 9'%3E%3C/polyline%3E%3Cpath d='M3 11V9a4 4 0 0 1 4-4h14'%3E%3C/path%3E%3Cpolyline points='7 23 3 19 7 15'%3E%3C/polyline%3E%3Cpath d='M21 13v2a4 4 0 0 1-4 4H3'%3E%3C/path%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.6;
}

.blocked-hour.recurring::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='17 1 21 5 17 9'%3E%3C/polyline%3E%3Cpath d='M3 11V9a4 4 0 0 1 4-4h14'%3E%3C/path%3E%3Cpolyline points='7 23 3 19 7 15'%3E%3C/polyline%3E%3Cpath d='M21 13v2a4 4 0 0 1-4 4H3'%3E%3C/path%3E%3C/svg%3E");
}

/* Compact options bar */
.form-options-bar {
  display: flex;
  gap: 8px;
  padding: 4px 0 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.form-option-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.form-option-chip:hover {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}

.form-option-chip:has(input:checked),
.form-option-chip.active {
  background: color-mix(in srgb, var(--modal-accent, var(--cal-primary)) 12%, transparent);
  border-color: var(--modal-accent, var(--cal-primary));
  color: var(--modal-accent, var(--cal-primary));
}

.form-option-chip input {
  display: none;
}

.form-option-chip svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.notes-expandable {
  margin-bottom: 8px;
  padding: 10px 12px;
  background: var(--bg-tertiary, #f8f8f8);
  border-radius: 10px;
}

.notes-expandable .form-textarea-flat {
  background: transparent;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  padding: 4px 0;
  resize: none;
}

/* Recurrence UI - inline toggle approach (legacy, kept for block form) */
.recurrence-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.recurrence-toggle-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.recurrence-toggle input {
  display: none;
}

.recurrence-switch {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border-light);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.recurrence-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.recurrence-toggle input:checked ~ .recurrence-switch {
  background: var(--modal-accent, var(--cal-primary));
}

.recurrence-toggle input:checked ~ .recurrence-switch::after {
  transform: translateX(18px);
}

.recurrence-config {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-tertiary, #f8f8f8);
  border-radius: 10px;
}

.recurrence-config.hidden {
  display: none;
}

.recurrence-days-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recurrence-days {
  display: flex;
  gap: 4px;
}

.day-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border-light);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
  user-select: none;
  background: var(--bg-primary, white);
}

.day-chip:hover {
  border-color: var(--modal-accent, var(--cal-primary));
  color: var(--modal-accent, var(--cal-primary));
}

.day-chip:has(input:checked) {
  background: var(--modal-accent, var(--cal-primary));
  color: white;
  border-color: transparent;
}

.day-chip input {
  display: none;
}

.recurrence-end-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.recurrence-end-label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.recurrence-end-input {
  flex: 1;
  max-width: 150px;
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-primary, white);
  color: var(--text-primary);
}

/* Recurring Delete Dialog */
.recurrence-delete-dialog {
  position: absolute;
  inset: 0;
  background: var(--modal-bg, white);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
}

.recurrence-delete-dialog.hidden {
  display: none;
}

.recurrence-delete-content {
  padding: 24px;
  text-align: center;
  width: 100%;
}

.recurrence-delete-content h4 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.recurrence-delete-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.recurrence-delete-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.recurrence-delete-options .btn {
  width: 100%;
  justify-content: center;
}

.recurrence-delete-options .btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.recurrence-delete-options .btn-outline:hover {
  background: var(--bg-hover, #f5f5f5);
  border-color: var(--border-default);
}

.recurrence-delete-cancel {
  width: 100%;
}

/* Current Time Indicator - only on today's column (like Google Calendar) */
.current-time-indicator {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  height: 2px;
}

.current-time-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cal-destructive);
  top: 50%;
  z-index: 21;
}

.current-time-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--cal-destructive);
}

/* Drag Ghost */
.drag-ghost {
  position: fixed;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 9999;
}

.drag-ghost.teal {
  background: var(--apt-teal-bg);
  color: var(--apt-teal-text);
  border-left: 3px solid rgba(0, 0, 0, 0.2);
}

.drag-ghost.rose {
  background: var(--apt-rose-bg);
  color: var(--apt-rose-text);
  border-left: 3px solid rgba(0, 0, 0, 0.2);
}

.drag-ghost.blue {
  background: var(--apt-blue-bg);
  color: var(--apt-blue-text);
  border-left: 3px solid rgba(0, 0, 0, 0.2);
}

.drag-ghost.green {
  background: var(--apt-green-bg);
  color: var(--apt-green-text);
  border-left: 3px solid rgba(0, 0, 0, 0.2);
}

.drag-ghost.orange {
  background: var(--apt-orange-bg);
  color: var(--apt-orange-text);
  border-left: 3px solid rgba(0, 0, 0, 0.2);
}

.drag-ghost.purple {
  background: var(--apt-purple-bg);
  color: var(--apt-purple-text);
  border-left: 3px solid rgba(0, 0, 0, 0.2);
}

/* Selection Preview */
.selection-preview {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  background: rgba(59, 130, 246, 0.2);
  border: 2px dashed var(--cal-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.selection-preview span {
  background: var(--cal-card);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--cal-foreground);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

/* Drag Preview */
.selection-preview.drag-preview {
  background: rgba(59, 130, 246, 0.4);
  border: 2px solid var(--cal-primary);
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 4px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.selection-preview.drag-preview.teal {
  background: rgba(13, 148, 136, 0.4);
  border-color: #0d9488;
}

.selection-preview.drag-preview.rose {
  background: rgba(225, 29, 72, 0.4);
  border-color: #e11d48;
}

.selection-preview.drag-preview.blue {
  background: rgba(37, 99, 235, 0.4);
  border-color: #2563eb;
}

.selection-preview.drag-preview.green {
  background: rgba(22, 163, 74, 0.4);
  border-color: #16a34a;
}

.selection-preview.drag-preview.orange {
  background: rgba(234, 88, 12, 0.4);
  border-color: #ea580c;
}

.selection-preview.drag-preview.purple {
  background: rgba(147, 51, 234, 0.4);
  border-color: #9333ea;
}

.selection-preview.drag-preview .appointment-title {
  font-size: 12px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.selection-preview.drag-preview .appointment-time {
  font-size: 11px;
  font-weight: 500;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Month View */
.month-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.month-view.hidden {
  display: none;
}

.month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--cal-border);
}

.month-header-cell {
  padding: 12px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--cal-muted-foreground);
  text-transform: uppercase;
}

.month-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
}

.month-cell {
  border-right: 1px solid var(--cal-border);
  border-bottom: 1px solid var(--cal-border);
  padding: 4px;
  min-height: 100px;
  cursor: pointer;
  transition: background 0.2s;
}

.month-cell:hover {
  background: var(--cal-muted);
}

.month-cell.weekend {
  background: var(--cal-weekend);
}

.month-cell.outside {
  opacity: 0.4;
}

.month-cell-header {
  display: flex;
  justify-content: flex-start;
  padding: 4px;
}

.month-day-number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  border-radius: 50%;
}

.month-day-number.today {
  background: var(--cal-today);
  color: var(--cal-primary-foreground);
}

.month-appointments {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.month-appointment {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.month-appointment.teal {
  background: var(--apt-teal-bg);
  color: var(--apt-teal-text);
}

.month-appointment.rose {
  background: var(--apt-rose-bg);
  color: var(--apt-rose-text);
}

.month-appointment.blue {
  background: var(--apt-blue-bg);
  color: var(--apt-blue-text);
}

.month-appointment.green {
  background: var(--apt-green-bg);
  color: var(--apt-green-text);
}

.month-appointment.orange {
  background: var(--apt-orange-bg);
  color: var(--apt-orange-text);
}

.month-appointment.purple {
  background: var(--apt-purple-bg);
  color: var(--apt-purple-text);
}

.month-more {
  font-size: 11px;
  color: var(--cal-muted-foreground);
  padding: 2px 6px;
}

/* Agenda View */
.agenda-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--cal-background);
}

.agenda-view.hidden {
  display: none;
}

.agenda-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--cal-border);
}

.agenda-date-info {
  display: flex;
  flex-direction: column;
}

.agenda-date-detail {
  font-size: 12px;
  color: var(--cal-muted-foreground);
}

.agenda-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.agenda-day {
  margin-bottom: 24px;
}

.agenda-day-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.agenda-date-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--cal-secondary);
}

.agenda-date-badge.today {
  background: var(--cal-today);
  color: var(--cal-primary-foreground);
}

.agenda-day-name {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

.agenda-day-number {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.agenda-date-label {
  font-size: 14px;
  font-weight: 500;
}

.agenda-appointments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 60px;
}

.agenda-appointment {
  background: var(--cal-card);
  border-radius: 8px;
  padding: 12px;
  border-left: 4px solid;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
}

.agenda-appointment:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.agenda-appointment.teal {
  border-left-color: var(--apt-teal);
}

.agenda-appointment.rose {
  border-left-color: var(--apt-rose);
}

.agenda-appointment.blue {
  border-left-color: var(--apt-blue);
}

.agenda-appointment.green {
  border-left-color: var(--apt-green);
}

.agenda-appointment.orange {
  border-left-color: var(--apt-orange);
}

.agenda-appointment.purple {
  border-left-color: var(--apt-purple);
}

.agenda-appointment.agenda-blocked {
  border-left-color: var(--text-muted);
  background: repeating-linear-gradient(
    -45deg,
    rgba(100, 116, 139, 0.04),
    rgba(100, 116, 139, 0.04) 4px,
    rgba(100, 116, 139, 0.1) 4px,
    rgba(100, 116, 139, 0.1) 8px
  );
}

.agenda-apt-time {
  font-size: 12px;
  color: var(--cal-muted-foreground);
  margin-bottom: 4px;
}

.agenda-apt-title {
  font-size: 14px;
  font-weight: 500;
}

.agenda-apt-doctor {
  font-size: 12px;
  color: var(--cal-muted-foreground);
  margin-top: 4px;
}

.agenda-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--cal-muted-foreground);
}

/* FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cal-primary);
  color: var(--cal-primary-foreground);
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.2s;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--cal-card);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
}

.modal.modal-sm {
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
  gap: var(--space-4);
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 1;
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition-base);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.modal-form .form-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.modal-form .form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: 0;
}

.modal-form .form-group input,
.modal-form .form-group select,
.modal-form .form-group textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--transition-base);
}

.modal-form .form-group input:focus,
.modal-form .form-group select:focus,
.modal-form .form-group textarea:focus {
  outline: none;
  border-color: var(--medical-primary);
  box-shadow: var(--shadow-focus);
}

.modal-form .form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.modal-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* Google Calendar Style Modal */
.modal {
  border-radius: 12px;
  background: var(--bg-primary);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15);
  border: none;
  overflow-y: auto;
  overflow-x: hidden;
  max-width: 500px;
  max-height: 90vh;
}

.modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--modal-accent, var(--cal-primary));
  border-radius: 4px 4px 0 0;
  opacity: 0.8;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.modal-header-left {
  display: flex;
  align-items: center;
  flex: 1;
}

.duration-display {
  margin-left: var(--space-3);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

.duration-display span {
  color: var(--modal-accent, var(--cal-primary));
  font-weight: 600;
}

/* Segmented Control Tabs */
.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 24px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
}

.modal-tabs.hidden {
  display: none;
}

.modal-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

.modal-tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Modal Panels */
.modal-panel.hidden {
  display: none;
}

.modal-form {
  padding: 16px 24px 24px;
}

.form-row-group {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: 14px;
  min-height: 44px;
}

/* Special alignment for notes/textarea rows */
.form-row-group:has(textarea) {
  align-items: flex-start;
}

.form-row-icon {
  width: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
  height: 24px;
  margin-top: 10px;
  /* Offset to align with first line of content */
}

/* When the content is a simple input/select, center the icon more */
.form-row-group:not(:has(textarea)) .form-row-icon {
  margin-top: 0;
  align-self: center;
}

.form-row-group:focus-within .form-row-icon {
  color: var(--modal-accent, var(--cal-primary));
}

.form-row-content {
  flex: 1;
}

/* Flat Inputs (no heavy borders) */
.form-input-flat,
.form-select-flat,
.form-textarea-flat,
.form-input-inline {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--border-light);
  background: transparent;
  font-size: 15px;
  color: var(--text-primary);
  transition: all 0.2s;
  border-radius: 0;
}

.form-input-flat:hover,
.form-select-flat:hover,
.form-textarea-flat:hover,
.form-input-inline:hover {
  border-bottom-color: var(--cal-primary);
}

.form-input-flat:focus,
.form-select-flat:focus,
.form-textarea-flat:focus,
.form-input-inline:focus {
  outline: none;
  border-bottom: 2px solid var(--cal-primary);
  margin-bottom: -1px;
}

/* Specific styling for grouped date/time */
.datetime-row-flat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.date-selector-flat .form-input-inline {
  width: auto;
  min-width: 120px;
}

.time-selectors-flat {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  padding: 2px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.time-selectors-flat select {
  border: none !important;
  background: transparent !important;
  padding: 4px !important;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-primary);
  height: 32px !important;
  font-weight: 500;
}

.modal-footer {
  padding: 0 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Notes Collapsible */
.notes-collapsible {
  margin-bottom: 0;
}

.notes-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  font-family: var(--font-primary);
  transition: color var(--transition-base);
  width: 100%;
  text-align: left;
}

.notes-toggle:hover {
  color: var(--medical-primary);
}

.notes-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-base);
  color: var(--text-muted);
}

.notes-toggle[aria-expanded="true"] .notes-toggle-icon {
  transform: rotate(180deg);
  color: var(--medical-primary);
}

.notes-content {
  margin-top: var(--space-3);
  animation: slideDown 0.2s ease-out;
}

.notes-content.hidden {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.notes-content textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--transition-base);
  resize: vertical;
  min-height: 80px;
}

.notes-content textarea:focus {
  outline: none;
  border-color: var(--medical-primary);
  box-shadow: var(--shadow-focus);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-light);
}

.modal-actions .btn-secondary {
  margin-left: auto;
}


/* Invite Info Banner */

/* Invite Info Banner */
.invite-info-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--medical-primary-bg);
  border: 1px solid var(--medical-primary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  color: var(--medical-primary-dark);
  font-size: var(--text-sm);
}

.invite-info-banner svg {
  flex-shrink: 0;
  color: var(--medical-primary);
}

/* Color Options */
.color-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-option {
  cursor: pointer;
}

.color-option input {
  display: none;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: block;
  border: 3px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
}

.color-swatch.teal {
  background: var(--apt-teal);
}

.color-swatch.rose {
  background: var(--apt-rose);
}

.color-swatch.blue {
  background: var(--apt-blue);
}

.color-swatch.green {
  background: var(--apt-green);
}

.color-swatch.orange {
  background: var(--apt-orange);
}

.color-swatch.purple {
  background: var(--apt-purple);
}

.color-option input:checked+.color-swatch {
  border-color: var(--cal-foreground);
  transform: scale(1.1);
}

/* Permission Options - Compact Toggle Switches */
.permissions-compact {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  min-width: 36px;
  background: var(--border-default);
  border-radius: 20px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--medical-primary);
}

.toggle-switch input:checked+.toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s;
  white-space: nowrap;
}

.toggle-switch input:checked~.toggle-label {
  color: var(--medical-primary-dark);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--cal-foreground);
  color: var(--cal-background);
  padding: 12px 24px;
  border-radius: var(--cal-radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 2000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.hidden {
  display: none;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Customer Autocomplete Styles */
.customer-autocomplete-container {
  position: relative;
}

.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  margin-top: var(--space-1);
}

.autocomplete-item {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-base);
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border-light);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--bg-hover);
}

.autocomplete-item-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.autocomplete-item-phone {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.autocomplete-create {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--medical-primary);
  font-weight: var(--font-medium);
  background: var(--medical-primary-bg);
  border-top: 1px solid var(--border-light);
}

.autocomplete-create:hover {
  background: var(--medical-primary-bg-subtle);
}

.autocomplete-create-icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--medical-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
}

.autocomplete-no-results {
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* New Customer Badge */
.new-customer-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--medical-accent-bg);
  color: var(--medical-accent);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  margin-top: var(--space-2);
  width: fit-content;
}

.badge-icon {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
}

/* New Customer Fields */
.new-customer-fields {
  background: var(--medical-primary-bg);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-top: var(--space-4);
  border: 1px solid var(--medical-primary);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.new-customer-fields .form-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.new-customer-fields label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.new-customer-fields label .required {
  color: var(--error);
  margin-left: var(--space-1);
}

.new-customer-fields input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--transition-base);
}

.new-customer-fields input:focus {
  outline: none;
  border-color: var(--medical-primary);
  box-shadow: var(--shadow-focus);
}

/* Onboarding Modal */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  pointer-events: auto;
}

.onboarding-overlay.hidden {
  display: none;
}

.onboarding-modal {
  background: var(--cal-card);
  border-radius: calc(var(--cal-radius) * 2);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  position: relative;
  z-index: 2001;
}

.onboarding-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--cal-primary), #8b5cf6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: white;
}

.onboarding-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--cal-foreground);
}

.onboarding-description {
  font-size: 15px;
  color: var(--cal-muted-foreground);
  line-height: 1.6;
  margin-bottom: 24px;
}

.onboarding-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--cal-primary);
  color: var(--cal-primary-foreground);
  border: none;
  border-radius: var(--cal-radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.onboarding-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
  .calendar-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }

  .calendar-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle-btn {
    display: none;
  }

  /* Calendar header: compact on mobile */
  .calendar-header {
    padding: 8px 12px;
    gap: 8px;
  }

  .calendar-nav {
    gap: 6px;
  }

  .nav-btn.today-btn {
    padding: 6px 12px;
    font-size: 13px;
  }

  .nav-btn.arrow-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
  }

  .current-period {
    font-size: 14px;
    min-width: auto;
  }

  .view-controls {
    display: none;
  }

  .day-number {
    font-size: 18px;
  }

  .day-number.today {
    width: 32px;
    height: 32px;
  }

  .fab {
    display: flex;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 52px;
    height: 52px;
  }

  .week-header {
    grid-template-columns: 50px repeat(7, 1fr);
  }

  .time-column {
    width: 50px;
  }

  /* Agenda view: tighter spacing on mobile */
  .agenda-list {
    padding: 12px;
  }

  .agenda-day {
    margin-bottom: 16px;
  }

  .agenda-appointments {
    margin-left: 52px;
    gap: 6px;
  }

  .agenda-appointment {
    padding: 10px;
  }

  .agenda-date-badge {
    width: 42px;
    height: 42px;
  }

  .agenda-day-number {
    font-size: 17px;
  }

  /* Modal tabs mobile */
  .modal-tabs {
    padding: 8px 16px;
  }

  .modal-tab {
    padding: 8px 12px;
    font-size: 13px;
    gap: 6px;
  }

  /* Recurrence mobile */
  .day-chip {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .recurrence-config {
    padding: 10px;
  }

  .recurrence-delete-content {
    padding: 16px;
  }

  /* Modal fixes for mobile - ensure scrolling works with dynamic content */
  .modal-overlay {
    align-items: flex-start;
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal {
    max-height: none;
    min-height: auto;
    margin: 0 auto;
    overflow-y: visible;
    padding: var(--space-4);
    border-radius: var(--radius-lg);
  }

  .modal-header {
    margin-bottom: var(--space-3);
  }

  .modal-title {
    font-size: 16px;
  }

  .form-row-group {
    gap: 8px;
  }

  .form-row-icon svg {
    width: 18px;
    height: 18px;
  }

  .modal-form {
    overflow-y: visible;
  }

  /* Ensure new customer fields are scrollable */
  .new-customer-fields {
    overflow-y: visible;
  }

  /* Modal footer: full-width buttons on mobile */
  .modal-footer {
    position: relative;
    z-index: 10;
    gap: 8px;
  }

  .modal-footer .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
  }
}