/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */
:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f6f8fc;
  --color-border: #e1e4e8;
  --color-text: #1f1f1f;
  --color-text-muted: #5f6368;
  --color-primary: #1a73e8;
  --color-primary-hover: #1765cc;
  --color-success: #1e8e3e;
  --color-success-bg: #e6f4ea;
  --color-danger: #d93025;
  --color-danger-bg: #fce8e6;
  --color-web: #b45309;       /* citas pedidas desde la web (5:1 con blanco) */
  --color-web-bg: #fef3e2;
  --color-slot-hover: #eef2fc;
  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-modal: 0 8px 28px rgba(0, 0, 0, 0.22);
  --font-main: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #1f1f1f;
    --color-bg-alt: #26272b;
    --color-border: #3c4043;
    --color-text: #e8eaed;
    --color-text-muted: #9aa0a6;
    --color-slot-hover: #2b3242;
    --color-success-bg: #10351f;
    --color-danger-bg: #3a1613;
  }
}

:root[data-theme="dark"] {
  --color-bg: #1f1f1f;
  --color-bg-alt: #26272b;
  --color-border: #3c4043;
  --color-text: #e8eaed;
  --color-text-muted: #9aa0a6;
  --color-slot-hover: #2b3242;
  --color-success-bg: #10351f;
  --color-danger-bg: #3a1613;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.app-header__title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header__title h1 {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0;
}

.app-header__logo {
  font-size: 1.4rem;
}

.app-header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header__rango {
  margin-left: 8px;
  font-size: 1rem;
  color: var(--color-text-muted);
  min-width: 180px;
}

