/* Portal Atenta — sistema visual compartido (dirección D, 03-sep-2026).
   Paleta y tipografía de somosatenta.cl: porcelana cálida, tinta ciruela,
   rosa dorado, lavanda y champagne; Playfair Display para títulos y cifras,
   Inter para todo lo demás. Lo cargan resumen, panel, config y login. */

:root {
  --bg: #fbf7f3; --bg-soft: #f6efe9; --card: #fffdfb;
  --border: #eadfd6; --border-soft: #f1e9e3;
  --ink: #241b21; --ink-soft: #5c4f57; --muted: #6b5c64;
  --rosa: #8e3f52; --rosa-hover: #7a3446; --rosa-tint: #f6e3e4; --rosa-border: #e9cfd6;
  --lavanda: #7f6bb5; --lavanda-tint: #ece5f6; --lavanda-ink: #5a4a8a;
  --champagne-tint: #f3e6d5; --champagne-ink: #7a5a1e;
  --ok: #2f6b47; --ok-tint: #e6f2ea;
  --alerta: #a83a3a; --alerta-tint: #f8e6e6; --alerta-border: #efc9c9;
  --sombra: 0 1px 2px rgba(36, 27, 33, .04), 0 8px 24px rgba(36, 27, 33, .06);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radio: 18px; --radio-chico: 10px;
  --sidebar: 232px;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); min-height: 100vh;
       font: 14.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--rosa); }
