/* ============================================================
   OdontoArte — Sistema de diseño
   Paleta: crema + azul oscuro profesional
   Responsive: móvil (PWA) + escritorio desde el primer momento
   ============================================================ */

:root {
  /* Azul oscuro profesional */
  --navy-900: #0e2136;
  --navy-800: #14304f;
  --navy-700: #1c3f66;
  --navy-600: #274c74;
  --navy-500: #35618c;

  /* Crema */
  --crema-50:  #faf6ec;
  --crema-100: #f4ecd9;
  --crema-200: #ebe0c6;
  --crema-300: #ddceac;

  /* Acento cálido (uso mínimo: estados activos, detalles) */
  --oro-500: #c8a24c;
  --oro-600: #b0872f;

  /* Superficies y texto */
  --surface:      #ffffff;
  --surface-alt:  var(--crema-50);
  --border:       #e7dec7;
  --text:         #1a2434;
  --text-muted:   #64708090;
  --text-soft:    #5c6675;

  /* Feedback */
  --ok:    #2f7d4f;
  --ok-bg: #e7f3ec;
  --err:   #b4342c;
  --err-bg:#f7e7e5;
  --info-bg:#e9eef5;

  /* Métricas */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(14, 33, 54, .08), 0 6px 20px rgba(14, 33, 54, .06);
  --shadow-sm: 0 1px 2px rgba(14, 33, 54, .08);
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-alt);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--navy-800); font-weight: 700; line-height: 1.2; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; }

/* Sidebar (navy) */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-800), var(--navy-900));
  color: #dfe7f0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(0);
  transition: transform .25s ease;
}
.sidebar__brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--crema-100);
  color: var(--navy-800);
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem;
  flex: none;
}
.sidebar__name { font-weight: 700; color: #fff; letter-spacing: .3px; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: .75rem .6rem 1rem; }
.nav-group__title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: #8ba0b8; padding: .9rem .7rem .35rem;
}
.nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .7rem; margin: .1rem 0;
  border-radius: var(--radius-sm);
  color: #cdd8e6; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav-link.is-active {
  background: rgba(255,255,255,.1);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--oro-500);
}
.nav-link.is-disabled { color: #6c7f96; cursor: default; }
.nav-link.is-disabled:hover { background: none; color: #6c7f96; }
.nav-link .pronto {
  margin-left: auto; font-size: .62rem; background: rgba(255,255,255,.12);
  padding: .12rem .4rem; border-radius: 20px; text-transform: uppercase; letter-spacing: .05em;
}
.nav-ico { width: 18px; height: 18px; flex: none; }
.sidebar__foot { padding: .8rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar__user { font-size: .82rem; color: #aebccd; }
.sidebar__user strong { color: #fff; display: block; }

/* Main */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-weight: 700; color: var(--navy-800); font-size: 1.05rem; }
.topbar__spacer { flex: 1; }
.hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  width: 40px; height: 40px; border-radius: 8px;
  color: var(--navy-800);
}
.hamburger:hover { background: var(--crema-100); }
.content { padding: 1.5rem; flex: 1; max-width: 1200px; width: 100%; }

/* Backdrop para drawer móvil */
.backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(14,33,54,.45); z-index: 39;
}

/* ---------- Componentes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card--pad { padding: 1.25rem; }

.grid-kpi {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 1.5rem;
}
.kpi { padding: 1.1rem 1.25rem; color: inherit; }
.kpi:hover { text-decoration: none; border-color: var(--navy-300); }
.kpi__label { color: var(--text-soft); font-size: .82rem; }
.kpi__value { font-size: 1.9rem; font-weight: 800; color: var(--navy-800); margin: .2rem 0; }
.kpi__note { font-size: .74rem; color: var(--text-soft); }
.dashboard-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.page-head { margin-bottom: 1.25rem; }
.page-head p { color: var(--text-soft); margin: 0; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .92rem; cursor: pointer;
  border: 1px solid transparent; font-family: inherit;
}
.btn--primary { background: var(--navy-700); color: #fff; }
.btn--primary:hover { background: var(--navy-800); text-decoration: none; }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--navy-800); }
.btn--ghost:hover { background: var(--crema-50); text-decoration: none; }
.btn--danger { background: var(--err-bg); color: var(--err); border-color: #eccbc8; }
.btn--danger:hover { background: #f2d9d6; text-decoration: none; }
.btn--sm { padding: .4rem .75rem; font-size: .82rem; }
.btn--block { width: 100%; }

/* Formularios */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; color: var(--navy-800); }
.input, .select {
  width: 100%; padding: .65rem .8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .95rem; font-family: inherit; background: var(--surface); color: var(--text);
}
.input:focus, .select:focus {
  outline: none; border-color: var(--navy-500);
  box-shadow: 0 0 0 3px rgba(53,97,140,.15);
}

/* Tabla */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); }
.table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* Badges */
.badge { display: inline-block; padding: .18rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge--admin { background: var(--navy-700); color: #fff; }
.badge--recepcion { background: var(--crema-200); color: var(--navy-800); }
.badge--on { background: var(--ok-bg); color: var(--ok); }
.badge--off { background: var(--err-bg); color: var(--err); }

/* Flash */
.flashes { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.flash { padding: .7rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; }
.flash--success { background: var(--ok-bg); color: var(--ok); }
.flash--error { background: var(--err-bg); color: var(--err); }
.flash--info { background: var(--info-bg); color: var(--navy-800); }

/* Permisos (toggles) */
.permiso-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .25rem; border-bottom: 1px solid var(--border);
}
.permiso-row:last-child { border-bottom: none; }
.permiso-row__label { flex: 1; }
.permiso-row__bloque { font-size: .72rem; color: var(--text-soft); }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #cdd3db; border-radius: 20px; transition: .2s;
}
.switch .track::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .track { background: var(--navy-600); }
.switch input:checked + .track::before { transform: translateX(20px); }

/* Tabs (ficha del paciente) */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tab {
  padding: .65rem 1rem; white-space: nowrap; color: var(--text-soft); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--navy-700); text-decoration: none; }