.app-header__vista {
  display: flex;
  gap: 4px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.app-header__vista .btn--ghost {
  border-color: transparent;
  padding: 6px 14px;
}

.app-header__vista .btn--ghost.is-active {
  background: var(--color-primary);
  color: #fff;
}

.app-header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header__sesion {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------------ */
/* Botones                                                             */
/* ------------------------------------------------------------------ */
.btn {
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}
.btn--primary:hover {
  background: var(--color-primary-hover);
}

.btn--ghost {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn--ghost:hover {
  background: var(--color-bg-alt);
}

.btn--icon {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 50%;
}
.btn--icon:hover {
  background: var(--color-bg-alt);
}

.btn--danger {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn--danger:hover {
  background: var(--color-danger-bg);
}

/* ------------------------------------------------------------------ */
/* Rejilla tipo Google Calendar                                        */
/* ------------------------------------------------------------------ */
.calendar-wrapper {
  overflow: auto;
  height: calc(100vh - 64px);
}

.calendar-grid {
  display: grid;
  /* 1 columna para las horas + 7 columnas para los dias */
  grid-template-columns: 64px repeat(7, 1fr);
  min-width: 820px;
}

.calendar-grid__corner,
.calendar-grid__day-header {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 2;
  border-bottom: 1px solid var(--color-border);
  padding: 8px 4px;
  text-align: center;
}

.calendar-grid__corner {
  z-index: 3;
}

.calendar-grid__day-header .dow {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.calendar-grid__day-header .dom {
  font-size: 1.1rem;
  font-weight: 500;
}

.calendar-grid__day-header.is-today .dom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
}

.calendar-grid__hour-label {
  grid-column: 1;
  border-right: 1px solid var(--color-border);
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: right;
  padding-right: 6px;
  transform: translateY(-0.6em);
}

.calendar-grid__slot {
  position: relative;
  border-top: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  min-height: 120px;
  cursor: pointer;
}

.calendar-grid__slot:hover {
  background: var(--color-slot-hover);
}

.calendar-grid__event {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  bottom: 2px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  z-index: 1;
}

.calendar-grid__event:hover {
  filter: brightness(1.08);
}

/* Citas de la web: naranja; las pendientes de llamar, con borde marcado */
.calendar-grid__event.is-web {
  background: var(--color-web);
}

.calendar-grid__event.is-pendiente {
  box-shadow: inset 4px 0 0 #fff;
  padding-left: 10px;
}

.calendar-grid__event .evento-aviso {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-grid__event.is-finalizado {
  background: var(--color-success);
}

.calendar-grid__event .evento-nombre {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-grid__event .evento-hora {
  display: block;
  opacity: 0.85;
  font-size: 0.7rem;
}

/* ------------------------------------------------------------------ */
/* Rejilla de mes                                                      */
/* ------------------------------------------------------------------ */
.calendar-grid--mes {
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(120px, 1fr);
  min-width: 700px;
}

.calendar-grid__mes-day-header {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 2;
  border-bottom: 1px solid var(--color-border);
  padding: 8px 4px;
  text-align: center;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.calendar-grid__mes-cell {
  border-top: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  padding: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.calendar-grid__mes-cell:hover {
  background: var(--color-slot-hover);
}

.calendar-grid__mes-cell.is-other-month {
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
}

.calendar-grid__mes-cell .fecha-num {
  align-self: flex-end;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 500;
}

.calendar-grid__mes-cell.is-today .fecha-num {
  background: var(--color-primary);
  color: #fff;
}

.calendar-grid__mes-cell .mes-eventos {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.calendar-grid__mes-event {
  background: var(--color-primary);
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.calendar-grid__mes-event:hover {
  filter: brightness(1.08);
}

.calendar-grid__mes-event.is-web {
  background: var(--color-web);
}

.calendar-grid__mes-event.is-pendiente {
  font-weight: 700;
}

.calendar-grid__mes-event.is-finalizado {
  background: var(--color-success);
}

/* ------------------------------------------------------------------ */
/* Modal (dialog nativo)                                               */
/* ------------------------------------------------------------------ */
dialog.modal {
  width: min(480px, 92vw);
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  background: var(--color-bg);
  color: var(--color-text);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.modal__header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
}

.modal__body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 70vh;
  overflow-y: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field__label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="datetime-local"],
.field textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field--checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-success);
}

.field__hint {
  margin: -8px 0 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  margin-top: 4px;
}

.modal__footer-right {
  display: flex;
  gap: 8px;
}

/* ------------------------------------------------------------------ */
/* Toast                                                               */
/* ------------------------------------------------------------------ */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

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

/* ------------------------------------------------------------------ */
/* Movil                                                                */
/* ------------------------------------------------------------------ */
@media (max-width: 600px) {
  .app-header {
    gap: 8px;
  }
  .app-header__rango {
    min-width: auto;
    font-size: 0.85rem;
  }
}

/* Bloque "Confirmada por telefono" del modal, solo en citas de la web */
.field-web {
  border-left: 4px solid var(--color-web);
  background: var(--color-web-bg);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.field-web:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-web .field__hint {
  margin: 0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .field-web {
    background: rgba(180, 83, 9, 0.16);
  }
}

/* ------------------------------------------------------------------ */
/* Acceso (app/plantillas/login.html)                                  */
/* ------------------------------------------------------------------ */
.login-pagina {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--color-bg-alt);
}

.login {
  width: 100%;
  max-width: 360px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 28px 24px;
}

.login__cabecera {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login__cabecera h1 {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0;
}

.login__intro {
  margin: 8px 0 20px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login__form input {
  font-size: 1rem;
  padding: 10px 12px;
}

.login__error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-danger-bg);
  color: var(--color-danger);
  font-size: 0.875rem;
}

.login__error[hidden] {
  display: none;
}

.login__boton {
  margin-top: 4px;
  padding: 10px 16px;
  font-size: 0.95rem;
}

/* Mostrar u ocultar la contraseña: botón dentro del campo, a la derecha */
.login__clave {
  position: relative;
}

.login__clave input {
  width: 100%;
  padding-right: 88px;
}

.login__ver {
  position: absolute;
  top: 3px;
  right: 3px;
  bottom: 3px;
  min-width: 76px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-primary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.login__ver:hover {
  background: var(--color-slot-hover);
}

.login__ver:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
}

/* Edge trae su propio ojo de "mostrar contraseña": con el botón basta */
.login__clave input::-ms-reveal,
.login__clave input::-ms-clear {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login__ver {
    color: #8ab4f8; /* 8:1 sobre el fondo oscuro */
  }
}

/* ------------------------------------------------------------------ */
/* Opiniones (static/opiniones.html)                                   */
/* ------------------------------------------------------------------ */
a.btn {
  display: inline-block;
  text-decoration: none;
}

.app-header__nav .btn.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.opiniones-panel {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.opiniones-panel__intro {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.opiniones-panel__resumen {
  margin: 16px 0 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.opiniones-panel__lista {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.opiniones-panel__vacio {
  margin-top: 24px;
  color: var(--color-text-muted);
}

.opinion-panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.opinion-panel.is-oculta {
  background: var(--color-bg-alt);
}

.opinion-panel.is-oculta .opinion-panel__texto {
  color: var(--color-text-muted);
}

.opinion-panel__cabecera {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-size: 0.85rem;
}

.opinion-panel__estrellas {
  color: var(--color-primary);
  letter-spacing: 1px;
}

.opinion-panel__quien {
  font-weight: 600;
}

.opinion-panel__fecha {
  color: var(--color-text-muted);
  margin-left: auto;
}

.opinion-panel__texto {
  margin: 10px 0 0;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-line;
}

.opinion-panel__pie {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.opinion-panel__estado {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.field-opinion:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.field-opinion .field__hint {
  margin: 0;
}

.opinion-panel__estados {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.opinion-panel__n8n {
  font-size: 0.8rem;
  color: var(--color-success);
}

.opinion-panel__n8n.is-pendiente {
  color: var(--color-text-muted);
}