a:hover { color: var(--rosa-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, .serif { font-family: var(--serif); font-weight: 500; letter-spacing: -.015em; }
.num { font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }

/* ---------- Estructura: barra lateral + contenido ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); flex-shrink: 0; background: var(--card);
           border-right: 1px solid var(--border); display: flex; flex-direction: column;
           padding: 28px 18px 24px; gap: 8px; position: sticky; top: 0; height: 100vh; }
.sidebar .marca { font-family: var(--serif); font-size: 27px; color: var(--ink);
                  text-decoration: none; padding: 0 14px 22px; display: block; }
.sidebar .nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px;
            border-radius: 12px; font-size: 14.5px; font-weight: 500; color: var(--ink-soft);
            text-decoration: none; border: none; background: none; text-align: left; }
.nav-item:hover { background: var(--bg-soft); color: var(--ink); }
.nav-item.activo, .nav-item.activo:hover { background: var(--rosa-tint); color: var(--rosa); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .nav-n { margin-left: auto; font-size: 12px; font-weight: 600; background: var(--rosa);
                   color: var(--card); border-radius: 7px; padding: 1px 7px; }
.sidebar .espacio { flex: 1; }
.sidebar-pie { padding: 14px; border-top: 1px solid var(--border); font-size: 13px;
               line-height: 1.4; }
.sidebar-pie .usuario { font-weight: 600; overflow: hidden; text-overflow: ellipsis;
                        white-space: nowrap; }
.sidebar-pie .clinica { color: var(--muted); overflow: hidden; text-overflow: ellipsis;
                        white-space: nowrap; }
.sidebar-pie .salir { display: inline-block; color: var(--rosa); font-weight: 500;
                      margin-top: 10px; background: none; border: none; padding: 0; }
.contenido { flex: 1; min-width: 0; }
.pagina { padding: 34px 44px 60px; display: flex; flex-direction: column; gap: 24px;
          max-width: 1320px; }
.pagina-cab { display: flex; align-items: flex-end; justify-content: space-between;
              gap: 16px; flex-wrap: wrap; }
.pagina-cab h1 { font-size: 32px; line-height: 1.1; }
.pagina-cab .sub { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* Móvil: la barra lateral pasa a pestañas abajo. */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: auto;
             height: auto; flex-direction: row; padding: 0 10px;
             padding-bottom: env(safe-area-inset-bottom); border-right: none;
             border-top: 1px solid var(--border); z-index: 20; gap: 0; }
  .sidebar .marca, .sidebar .espacio { display: none; }
  .sidebar-pie { display: flex; align-items: center; padding: 0; border: none; }
  .sidebar-pie .usuario, .sidebar-pie .clinica { display: none; }
  .sidebar-pie .salir { margin: 0; min-height: 44px; padding: 0 12px; display: flex;
                        align-items: center; font-size: 12px; }
  .sidebar .nav { flex-direction: row; flex: 1; gap: 0; }
  .nav-item { flex: 1; flex-direction: column; gap: 4px; padding: 9px 0 7px;
              font-size: 12px; border-radius: 0; }
  .nav-item svg { width: 22px; height: 22px; }
  .nav-item.activo, .nav-item.activo:hover { background: none; }
  .nav-item .nav-n { position: absolute; margin: 0; transform: translate(14px, -4px); }
  .nav-item { position: relative; }
  .contenido { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .pagina { padding: calc(22px + env(safe-area-inset-top)) 18px 40px; gap: 14px; }
  .pagina-cab h1 { font-size: 26px; }
  /* iOS hace zoom al enfocar un campo con letra < 16px: en el teléfono todos van a 16. */
  .campo input, .campo select, .campo textarea, input.in, select.in, textarea.in,
  input[type="search"], textarea { font-size: 16px; }
}
/* Instalada como app (standalone): sin resaltado azul al tocar y sin rebote lateral. */
* { -webkit-tap-highlight-color: transparent; }
html { overscroll-behavior-x: none; }

/* ---------- Tarjetas y paneles teñidos ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radio);
        padding: 22px 24px; box-shadow: var(--sombra); min-width: 0; }
.tinte { border-radius: var(--radio); padding: 22px 24px; min-width: 0; }
.tinte.lavanda { background: var(--lavanda-tint); }
.tinte.champagne { background: var(--bg-soft); }
.card h2, .tinte h2 { font-size: 18px; }
.card .desc, .tinte .desc { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
@media (max-width: 760px) { .card, .tinte { padding: 16px 18px; border-radius: 16px; } }

/* ---------- Botones, chips, etiquetas ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       font-size: 13px; font-weight: 600; color: var(--rosa); border: 1px solid var(--rosa-border);
       background: var(--card); border-radius: 9px; padding: 8px 14px; text-decoration: none;
       min-height: 36px; white-space: nowrap; }
.btn:hover { background: var(--rosa-tint); color: var(--rosa-hover); }
.btn.primario { background: var(--rosa); border-color: var(--rosa); color: var(--card); }
.btn.primario:hover { background: var(--rosa-hover); border-color: var(--rosa-hover); color: var(--card); }
.btn.peligro { color: var(--alerta); border-color: var(--alerta-border); }
.btn.peligro:hover { background: var(--alerta-tint); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.chico { padding: 5px 11px; min-height: 30px; font-size: 12.5px; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
        color: var(--ink-soft); background: var(--card); border: 1px solid var(--border);
        border-radius: 999px; padding: 6px 11px; white-space: nowrap; }
.chip .n { color: var(--muted); font-weight: 500; }
.chip:hover { border-color: var(--rosa-border); color: var(--rosa); }
.chip.activo { background: var(--rosa); border-color: var(--rosa); color: var(--card); }
.chip.activo .n { color: rgba(255, 253, 251, .8); }
.chip .punto { width: 7px; height: 7px; border-radius: 50%; background: var(--rosa); display: inline-block; }
.chip.activo .punto { background: var(--card); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
         border-radius: 7px; padding: 2px 8px; white-space: nowrap; }
.badge.nuevo { background: var(--rosa-tint); color: var(--rosa); }
.badge.humano, .badge.escalada { background: var(--rosa); color: var(--card); }
.badge.cita { background: var(--ok-tint); color: var(--ok); }
.badge.espera { background: var(--champagne-tint); color: var(--champagne-ink); }
.badge.pausa, .badge.pausada { background: var(--lavanda-tint); color: var(--lavanda-ink); }
.badge.interes { background: var(--card); color: var(--ink-soft); border: 1px solid var(--border); font-weight: 500; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 8px;
        padding: 3px 9px; white-space: nowrap; }
.pill.ok { background: var(--ok-tint); color: var(--ok); }
.pill.pend { background: var(--border-soft); color: var(--ink-soft); }
.pill.ambar { background: var(--champagne-tint); color: var(--champagne-ink); }

.delta { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 8px;
         padding: 2px 8px; vertical-align: middle; letter-spacing: 0; }
.delta.up { background: var(--rosa-tint); color: var(--rosa); }
.delta.down { background: var(--champagne-tint); color: var(--champagne-ink); }
.delta.flat { background: var(--border-soft); color: var(--ink-soft); }

/* ---------- Tablas ---------- */
.tabla-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
            padding: 0 8px 8px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabla td { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: none; }
.tabla td:last-child, .tabla th:last-child { padding-right: 0; }
.tabla .r { text-align: right; }
.tabla td.r { font-variant-numeric: tabular-nums; }
.tabla b { font-weight: 600; }
.track { height: 7px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
.track .fill { height: 100%; background: var(--rosa); border-radius: 4px; min-width: 2px; }

/* ---------- Formularios ---------- */
.campo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.campo label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.campo input, .campo select, .campo textarea, input.in, select.in, textarea.in {
  width: 100%; height: 40px; border: 1px solid var(--border); border-radius: var(--radio-chico);
  background: var(--bg); padding: 0 12px; font-size: 14px; color: var(--ink); }
.campo textarea, textarea.in { height: auto; min-height: 80px; padding: 10px 12px; line-height: 1.45; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .in:focus {
  outline: 2px solid var(--rosa-tint); border-color: var(--rosa); }
.campo input::placeholder, .campo textarea::placeholder, .in::placeholder { color: var(--muted); }
.fila { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fila .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .fila { grid-template-columns: 1fr; } }

/* Interruptor: <label class="switch"><span>texto</span><span class="pista"><span class="bola"></span></span></label>
   con la clase .on en el label cuando está activo. */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500;
          color: var(--ink-soft); cursor: pointer; user-select: none; }
.switch .pista { width: 38px; height: 22px; border-radius: 999px; background: #d9cbd0;
                 position: relative; display: inline-block; flex-shrink: 0; transition: background .15s; }
.switch .bola { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
                background: var(--card); transition: left .15s; }
.switch.on .pista { background: var(--rosa); }
.switch.on .bola { left: 19px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

/* ---------- Estados ---------- */
.cargando, .error-card, .vacio { color: var(--muted); text-align: center; }
.cargando, .error-card { background: var(--card); border: 1px solid var(--border);
                         border-radius: var(--radio); padding: 34px; }
.vacio { font-size: 13px; padding: 10px 0; }
.error-card .btn { margin-top: 12px; }
.aviso { background: var(--alerta-tint); color: var(--alerta); border: 1px solid var(--alerta-border);
         border-radius: 9px; padding: 9px 12px; font-size: 13.5px; }
.estado-ok { color: var(--ok); font-size: 12.5px; }
