/* semanal.css — calendario semanal por horarios (visitas + reuniones jatto)
   Usa los tokens de tema reales (main.css): --bg, --bg-alt, --bg-elev, --fg,
   --fg-muted, --line, --accent, --warn… → respeta claro/oscuro. */

/* switch Mes / Semana */
.cal-mode {
  display: inline-flex; gap: 0; margin-right: 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-elev);
}
.cal-mode-btn {
  border: 0 !important; border-radius: 0 !important; padding: 6px 16px;
  font-weight: 600; color: var(--fg-muted); background: transparent;
}
.cal-mode-btn:hover { background: var(--hover); color: var(--fg); }
.cal-mode-btn.active { background: var(--accent); color: var(--accent-fg); }
.cal-mode-btn.active:hover { background: var(--accent); }

/* controles (toggle jatto + leyenda) */
.sem-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sem-toggle {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
  cursor: pointer; user-select: none; padding: 6px 12px;
  border-radius: var(--radius); background: var(--bg-elev);
  border: 1px solid var(--line); color: var(--fg);
}
.sem-toggle:hover { border-color: var(--line-strong); }
.sem-toggle input { accent-color: var(--warn); width: 15px; height: 15px; }
.sem-legend { display: inline-flex; gap: 14px; }
.sem-legend .legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-muted); }
.sem-legend .legend-swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.legend-swatch.sem-sw-visit { background: var(--accent); }
.legend-swatch.sem-sw-jatto { background: var(--warn); }

/* nav de semana */
.sem-nav { display: flex; align-items: center; gap: 6px; }
.sem-title { font-size: 15px; margin: 0 6px; min-width: 184px; text-align: center; font-variant-numeric: tabular-nums; color: var(--fg); }

.sem-empty { padding: 50px; text-align: center; color: var(--fg-muted); }

/* layout: gutter de horas + 7 días */
.sem-grid {
  --gutter: 56px;
  width: 100%; overflow: auto; max-height: calc(100vh - 196px);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-elev); box-shadow: var(--shadow-sm);
}
.sem-headrow, .sem-bodyrow {
  display: grid;
  grid-template-columns: var(--gutter) repeat(7, minmax(120px, 1fr));
  min-width: 900px;
}
.sem-headrow {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
}
.sem-bodyrow { position: relative; }

/* encabezados de día */
.sem-corner { border-right: 1px solid var(--line); }
.sem-dayhead {
  text-align: center; padding: 10px 4px 8px; font-size: 11px;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--fg-subtle); border-left: 1px solid var(--line);
}
.sem-dayhead b { display: block; font-size: 17px; font-weight: 700; color: var(--fg); margin-top: 2px; letter-spacing: 0; text-transform: none; }
.sem-dayhead.is-visitday { color: var(--accent); }
.sem-dayhead.is-today b {
  color: var(--accent-fg); background: var(--accent);
  width: 28px; height: 28px; line-height: 28px; border-radius: 50%;
  margin: 2px auto 0; display: inline-block;
}

/* gutter de horas */
.sem-hours { position: relative; border-right: 1px solid var(--line); background: var(--bg-alt); }
.sem-hour { position: relative; }
.sem-hour span {
  position: absolute; top: -7px; right: 8px; font-size: 11px;
  color: var(--fg-subtle); font-variant-numeric: tabular-nums;
}

/* columnas de días */
.sem-col {
  position: relative; border-left: 1px solid var(--line); cursor: copy;
  background: repeating-linear-gradient(
    var(--bg-elev), var(--bg-elev) 47px,
    var(--line) 47px, var(--line) 48px);
  transition: background-color .12s;
}
.sem-col:hover { background-color: color-mix(in srgb, var(--accent) 6%, transparent); }
.sem-col.is-visitday { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.sem-col.is-today { background-color: color-mix(in srgb, var(--accent) 8%, transparent); }
.sem-line { position: absolute; left: 0; right: 0; height: 0; }

/* línea de hora actual */
.sem-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 4; }
.sem-now::before { content: ""; position: absolute; left: -4px; top: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }

/* franja de eventos día completo (jatto) */
.sem-allday {
  position: absolute; top: 3px; left: 4px; right: 4px; z-index: 3;
  background: color-mix(in srgb, var(--warn) 22%, var(--bg-elev));
  color: var(--warn-fg); font-size: 10px; font-weight: 700;
  padding: 3px 7px; border-radius: 5px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-left: 3px solid var(--warn);
}

/* bloques de evento */
.sem-ev {
  position: absolute; z-index: 2; border-radius: 7px; padding: 4px 8px;
  overflow: hidden; font-size: 11px; line-height: 1.25;
  box-shadow: var(--shadow-sm);
  transition: transform .1s, box-shadow .1s, filter .1s;
}
.sem-ev-time { display: block; font-size: 9.5px; opacity: .85; font-weight: 600; }
.sem-ev-name { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sem-ev-sub { font-size: 9.5px; opacity: .85; }

/* Visita = acento sólido, plano y limpio */
.sem-ev-visit {
  background: var(--accent); color: var(--accent-fg); cursor: pointer;
  border-left: 3px solid color-mix(in srgb, var(--accent) 60%, #000);
}
.sem-ev-visit:hover { transform: translateY(-1px); box-shadow: var(--shadow); z-index: 6; }

/* Jatto (bloqueado) = ámbar suave translúcido, no neón */
.sem-ev-jatto {
  background: color-mix(in srgb, var(--warn) 20%, var(--bg-elev));
  color: var(--warn-fg);
  border-left: 3px solid var(--warn);
}
.sem-ev-jatto:hover { transform: translateY(-1px); box-shadow: var(--shadow); z-index: 6; }
.sem-ev-crm-only { outline: 2px dashed color-mix(in srgb, var(--danger) 70%, white); }
.sem-allday { cursor: pointer; }

/* popup de detalle de evento */
.sem-detail-ov {
  position: fixed; inset: 0; z-index: var(--z-modal, 2000);
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.sem-detail {
  width: 100%; max-width: 420px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 18px 20px 16px; color: var(--fg);
}
.sem-d-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sem-d-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.sem-d-visit { background: var(--accent); color: var(--accent-fg); }
.sem-d-jatto { background: color-mix(in srgb, var(--warn) 22%, var(--bg-elev)); color: var(--warn-fg); }
.sem-d-x { background: none; border: 0; color: var(--fg-muted); font-size: 16px; cursor: pointer; line-height: 1; padding: 4px; }
.sem-d-x:hover { color: var(--fg); }
.sem-d-title { font-size: 18px; font-weight: 700; margin: 2px 0 6px; }
.sem-d-when { font-size: 13px; color: var(--fg-muted); margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.sem-d-meta { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.sem-d-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.sem-d-row span { color: var(--fg-subtle); }
.sem-d-row b { color: var(--fg); text-align: right; }
.sem-d-desc { border-top: 1px solid var(--line); padding-top: 10px; }
.sem-d-desc-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-subtle); margin-bottom: 5px; }
.sem-d-desc-b { font-size: 13.5px; line-height: 1.5; color: var(--fg); white-space: pre-wrap; word-break: break-word; }
.sem-d-empty { color: var(--fg-subtle); font-style: italic; font-size: 13px; }
.sem-d-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
