.appointment-calendar {
  max-width: 1500px;
  padding: 1.5rem;
}

.calendar-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.calendar-eyebrow {
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.calendar-heading h1 {
  margin: 0.2rem 0 0;
  color: #0f172a;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
}

.calendar-heading p { margin: 0.25rem 0 0; color: #64748b; }
.calendar-view-switch { display: flex; gap: 0.5rem; }
.calendar-view-switch .btn { display: inline-flex; align-items: center; gap: 0.45rem; }

.calendar-panel {
  padding: 1.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.07);
}

.calendar-navigation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.calendar-navigation > :last-child { justify-self: end; }
.calendar-navigation .btn { display: inline-flex; align-items: center; gap: 0.4rem; width: fit-content; }
.calendar-today { border: 1px solid #e2e8f0; }

.calendar-grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.calendar-grid th { padding: 0.8rem; border-bottom: 1px solid #dbe4ef; color: #64748b; font-size: 0.75rem; letter-spacing: 0.08em; text-align: center; }
.calendar-cell { height: 135px; padding: 0.55rem; border-right: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.calendar-cell:first-child { border-left: 1px solid #e2e8f0; }
.calendar-cell.is-other-month { background: #f8fafc; opacity: 0.62; }

.calendar-date { display: flex; align-items: center; justify-content: space-between; color: #0f172a; font-weight: 700; text-decoration: none; }
.calendar-date i { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; color: #2563eb; opacity: 0; transition: 0.2s ease; }
.calendar-cell:hover .calendar-date i { background: #dbeafe; opacity: 1; }
.calendar-events { display: grid; gap: 0.3rem; margin-top: 0.45rem; }
.calendar-event { display: flex; gap: 0.35rem; min-width: 0; padding: 0.38rem 0.45rem; border-left: 3px solid #2563eb; border-radius: 0.35rem; background: #eff6ff; color: #1e3a8a; font-size: 0.76rem; text-decoration: none; }
.calendar-event time { flex: 0 0 auto; font-weight: 700; }
.calendar-event span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-mobile { display: none; }

.daily-schedule { margin: 0; border-color: #e2e8f0; }
.daily-schedule thead th { padding: 0.85rem; background: #f8fafc; color: #334155; }
.daily-schedule tbody td { border-color: #e2e8f0; }
.daily-add { opacity: 0.35; transition: opacity 0.2s ease; }
.daily-schedule tr:hover .daily-add { opacity: 1; }

/* Panel para crear y editar citas */
.appointment-modal { position: fixed; inset: 0; z-index: 1060; }
.appointment-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.58); backdrop-filter: blur(3px); animation: appointment-fade-in 0.2s ease-out; }
.appointment-modal-panel { position: absolute; top: 0; right: 0; display: flex; width: min(520px, 100%); height: 100dvh; flex-direction: column; overflow: hidden; background: #fff; box-shadow: -20px 0 55px rgba(15, 23, 42, 0.2); animation: appointment-slide-in 0.25s ease-out; }
.appointment-modal-panel.is-closing { animation: appointment-slide-out 0.22s ease-in forwards; }
.appointment-modal.is-closing .appointment-modal-backdrop { opacity: 0; transition: opacity 0.22s ease-in; }

.appointment-form { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.appointment-form-header { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.9rem; padding: 1.35rem 1.5rem; border-bottom: 1px solid #e2e8f0; background: linear-gradient(135deg, #eff6ff, #fff); }
.appointment-form-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 15px; background: #2563eb; color: #fff; font-size: 1.35rem; box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25); }
.appointment-form-header span { color: #2563eb; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.appointment-form-header h2 { margin: 0.1rem 0 0; color: #0f172a; font-size: 1.25rem; font-weight: 700; }
.appointment-form-header p { margin: 0.2rem 0 0; color: #64748b; font-size: 0.82rem; }
.appointment-modal-close { display: grid; width: 38px; height: 38px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: #fff; color: #475569; box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08); }
.appointment-modal-close:hover { background: #fee2e2; color: #dc2626; }

.appointment-form-body { flex: 1; overflow-y: auto; padding: 1.35rem 1.5rem; scrollbar-gutter: stable; }
.appointment-field { margin-bottom: 1.15rem; }
.appointment-field .form-label { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.45rem; color: #334155; font-size: 0.83rem; font-weight: 700; }
.appointment-field .form-label i { color: #2563eb; }
.appointment-field .form-control,
.appointment-field .form-select { min-height: 46px; border-color: #cbd5e1; border-radius: 0.7rem; background-color: #fff; }
.appointment-field textarea.form-control { min-height: 105px; resize: vertical; }
.appointment-field .form-control:focus,
.appointment-field .form-select:focus { border-color: #60a5fa; box-shadow: 0 0 0 0.22rem rgba(37, 99, 235, 0.12); }
.appointment-readonly { gap: 0.35rem; background: #f8fafc !important; color: #334155; }
.appointment-datetime-grid { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 0.9rem; }
.appointment-duration { display: flex; align-items: center; gap: 0.4rem; margin: -0.55rem 0 1.15rem; padding: 0.55rem 0.7rem; border-radius: 0.6rem; background: #f1f5f9; color: #64748b; font-size: 0.78rem; }

.appointment-form-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.65rem; padding: 1rem 1.5rem; border-top: 1px solid #e2e8f0; background: #fff; box-shadow: 0 -8px 25px rgba(15, 23, 42, 0.04); }
.appointment-form-footer .btn { min-height: 43px; padding-inline: 1.15rem; border-radius: 0.7rem; font-weight: 600; }
.appointment-history { order: -1; margin-right: auto; }

@keyframes appointment-fade-in { from { opacity: 0; } }
@keyframes appointment-slide-in { from { transform: translateX(100%); } }
@keyframes appointment-slide-out { to { transform: translateX(100%); } }

@media (max-width: 768px) {
  .appointment-calendar { padding: 0; }
  .calendar-heading { align-items: stretch; flex-direction: column; gap: 1rem; margin: 0 0 1rem; }
  .calendar-heading p { font-size: 0.9rem; }
  .calendar-view-switch { width: 100%; }
  .calendar-view-switch .btn { flex: 1; justify-content: center; }
  .calendar-panel { padding: 0.85rem; border-radius: 1rem; }
  .calendar-navigation { grid-template-columns: 1fr auto 1fr; gap: 0.4rem; }
  .calendar-navigation .btn { min-height: 42px; padding: 0.5rem 0.7rem; }
  .calendar-navigation > :last-child { justify-self: end; }
  .calendar-navigation .nav-label { display: none; }
  .calendar-desktop { display: none; }
  .calendar-mobile { display: grid; gap: 0.65rem; }

  .agenda-day { overflow: hidden; border: 1px solid #e2e8f0; border-radius: 0.85rem; background: #fff; }
  .agenda-day.is-today { border-color: #93c5fd; box-shadow: 0 0 0 2px #dbeafe; }
  .agenda-day-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.8rem; padding: 0.7rem; }
  .agenda-date { display: grid; width: 48px; text-align: center; }
  .agenda-weekday { color: #64748b; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; }
  .agenda-date strong { color: #0f172a; font-size: 1.35rem; line-height: 1.1; }
  .agenda-day-summary { display: flex; align-items: center; gap: 0.5rem; color: #475569; }
  .agenda-day-summary small { padding: 0.15rem 0.45rem; border-radius: 1rem; background: #dbeafe; color: #1d4ed8; font-weight: 700; }
  .agenda-add { display: grid; width: 38px !important; height: 38px; padding: 0; place-items: center; }
  .agenda-events { border-top: 1px solid #eef2f7; }
  .agenda-event { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.65rem; padding: 0.72rem; color: #334155; text-decoration: none; }
  .agenda-event + .agenda-event { border-top: 1px solid #eef2f7; }
  .agenda-event time { color: #2563eb; font-size: 0.82rem; font-weight: 700; }
  .agenda-event span { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
  .daily-schedule { min-width: 0 !important; font-size: 0.86rem; }
  .daily-schedule th:first-child,
  .daily-schedule td:first-child { width: 68px !important; }
  .daily-schedule td { height: 64px !important; }
  .daily-add { opacity: 0.55; }

  .appointment-modal-panel { top: auto; bottom: 0; width: 100%; height: min(92dvh, 760px); border-radius: 1.25rem 1.25rem 0 0; animation-name: appointment-sheet-in; }
  .appointment-modal-panel.is-closing { animation-name: appointment-sheet-out; }
  .appointment-form-header { padding: 1rem; }
  .appointment-form-icon { width: 42px; height: 42px; border-radius: 13px; }
  .appointment-form-header p { display: none; }
  .appointment-form-body { padding: 1rem; }
  .appointment-form-footer { padding: 0.8rem 1rem calc(0.8rem + env(safe-area-inset-bottom)); }
  .appointment-form-footer .btn { flex: 1; }
  .appointment-history { flex-basis: 100% !important; order: -1; margin: 0; }
}

@media (max-width: 420px) {
  .appointment-datetime-grid { grid-template-columns: 1fr; gap: 0; }
}

@keyframes appointment-sheet-in { from { transform: translateY(100%); } }
@keyframes appointment-sheet-out { to { transform: translateY(100%); } }
