*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: system-ui, -apple-system, sans-serif; background: #f3f4f6; color: #111; }

/* ── Layout ────────────────────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: #fff; border-right: 1px solid #e5e7eb;
  display: flex; flex-direction: column;
}
.sidebar-brand { padding: 20px; border-bottom: 1px solid #f3f4f6; }
.sidebar-brand h1 { color: #2563eb; font-size: 1.1rem; font-weight: 700; }
.sidebar-brand p { color: #9ca3af; font-size: 0.72rem; margin-top: 2px; }

.sidebar nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 0.875rem; color: #4b5563; text-decoration: none;
  transition: background 0.15s;
}
.sidebar nav a:hover { background: #f3f4f6; }
.sidebar nav a.active { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid #f3f4f6; font-size: 0.72rem; color: #9ca3af; }

.sidebar-header { display: flex; align-items: center; }
.sidebar-brand { flex: 1; }
.nav-toggle { display: none; }

.main { flex: 1; overflow: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

/* ── Botones ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-size: 0.875rem; cursor: pointer; border: none; font-weight: 500; transition: background 0.15s; }
.btn-primary   { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger    { background: #fff; color: #dc2626; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn:disabled  { opacity: 0.5; cursor: not-allowed; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

/* ── Toolbar (calendario) ──────────────────────────────────────────────── */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav-btn { padding: 6px 12px; background: #fff; border: 1px solid #d1d5db; border-radius: 8px; cursor: pointer; font-size: 0.875rem; }
.cal-nav-btn:hover { background: #f9fafb; }
#cal-title { font-size: 0.9rem; font-weight: 600; color: #374151; margin-left: 8px; }
.view-toggle { display: flex; border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; background: #fff; }
.view-toggle button { padding: 6px 12px; font-size: 0.875rem; cursor: pointer; border: none; background: none; color: #374151; }
.view-toggle button:not(:first-child) { border-left: 1px solid #d1d5db; }
.view-toggle button.active { background: #2563eb; color: #fff; }

/* ── FullCalendar overrides ────────────────────────────────────────────── */
#calendar { height: 100%; }
.fc .fc-col-header-cell { background: #f9fafb; font-size: 0.8rem; font-weight: 600; color: #4b5563; }
.fc .fc-timegrid-slot { height: 36px !important; }
.fc .fc-event { font-size: 0.75rem; border-radius: 4px; padding: 1px 4px; cursor: pointer; }
.fc .fc-resource-area-header { background: #f9fafb; font-size: 0.8rem; font-weight: 600; color: #4b5563; }
.fc-direction-ltr .fc-timegrid-col-events { margin: 0 1px; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.4); align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 100%; max-width: 520px; margin: 16px; overflow: hidden; }
.modal-header { background: #2563eb; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { color: #fff; font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: rgba(255,255,255,.8); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; }

/* ── Formulario ───────────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.8rem; font-weight: 500; color: #374151; }
input, select, textarea {
  border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 12px;
  font-size: 0.875rem; color: #111; width: 100%;
  outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { resize: none; }
.hint { font-size: 0.75rem; color: #6b7280; }

/* ── Alert / error ───────────────────────────────────────────────────── */
.alert-error { background: #fef2f2; color: #dc2626; border-radius: 8px; padding: 10px 14px; font-size: 0.85rem; display: none; }
.alert-error.show { display: block; }

/* ── Página de tabla ─────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; color: #111; }
.search-bar { padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 0.875rem; width: 100%; max-width: 360px; outline: none; }
.search-bar:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th { text-align: left; padding: 12px 16px; background: #f9fafb; color: #6b7280; font-weight: 500; border-bottom: 1px solid #e5e7eb; }
tbody tr { border-bottom: 1px solid #f3f4f6; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }
td { padding: 12px 16px; color: #374151; }
.td-actions { text-align: right; white-space: nowrap; display: flex; gap: 8px; justify-content: flex-end; }
.td-actions a { font-size: 0.8rem; cursor: pointer; text-decoration: none; }
.link-edit   { color: #2563eb; }
.link-delete { color: #dc2626; }
.link-edit:hover   { text-decoration: underline; }
.link-delete:hover { text-decoration: underline; }
.empty-row td { text-align: center; color: #9ca3af; padding: 40px; }

/* ── Cards (profesionales / servicios) ────────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.prof-card  { padding: 20px; display: flex; align-items: flex-start; gap: 14px; }
.prof-dot   { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.prof-info  { flex: 1; min-width: 0; }
.prof-info h3 { font-weight: 600; color: #111; font-size: 0.95rem; }
.prof-info p  { font-size: 0.8rem; color: #6b7280; margin-top: 2px; }
.prof-schedule { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.prof-schedule span { font-size: 0.75rem; color: #6b7280; }
.card-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; }
.card-actions a { font-size: 0.78rem; cursor: pointer; }

.svc-card { padding: 18px 20px; }
.svc-card h3 { font-weight: 600; color: #111; }
.svc-dur  { font-size: 0.82rem; color: #2563eb; margin-top: 2px; }
.svc-desc { font-size: 0.78rem; color: #9ca3af; margin-top: 4px; }
.svc-header { display: flex; align-items: flex-start; justify-content: space-between; }

/* ── Horario builder ────────────────────────────────────────────────── */
.schedule-row { display: flex; align-items: center; gap: 8px; }
.schedule-row select, .schedule-row input { font-size: 0.8rem; padding: 5px 8px; }
.schedule-row .rm-btn { background: none; border: none; color: #ef4444; font-size: 1.2rem; cursor: pointer; line-height: 1; }

/* ── Color picker ───────────────────────────────────────────────────── */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; transition: transform .15s; border: 2px solid transparent; }
.color-swatch.selected { transform: scale(1.2); border-color: #374151; }

/* ── Tabla responsive ─────────────────────────────────────────────────── */
.table-wrap { overflow: hidden; }

/* ── Responsive (móviles) ───────────────────────────────────────────── */
img { max-width: 100%; height: auto; display: block; }

@media (max-width: 767px) {
  /* Layout base */
  .layout { display: block; height: auto; overflow: visible; }

  /* Sidebar: barra compacta con toggle */
  .sidebar { width: 100%; flex-direction: column; padding: 0; }
  .sidebar-header { padding: 10px 14px; border-bottom: 1px solid #e5e7eb; }
  .sidebar-brand { padding: 0; border: none; }
  .sidebar-brand p { display: none; }
  .nav-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex-shrink: 0;
    background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 8px;
    font-size: 1.3rem; cursor: pointer; color: #374151; line-height: 1;
  }
  .nav-toggle:hover { background: #e5e7eb; }
  .sidebar nav {
    display: none; flex-direction: column; gap: 2px;
    padding: 8px 12px; border-bottom: 1px solid #e5e7eb;
  }
  .sidebar nav.open { display: flex; }
  .sidebar-footer { display: none; }

  /* Área principal: scroll natural de página */
  .main { padding: 12px; overflow: visible; }

  /* Toolbar calendario: 2 filas (nav/título arriba, vistas+acción abajo) */
  .cal-toolbar { gap: 8px; flex-direction: column; align-items: flex-start; }
  .cal-nav { flex-wrap: wrap; }

  /* Calendario */
  .card { overflow: auto; }
  #calendar { height: 60vh; min-height: 320px; }

  /* Formulario */
  .form-row { grid-template-columns: 1fr; }

  /* Modal a pantalla casi completa */
  .modal-box { margin: 8px; max-width: calc(100% - 16px); width: auto; max-height: 92vh; }

  /* Cards profesionales/servicios */
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .prof-dot { width: 36px; height: 36px; }

  /* Tabla */
  .table-wrap { overflow-x: auto; }
  table td, thead th { padding: 10px; font-size: 0.82rem; }

  .schedule-row { flex-wrap: wrap; }
}
