:root {
  --bg: #f5f4f2;
  --panel: #ffffff;
  --ink: #1e1b18;
  --ink-soft: #6b645d;
  --border: #e5e1db;
  --accent: #8a5a3b;
  --accent-dark: #6e4630;
  --danger: #b3402f;
  --danger-bg: #fbeae7;
  --success: #2f7a4f;
  --success-bg: #e9f5ee;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

button {
  font-family: inherit;
}

a {
  color: var(--accent);
}

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.login-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.login-card .subtitle {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 24px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s ease;
}

.btn:hover {
  background: var(--accent-dark);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.btn-block {
  width: 100%;
}

.btn.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn.btn-secondary:hover {
  background: #f1efec;
}

.btn.btn-danger {
  background: var(--danger);
}

.btn.btn-danger:hover {
  background: #93342a;
}

.alert {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
}

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 2px;
}

.sidebar-brand small {
  display: block;
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 11px;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  flex: 1;
}

.nav-list li {
  margin-bottom: 4px;
}

.nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

.nav-link:hover {
  background: #f1efec;
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.nav-link.disabled {
  color: #b8b2aa;
  cursor: default;
}

.nav-link.disabled:hover {
  background: none;
}

.nav-tag {
  float: right;
  font-size: 10px;
  border-radius: 999px;
  padding: 1px 7px;
  background: #ece8e2;
  color: var(--ink-soft);
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-caret {
  font-size: 10px;
  color: var(--ink-soft);
  margin-left: 6px;
}

.nav-link.active .nav-caret {
  color: #fff;
}

.nav-subgroup {
  list-style: none;
  margin: 2px 0 0;
  padding: 0 0 0 12px;
}

.nav-subgroup li {
  margin-bottom: 2px;
}

.nav-sublink {
  font-size: 13px;
  padding: 7px 12px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.sidebar-user {
  font-size: 13px;
  margin-bottom: 10px;
}

.sidebar-user .role {
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px;
}

.main h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.main .page-subtitle {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-header h2 {
  font-size: 16px;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-inactive {
  background: #eee;
  color: #999;
}

.badge-role {
  background: #efe6dc;
  color: var(--accent-dark);
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin-top: 0;
  font-size: 17px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.temp-password-box {
  background: #fbf6ec;
  border: 1px solid #e8dcc0;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  margin-top: 14px;
}

.temp-password-box code {
  font-size: 15px;
  font-weight: 700;
  background: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 4px;
}

.dash-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

.dash-filters .field {
  margin-bottom: 0;
}

.dash-filters-tight {
  margin-bottom: 16px;
  align-items: center;
}

.dash-filters-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.dash-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  background: #f6f4f1;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

.dash-check input {
  margin: 0;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-height: 340px;
}

.panel-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: stretch;
}

.panel-row-main {
  flex: 2 1 480px;
  min-width: 0;
}

.panel-row-side {
  flex: 1 1 240px;
  min-width: 220px;
  border-left: 1px solid var(--border);
  padding-left: 20px;
}

@media (max-width: 820px) {
  .panel-row-side {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 16px;
  }
}

.panel-row-side h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.zona-scroll {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.zona-scroll label {
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
  cursor: pointer;
}

.zona-scroll label input {
  margin-right: 5px;
}

.zona-rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.zona-rank-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

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

.zona-rank-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.zona-rank-name {
  font-weight: 600;
}

.zona-rank-count {
  color: var(--accent-dark);
  font-weight: 700;
}

.zona-rank-bar-bg {
  background: #ece8e2;
  border-radius: 3px;
  height: 5px;
  overflow: hidden;
}

.zona-rank-bar-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 3px;
}

.count-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.count-badge {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}

.count-badge:hover {
  background: #f6f4f1;
}

.count-badge.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.table-scroll {
  max-height: 360px;
  overflow-y: auto;
}

.empty-state {
  color: var(--ink-soft);
  font-size: 13px;
  padding: 20px 0;
  text-align: center;
}

/* ---------- Agenda ---------- */

.agenda-grid {
  display: flex;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.agenda-hours-col {
  flex: 0 0 52px;
  border-right: 1px solid var(--border);
}

.agenda-day-col {
  flex: 1 1 0;
  min-width: 120px;
  border-right: 1px solid var(--border);
}

.agenda-day-col:last-child {
  border-right: none;
}

.agenda-day-header {
  height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  background: #faf9f7;
}

.agenda-day-header.agenda-day-today {
  background: #efe6dc;
}

.agenda-day-name {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}

.agenda-day-num {
  font-size: 14px;
  font-weight: 700;
}

.agenda-day-allday {
  min-height: 4px;
  padding: 2px;
  border-bottom: 1px solid var(--border);
}

.agenda-event-allday {
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-hour-label {
  font-size: 11px;
  color: var(--ink-soft);
  text-align: right;
  padding-right: 6px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  transform: translateY(-6px);
}

.agenda-day-body {
  position: relative;
}

.agenda-hour-row {
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.agenda-event-block {
  position: absolute;
  left: 2px;
  right: 2px;
  color: #fff;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 11px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.agenda-event-block.agenda-event-bloqueo {
  background: repeating-linear-gradient(
    45deg,
    #6b6b6b,
    #6b6b6b 6px,
    #838383 6px,
    #838383 12px
  ) !important;
  opacity: 0.85;
}

/* A pedido de Rafael: turno cancelado (por respuesta del cliente al
   mensaje de confirmación) sigue visible en la grilla, pero claramente
   distinto — tachado y más tenue, sin sacarlo del calendario. */
.agenda-event-block.agenda-event-cancelado {
  opacity: 0.5;
}
.agenda-event-block.agenda-event-cancelado .agenda-event-title {
  text-decoration: line-through;
}
.agenda-event-block.agenda-event-confirmado {
  box-shadow: inset 3px 0 0 rgba(47, 122, 79, 0.9), 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Evaluacion (sin costo, atada a un servicio) y videollamada (sin costo,
   para vender la capacitacion) -- a pedido de Rafael. Se distinguen con un
   borde punteado para que se note de un vistazo que no facturan nada. */
.agenda-event-block.agenda-event-evaluacion {
  border: 2px dashed rgba(255, 255, 255, 0.85) !important;
}
.agenda-event-block.agenda-event-videollamada {
  border: 2px dotted rgba(255, 255, 255, 0.85) !important;
}

.agenda-event-time {
  font-weight: 700;
  font-size: 10px;
  opacity: 0.9;
}

.agenda-event-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A pedido de Rafael: icono de estado bien visible en la esquina de cada
   turno -- check verde (confirmado), X roja (cancelado) o reloj (pendiente
   de confirmar). El fondo blanco semi-transparente asegura que se vea sin
   importar el color de fondo del profesional. */
.agenda-event-status-icon {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

.mobile-topbar .hamburger {
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .app-shell {
    flex-direction: column;
  }

  .mobile-topbar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12);
  }

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

  .main {
    padding: 20px 16px;
  }

  .panel {
    padding: 16px;
  }

  table {
    font-size: 13px;
  }

  th:nth-child(4),
  td:nth-child(4) {
    display: none;
  }
}

/* ---------- Toast de notificación (carga de registro exitosa) ---------- */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}

.toast {
  background: var(--success);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-error {
  background: var(--danger);
}

@media (max-width: 640px) {
  .toast-container {
    top: auto;
    bottom: 16px;
    left: 16px;
    right: 16px;
    max-width: none;
  }
}

/* Selects con búsqueda (lupa) */
.ssw {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}
.ssw::before {
  content: "\1F50D";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.55;
  pointer-events: none;
}
.ssw-input {
  padding-left: 26px !important;
}
.ssw-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
.ssw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.ssw-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light, #eef2ff);
  color: var(--primary, #4f46e5);
  border-radius: 999px;
  padding: 2px 8px 2px 10px;
  font-size: 12px;
  font-weight: 500;
}
.ssw-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  opacity: 0.7;
}
.ssw-chip button:hover {
  opacity: 1;
}
.ssw-multi-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  min-width: 260px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 6px;
}
.ssw-multi-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
}
.ssw-multi-panel label:hover {
  background: var(--bg-hover, #f1f5f9);
}
.ssw-multi-empty {
  padding: 8px 6px;
  font-size: 12px;
  opacity: 0.6;
}