.tab.is-active { color: var(--navy-800); border-bottom-color: var(--navy-700); }
.tab.is-disabled { color: #b3bccb; cursor: default; }
.tab.is-disabled:hover { color: #b3bccb; }
.tab .pronto { font-size: .6rem; background: var(--crema-200); color: var(--navy-800); padding: .1rem .35rem; border-radius: 20px; margin-left: .3rem; }

/* Ficha: secciones en una sola página */
.ficha-sec { margin-bottom: 2rem; scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.ficha-sec__title {
  font-size: 1.1rem; color: var(--navy-800); margin: 0 0 .75rem;
  padding-bottom: .4rem; border-bottom: 2px solid var(--crema-200);
  display: flex; align-items: center; gap: .5rem;
}

/* Ficha: cabecera del paciente */
.pac-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.pac-avatar {
  width: 56px; height: 56px; border-radius: 14px; flex: none;
  background: var(--navy-700); color: var(--crema-100);
  display: grid; place-items: center; font-weight: 800; font-size: 1.3rem;
}
.pac-meta { color: var(--text-soft); font-size: .9rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.alert-box { background: var(--err-bg); color: var(--err); border-radius: var(--radius-sm); padding: .6rem .9rem; font-size: .85rem; margin-bottom: 1rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { background: var(--crema-100); color: var(--navy-800); border: 1px solid var(--crema-200); padding: .25rem .6rem; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; }
.dl dt { color: var(--text-soft); font-size: .85rem; }
.dl dd { margin: 0; }

.nota { border-left: 3px solid var(--navy-500); padding: .5rem .9rem; background: var(--surface-alt); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.nota + .nota { margin-top: .75rem; }
.nota__meta { font-size: .75rem; color: var(--text-soft); display: flex; gap: .75rem; margin-bottom: .3rem; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .5rem; }
.check { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Odontograma */
.odo-palette { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; }
.odo-tool {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .7rem; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  font-size: .8rem; font-weight: 600; color: var(--navy-800); font-family: inherit;
}
.odo-tool:hover { background: var(--crema-50); }
.odo-tool.is-active { border-color: var(--navy-700); box-shadow: 0 0 0 2px rgba(28,63,102,.15); }
.odo-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* Lienzo único con forma de boca (arcadas curvas), escala al ancho */
.odo-boca { width: 100%; }
.odo-canvas { width: 100%; max-width: 620px; height: auto; display: block; margin: 0 auto; }
.odo-t { cursor: pointer; }
.odo-t path { fill: #fff; stroke: #94a3b8; stroke-width: 2; transition: fill .1s, stroke .1s; }
.odo-t:hover path { stroke: var(--navy-700); stroke-width: 3; }
.odo-t.is-ausente { opacity: .5; }
.odo-t.is-ausente path { stroke-dasharray: 4 3; }
.odo-lbl { font-size: 11px; fill: var(--text-soft); text-anchor: middle; font-family: var(--font); user-select: none; }
.odo-arco-lbl { font-size: 11px; fill: #9aa6b6; text-anchor: middle; text-transform: uppercase; letter-spacing: .1em; font-family: var(--font); }

/* Agenda */
.agenda-bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.agenda-nav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.agenda-actions { display: flex; align-items: center; gap: .6rem; margin-left: auto; flex-wrap: wrap; }
.agenda-sync { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg__item { padding: .4rem .8rem; font-size: .82rem; font-weight: 600; color: var(--text-soft); background: var(--surface); }
.seg__item:hover { text-decoration: none; background: var(--crema-50); }
.seg__item.is-active { background: var(--navy-700); color: #fff; }

.cita { display: flex; gap: 1rem; padding: 1rem 1.1rem; align-items: flex-start; }
.cita__time { width: 68px; flex: none; text-align: center; }
.cita__time strong { font-size: 1.05rem; color: var(--navy-800); display: block; }
.cita__body { flex: 1; min-width: 0; }
.cita__side { flex: none; text-align: right; }

.semana-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; }
.semana-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; min-height: 120px; }
.semana-col.is-hoy { border-color: var(--navy-500); box-shadow: inset 0 2px 0 var(--navy-500); }
.semana-col__head { display: flex; flex-direction: column; align-items: center; padding: .5rem; background: var(--crema-50); border-bottom: 1px solid var(--border); color: var(--navy-800); }
.semana-col__head:hover { text-decoration: none; background: var(--crema-100); }
.semana-col__head span { font-size: .7rem; text-transform: uppercase; color: var(--text-soft); }
.semana-col__head strong { font-size: 1.1rem; }
.semana-col__body { padding: .35rem; display: flex; flex-direction: column; gap: .35rem; }
.semana-cita { display: flex; flex-direction: column; padding: .35rem .45rem; border-radius: 6px; background: var(--surface-alt); font-size: .74rem; line-height: 1.25; color: var(--text); }
.semana-cita:hover { text-decoration: none; background: var(--crema-100); }
.semana-cita strong { color: var(--navy-800); }
.semana-add { display: block; text-align: center; color: #c1c9d4; padding: .4rem; font-size: 1.1rem; }
.semana-add:hover { text-decoration: none; color: var(--navy-600); background: var(--crema-50); border-radius: 6px; }

@media (max-width: 760px) {
  .semana-grid { grid-template-columns: 1fr; }
  .semana-col { min-height: 0; }
  .agenda-actions { margin-left: 0; }
  .agenda-sync { align-items: flex-start; flex-direction: column; }
}

/* Subida de archivos + galería de imágenes clínicas */
.upload-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.galeria { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-top: 1rem; }
.galeria__item { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.galeria__item img { width: 100%; height: 150px; object-fit: cover; display: block; background: var(--crema-100); }
.galeria__item figcaption { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; flex-wrap: wrap; }

.helper { font-size: .8rem; color: var(--text-soft); }
.stack > * + * { margin-top: 1rem; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; border: none; }

/* ---------- Login ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(1200px 600px at 50% -10%, var(--crema-100), var(--surface-alt));
}
.auth__card { width: 100%; max-width: 380px; padding: 2rem; }
.auth__brand { text-align: center; margin-bottom: 1.5rem; }
.auth__logo {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto .75rem;
  background: var(--navy-800); color: var(--crema-100);
  display: grid; place-items: center; font-weight: 800; font-size: 1.4rem;
}
.auth__title { color: var(--navy-800); margin: 0; }
.auth__sub { color: var(--text-soft); font-size: .88rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.checkbox input { width: auto; }

/* ============================================================
   RESPONSIVE — móvil / tablet
   ============================================================ */
@media (max-width: 900px) {
  .main { margin-left: 0; }
  .hamburger { display: grid; place-items: center; }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .backdrop { display: block; }
  .content { padding: 1rem; }
  .kpi__value { font-size: 1.6rem; }
}

/* Grids de formulario con columnas fijas (ej. "1fr 1fr", "2fr 1fr 1fr 1fr"):
   colapsan a una sola columna en pantallas chicas. Los grids que ya usan
   auto-fit/minmax (paneles, KPIs) se adaptan solos y no necesitan esta clase. */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr !important; }
}

/* Respeta preferencias de reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
