/* ═══════════════════════════════════════════════════════
   CALENDARIO — Estilos del módulo de agenda mensual
   ═══════════════════════════════════════════════════════ */

/* ── Navegación de mes ── */
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: 10px;
}
.cal-nav-center {
  display: flex; align-items: center; gap: 10px;
}
.cal-mes-label {
  font-size: 18px; font-weight: 700; color: var(--text);
  min-width: 200px; text-align: center; letter-spacing: -.3px;
}
.cal-nav-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.cal-nav-btn:hover { background: var(--surface-2); color: var(--text); }
.cal-hoy-btn {
  padding: 6px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .12s;
}
.cal-hoy-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Grid del calendario ── */
.cal-grid-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
}
.cal-header-row {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}
.cal-header-cell {
  padding: 8px 0; text-align: center;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-3);
}
.cal-header-cell:first-child { color: var(--accent); } /* Lunes resaltado */

.cal-body {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
}
.cal-cell {
  min-height: 100px; border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); padding: 6px 8px;
  cursor: pointer; transition: background .1s; position: relative;
  display: flex; flex-direction: column; gap: 3px;
}
.cal-cell:nth-child(7n) { border-right: none; } /* última col */
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.feriado { background: var(--surface-2); cursor: default; }
.cal-cell.feriado:hover { background: var(--surface-2); }
.cal-cell.hoy { background: var(--accent-bg); }
.cal-cell.hoy:hover { background: var(--accent-bg); filter: brightness(.97); }
.cal-cell.otro-mes { opacity: .35; pointer-events: none; }
.cal-cell.seleccionado { outline: 2px solid var(--accent); outline-offset: -2px; }

.cal-dia-num {
  font-size: 13px; font-weight: 600; color: var(--text);
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0;
}
.cal-cell.hoy .cal-dia-num {
  background: var(--accent); color: #fff;
}
.cal-cell.feriado .cal-dia-num { color: var(--text-3); }
.cal-feriado-label {
  font-size: 10px; color: var(--text-3); line-height: 1.25;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* Chips de eventos */
.cal-eventos {
  display: flex; flex-direction: column; gap: 2px; margin-top: 2px;
  overflow: hidden; flex: 1;
}
.cal-evento-chip {
  font-size: 10.5px; line-height: 1.3; padding: 1px 5px;
  border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--accent-bg); color: var(--accent-text); font-weight: 500;
}
.cal-evento-chip.tiene-trabajador { background: #dbeafe; color: #1d4ed8; }
.cal-mas {
  font-size: 10px; color: var(--text-3); padding-left: 2px;
}

/* ── Panel lateral de evento ── */
.cal-panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 100; display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 0;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.cal-panel {
  width: 380px; max-width: 100vw; height: 100vh; overflow-y: auto;
  background: var(--surface); box-shadow: -4px 0 24px rgba(0,0,0,.15);
  display: flex; flex-direction: column;
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.cal-panel-header {
  display: flex; align-items: center; gap: 10px; padding: 1.25rem;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.cal-panel-fecha {
  flex: 1; font-size: 15px; font-weight: 700; color: var(--text);
}
.cal-panel-feriado-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--surface-2); color: var(--text-3); font-weight: 500;
}
.cal-panel-body { flex: 1; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.cal-panel-footer {
  padding: 1rem 1.25rem; border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}

/* Lista de eventos del día */
.cal-evento-list { display: flex; flex-direction: column; gap: 8px; }
.cal-evento-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.cal-evento-item-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.cal-evento-item-title {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.cal-evento-item-meta {
  font-size: 11.5px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px;
}
.cal-evento-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; padding: 1px 7px; border-radius: 10px;
  background: var(--accent-bg); color: var(--accent-text); font-weight: 500;
}
.cal-evento-empty {
  text-align: center; padding: 1.5rem 0; color: var(--text-3); font-size: 13px;
}

@media (max-width: 700px) {
  .cal-panel { width: 100vw; }
  .cal-cell { min-height: 60px; padding: 4px; }
  .cal-evento-chip { display: none; }
  .cal-dia-num { font-size: 12px; width: 22px; height: 22px; }
}

/* ── Dark mode overrides ── */
html.dark .cal-grid-wrap {
  background: #161820;
  border-color: rgba(100,120,220,0.16);
}
html.dark .cal-header-cell { color: #4e5570; }
html.dark .cal-header-cell:first-child { color: #6b82ff; }

html.dark .cal-cell {
  border-color: rgba(100,120,220,0.10);
}
html.dark .cal-cell:hover { background: rgba(107,130,255,0.07); }
html.dark .cal-cell.feriado { background: #12141c; }
html.dark .cal-cell.hoy { background: rgba(107,130,255,0.12); }
html.dark .cal-cell.hoy .cal-dia-num { background: #3d5aff; }
html.dark .cal-dia-num { color: #c0c8e8; }
html.dark .cal-feriado-label { color: #4e5570; }

html.dark .cal-panel {
  background: #181a24;
  border-left: 1px solid rgba(107,130,255,0.15);
}
html.dark .cal-panel-header {
  border-bottom-color: rgba(100,120,220,0.14);
}
html.dark .cal-evento-item {
  background: #1e2130;
  border-color: rgba(100,120,220,0.14);
}
html.dark .cal-evento-badge {
  background: #1a2048;
  color: #a0b0ff;
}

/* ── Selector de vista ── */
.cal-view-tabs {
  display: flex; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 3px; gap: 2px;
}
.cal-view-tab {
  padding: 5px 14px; border-radius: calc(var(--radius-sm) - 2px);
  font-size: 12.5px; font-weight: 500; border: none; background: transparent;
  color: var(--text-2); cursor: pointer; transition: background .12s, color .12s;
}
.cal-view-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
html.dark .cal-view-tab.active { background: #1e2538; color: #a0b0ff; }

/* ── Vista SEMANA ── */
.cal-semana-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
}
.cal-semana-header {
  display: grid; grid-template-columns: 60px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}
.cal-semana-header-cell {
  padding: 8px 6px; text-align: center; font-size: 12px;
  border-right: 1px solid var(--border);
}
.cal-semana-header-cell:last-child { border-right: none; }
.cal-semana-header-cell .dow { font-weight: 600; text-transform: uppercase;
  font-size: 10.5px; letter-spacing: .5px; color: var(--text-3); }
.cal-semana-header-cell .dom {
  font-size: 20px; font-weight: 700; color: var(--text);
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin: 2px auto 0;
}
.cal-semana-header-cell.hoy .dom { background: var(--accent); color: #fff; }
.cal-semana-header-cell.feriado .dom { color: var(--text-3); }

.cal-semana-body {
  display: grid; grid-template-columns: 60px repeat(7, minmax(0, 1fr));
  min-height: 500px;
}
.cal-semana-time-col { border-right: 1px solid var(--border); }
.cal-semana-time-slot {
  height: 48px; display: flex; align-items: flex-start;
  padding: 4px 6px 0; font-size: 10px; color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.cal-semana-day-col {
  border-right: 1px solid var(--border); position: relative;
  cursor: pointer;
}
.cal-semana-day-col:last-child { border-right: none; }
.cal-semana-day-col:hover { background: var(--surface-2); }
.cal-semana-day-col.feriado { background: var(--surface-2); cursor: default; }
.cal-semana-day-col.feriado:hover { background: var(--surface-2); }
.cal-semana-slot {
  height: 48px; border-bottom: 1px solid var(--border);
  position: relative;
}
.cal-semana-evento {
  position: absolute; left: 2px; right: 2px;
  border-radius: 4px; padding: 2px 5px;
  font-size: 10.5px; font-weight: 500; line-height: 1.3;
  overflow: hidden; cursor: grab; z-index: 2;
  transition: opacity .15s, box-shadow .15s;
  user-select: none;
}
.cal-semana-evento:hover { box-shadow: 0 2px 8px rgba(0,0,0,.2); opacity: .9; }
.cal-semana-evento.dragging { opacity: .5; cursor: grabbing; }

/* ── Vista DÍA ── */
.cal-dia-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
}
.cal-dia-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.cal-dia-titulo { font-size: 18px; font-weight: 700; color: var(--text); }
.cal-dia-feriado { font-size: 12px; color: var(--text-3); padding: 2px 8px;
  border-radius: 10px; background: var(--surface-2); }
.cal-dia-body { display: grid; grid-template-columns: 60px 1fr; }
.cal-dia-slot { height: 56px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; padding: 4px 6px 0;
  font-size: 10.5px; color: var(--text-3); border-right: 1px solid var(--border); }
.cal-dia-col { position: relative; }
.cal-dia-hora-row { height: 56px; border-bottom: 1px solid var(--border); position: relative; cursor: pointer; }
.cal-dia-hora-row:hover { background: var(--accent-bg); }
.cal-dia-evento {
  position: absolute; left: 4px; right: 4px; border-radius: 6px;
  padding: 4px 8px; font-size: 12px; font-weight: 500; line-height: 1.4;
  cursor: grab; z-index: 2; transition: box-shadow .15s;
  user-select: none;
}
.cal-dia-evento:hover { box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.cal-dia-evento.dragging { opacity: .5; cursor: grabbing; }

/* ── Estado colores (compartido entre vistas) ── */
.ev-pendiente   { background: #e5e7eb; color: #374151; }
.ev-en_progreso { background: #fef3c7; color: #92400e; }
.ev-terminado   { background: #d1fae5; color: #065f46; }
html.dark .ev-pendiente   { background: #1e2538; color: #94a3b8; }
html.dark .ev-en_progreso { background: #422006; color: #fbbf24; }
html.dark .ev-terminado   { background: #064e3b; color: #6ee7b7; }

/* ── Drag & drop ── */
.cal-drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-bg) !important; }

html.dark .cal-semana-wrap,
html.dark .cal-dia-wrap { border-color: rgba(100,120,220,0.16); }
html.dark .cal-semana-time-slot,
html.dark .cal-semana-slot,
html.dark .cal-dia-slot,
html.dark .cal-dia-hora-row { border-color: rgba(100,120,220,0.10); }
html.dark .cal-semana-day-col,
html.dark .cal-semana-header-cell { border-color: rgba(100,120,220,0.10); }
html.dark .cal-semana-day-col:hover { background: rgba(107,130,255,0.07); }
html.dark .cal-dia-hora-row:hover { background: rgba(107,130,255,0.07); }

/* ═══ Carteles de la tarjeta: mismos tamaños de antes, colores más fuertes (v206) ═══ */
.cal-ev-tipo { background: #c7d2fe !important; color: #312e81 !important; }
.cal-ev-lbl { font-size: 11px; color: var(--text-2); }
.cal-ev-estado, .cal-ev-ot { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px; border: none; cursor: pointer; font-family: inherit; }
.cal-ev-estado:hover, .cal-ev-ot:hover { filter: brightness(.94); }
.cal-ev-estado.est-pendiente   { background: #fed7aa; color: #9a3412; }
.cal-ev-estado.est-en_progreso { background: #fde68a; color: #854d0e; }
.cal-ev-estado.est-terminado   { background: #bbf7d0; color: #166534; }
.cal-ev-ot { margin-left: auto; background: var(--accent); color: #fff; }
html.dark .cal-ev-tipo { background: #2e3a80 !important; color: #e0e7ff !important; }
html.dark .cal-ev-estado.est-pendiente   { background: #7c2d12; color: #fed7aa; }
html.dark .cal-ev-estado.est-en_progreso { background: #713f12; color: #fde68a; }
html.dark .cal-ev-estado.est-terminado   { background: #14532d; color: #bbf7d0; }

/* ── Modelos de orden de trabajo (v220) ── */
.otm-ayuda { font-size: 12.5px; color: var(--text-3); margin: -4px 0 12px; }
.otm-hint { font-size: 11.5px; color: var(--text-3); margin: 2px 0 6px; }
.otm-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.otm-item-nombre { font-weight: 600; font-size: 14px; color: var(--text); }
.otm-item-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.otm-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-bg); color: var(--accent-text); }
.otm-chip.gral { background: var(--surface-2); color: var(--text-2); }
.otm-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.otm-fila { display: flex; gap: 6px; align-items: center; }
.otm-fila .form-input { margin: 0; flex: 1; }
.otm-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.otm-vacio { text-align: center; color: var(--text-3); padding: 22px; font-size: 13px; }

/* v221: trabajos terminados tachados */
.ev-hecho, .ev-hecho * { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.ev-hecho { opacity: .7; }

/* v230: acciones de la OT en cada trabajo */
.cal-ot-acciones { margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-ot-mini { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.cal-ot-mini:hover { background: var(--surface-2); color: var(--text); }
.cal-ot-subir { border: 1px dashed var(--accent) !important; color: var(--accent-text) !important; background: var(--accent-bg) !important; font-weight: 600; }
.cal-ot-adj { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 3px 4px 3px 8px; border-radius: 6px;
  background: #dcfce7; color: #166534; max-width: 100%; }
html.dark .cal-ot-adj { background: #14532d; color: #bbf7d0; }
.cal-ot-adj a { color: inherit; text-decoration: underline; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ot-quitar { border: none; background: none; color: inherit; cursor: pointer; opacity: .7; font-size: 12px; padding: 0 2px; }
.cal-ot-quitar:hover { opacity: 1; }

/* ── v234: vista semana / día por filas de horario (sin horas vacías) ── */
.cal-sem2 { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.cal-sem2-row { display: grid; grid-template-columns: 64px repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.cal-sem2-row:last-child { border-bottom: none; }
.cal-sem2-head { background: var(--surface-2); }
.cal-sem2-time { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 8px 6px; text-align: right; border-right: 1px solid var(--border); }
.cal-sem2-hcell { text-align: center; padding: 8px 4px; border-right: 1px solid var(--border); cursor: pointer; }
.cal-sem2-hcell:last-child, .cal-sem2-cell:last-child { border-right: none; }
.cal-sem2-hcell .dow { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; }
.cal-sem2-hcell .dom { font-size: 17px; font-weight: 700; color: var(--text); }
.cal-sem2-hcell.hoy .dom { color: var(--accent); }
.cal-sem2-hcell .fer { font-size: 9px; color: #b45309; margin-top: 1px; line-height: 1.15; }
.cal-sem2-hcell.feriado, .cal-sem2-cell.feriado { background: rgba(245, 158, 11, .06); }
.cal-sem2-cell { border-right: 1px solid var(--border); padding: 4px; min-height: 52px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; min-width: 0; }
.cal-sem2-cell:hover { background: var(--surface-2); }
.cal-sem2-cell.vacia { min-height: 80px; }
.cal-sem2-vacio { text-align: center; padding: 14px; font-size: 12.5px; color: var(--text-3); border-top: 1px solid var(--border); }
.cal-bloque { border-radius: 6px; padding: 4px 6px; font-size: 10.5px; cursor: grab; background: var(--accent-bg); color: var(--accent-text);
  border-left: 3px solid var(--accent); min-width: 0; }
.cal-bloque .l1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cal-bloque .l1 b { font-weight: 700; opacity: .85; }
.cal-bloque .l1 small { font-weight: 500; opacity: .7; font-size: 10px; }
.cal-bloque .l2 { font-size: 9.5px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.cal-bloque .l2 i { font-size: 9px; }
.cal-bloque.grande { font-size: 12.5px; padding: 7px 10px; }
.cal-bloque.grande .l2 { font-size: 11px; }
.cal-dia2 { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; margin-top: 10px; }
.cal-dia2-row { display: grid; grid-template-columns: 64px 1fr; border-bottom: 1px solid var(--border); }
.cal-dia2-row:last-child { border-bottom: none; }
.cal-dia2-cell { padding: 6px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 760px) { .cal-sem2 { overflow-x: auto; } .cal-sem2-row { min-width: 720px; } }

/* v234: menú de aviso en el trabajo */
.cal-aviso-wrap { position: relative; display: inline-flex; }
.cal-aviso-menu { position: fixed; z-index: 2500; min-width: 240px; background: var(--surface);
  border: 1px solid var(--border-md); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); padding: 4px; display: flex; flex-direction: column; }
.cal-aviso-menu button { display: flex; gap: 8px; align-items: center; text-align: left; border: none; background: none; padding: 7px 10px;
  font-size: 12.5px; color: var(--text); border-radius: 6px; cursor: pointer; }
.cal-aviso-menu button:hover { background: var(--surface-2); }
.cal-aviso-menu .ti-brand-whatsapp { color: #16a34a; }

/* v237: columnas del mes siempre del mismo ancho (el contenido no las estira) */
.cal-cell { min-width: 0; overflow: hidden; }
.cal-evento-chip { max-width: 100%; min-width: 0; }
.cal-header-cell { min-width: 0; }
