/* ══════════════════════════════════════════════════════
   TAS Optima v2 — Paleta centralizada
   Cambiar aquí afecta a toda la app.
   ══════════════════════════════════════════════════════ */
:root {
  /* Primarios (sidebar, botones principales, selección activa) */
  --color-primary: #1a2d4a;        /* navy azulado oscuro */
  --color-primary-hover: #2d445e;   /* hover */
  --color-on-primary: #ffffff;     /* texto sobre primario */

  /* Acento (hover, highlights, links activos, checkboxes, CTA) */
  --color-accent: #4ea8cd;         /* azul cielo/acero */
  --color-accent-hover: #3b92b5;
  --color-on-accent: #0a1a2d;

  /* Superficies (claro, neutro frío) */
  --color-bg: #f5f7f8;
  --color-surface: #eceff0;
  --color-surface-2: #e5e8ea;
  --color-border: #cbc4d3;

  /* Texto */
  --color-text: #1d1a21;
  --color-text-muted: #6b7280;

  /* Estado */
  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-success-border: #b7dfc2;
  --color-success-text: #1e7e34;
  --color-danger: #ba1a1a;
  --color-danger-bg: #fee2e2;
  --color-danger-border: #f5c6c6;
  --color-warning-bg: #fef7e6;
  --color-warning-text: #b87a00;
  --color-warning-border: #fce4a8;
}

/* ── Global (from base.html) ── */
body { background-color: var(--color-bg); color: var(--color-text); font-family: "Inter", sans-serif; }
.htmx-indicator { display: none !important; }
.htmx-request .htmx-indicator { display: flex !important; }
.htmx-request.htmx-indicator { display: flex !important; }
[x-cloak] { display: none !important; }

/* ── Admin: Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1.25rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 600; border: none; cursor: pointer; transition: all 0.2s; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-surface-2); }
.btn-success { background: var(--color-success); color: var(--color-on-primary); }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-outline { background: transparent; color: var(--color-primary); border: 1.5px solid var(--color-primary); }
.btn-outline:hover { background: rgba(26,46,53,0.05); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #a01818; }
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }

/* ── Ciclos ── */
.cycle-row { cursor: pointer; transition: background-color 0.15s; }
.cycle-row:hover { background-color: var(--color-surface); }
.badge-active { background: #e8f5e9; color: #2e7d32; font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge-closed { background: #f3f0f0; color: #666; font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.filter-btn { padding: 6px 16px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--color-border); background: white; color: var(--color-text); cursor: pointer; transition: all 0.15s; }
.filter-btn.active { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }

/* ── Calendario FullCalendar ── */
.fc { font-family: "Inter", sans-serif; font-size: 0.875rem; }
.fc .fc-toolbar-title { font-family: "Hanken Grotesk", sans-serif; font-size: 1.25rem; font-weight: 600; }
.fc .fc-button-primary { background-color: var(--color-primary); border-color: var(--color-primary); }
.fc .fc-button-primary:not(:disabled):hover,
.fc .fc-button-primary:not(:disabled).fc-button-active { background-color: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.fc .fc-button-primary:disabled { background-color: var(--color-border); border-color: var(--color-border); opacity: 0.6; }
.fc .fc-today-button { background-color: var(--color-accent) !important; border-color: var(--color-accent) !important; }
.fc .fc-today-button:hover:not(:disabled) { background-color: var(--color-accent-hover) !important; border-color: var(--color-accent-hover) !important; }
.fc .fc-day-today { background-color: rgba(78,205,196,0.10) !important; }
.fc .fc-now-indicator { border-color: var(--color-danger); }
.fc .fc-non-business { background-color: rgba(0,0,0,0.02); }
.fc .fc-highlight { background-color: rgba(26,46,53,0.10); }
.fc .*** { border-color: var(--color-border); }
.fc th { font-weight: 500; }
.fc .fc-col-header-cell { background-color: var(--color-primary); color: var(--color-on-primary); padding: 0.5rem 0; }
.fc .fc-col-header-cell-cushion { color: var(--color-on-primary); text-decoration: none; text-transform: capitalize; }
.fc .fc-daygrid-day-number { color: var(--color-text); font-weight: 500; font-size: 0.875rem; text-decoration: none; padding: 4px 6px; }
.fc .fc-day-other .fc-daygrid-day-number { color: #7a7582; opacity: 0.6; }
.fc-event { border-radius: 0.25rem; font-size: 0.75rem; padding: 2px 5px; cursor: pointer; border: none !important; line-height: 1.3; }
.fc-event:hover { filter: brightness(0.92); }
.fc-daygrid-dot-event { padding: 2px 4px; }
.fc .fc-view-harness { background-color: #ffffff; }
.fc .fc-more-popover { border: 1px solid var(--color-border); border-radius: 0.5rem; box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.fc .fc-popover-header { background-color: var(--color-surface); padding: 0.5rem 0.75rem; }
.fc .fc-daygrid-more-link { color: var(--color-primary); font-weight: 500; }

/* ── Visitas ── */
.status-pending { background: #fff8e1; color: #f57f17; }
.status-completed { background: #e8f5e9; color: #2e7d32; }
.status-cancelled { background: #ffebee; color: #c62828; }
.status-no_show { background: #f5f5f5; color: #616161; }
.visit-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.filter-pill { padding: 6px 16px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--color-border); background: white; color: var(--color-text); cursor: pointer; transition: all 0.15s; }
.filter-pill.active { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.category-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; text-transform: uppercase; }
.cat-10A { background: #e8f5e9; color: #2e7d32; }
.cat-20B { background: #fff3e0; color: #e65100; }
.cat-20C { background: #e3f2fd; color: #1565c0; }

/* ── Importar ── */
.card { background: rgba(255,255,255,0.8); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 0.75rem; border: 1px solid var(--color-border); padding: 1.5rem; margin-bottom: 1.5rem; }
.upload-zone { border: 2px dashed var(--color-border); border-radius: 0.75rem; padding: 2rem; text-align: center; cursor: pointer; transition: all 0.2s; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--color-primary); background: rgba(26,46,53,0.05); }
.upload-zone .icon { font-size: 2.5rem; color: var(--color-text-muted); margin-bottom: 0.75rem; }
.upload-zone p { color: var(--color-text-muted); font-size: 0.875rem; }
.upload-zone .filename { color: var(--color-primary); font-weight: 600; margin-top: 0.5rem; }
.upload-zone input[type="file"] { display: none; }
.stats-bar { display: flex; gap: 1.5rem; margin-bottom: 1rem; }
.stat { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.stat .count { font-weight: 700; font-size: 1.25rem; }
.stat.valid .count { color: var(--color-success); }
.stat.invalid .count { color: var(--color-danger); }
.stat.total .count { color: var(--color-primary); }
.table-wrapper { overflow-x: auto; max-height: 400px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: 0.75rem; }
.table-wrapper table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.table-wrapper th { background: var(--color-primary); color: var(--color-on-primary); padding: 0.75rem; text-align: left; font-weight: 600; position: sticky; top: 0; }
.table-wrapper td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--color-border); }
.table-wrapper tr:hover { background: #f9fafb; }
.table-wrapper tr.error { background: #fef2f2; }
.table-wrapper tr.valid { background: #f0fdf4; }
.badge { display: inline-block; padding: 0.125rem 0.5rem; border-radius: 9999px; font-size: 0.7rem; font-weight: 600; }
.badge.success { background: var(--color-success-bg); color: var(--color-success); }
.badge.error { background: var(--color-danger-bg); color: var(--color-danger); }
.actions { display: flex; gap: 1rem; justify-content: flex-end; margin-top: 1rem; }
.progress { margin-top: 1rem; }
.progress-bar { height: 8px; background: var(--color-border); border-radius: 4px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--color-primary); transition: width 0.3s; }
.progress-text { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.result { padding: 1rem; border-radius: 0.5rem; margin-top: 1rem; font-size: 0.875rem; }
.result.success { background: var(--color-success-bg); border: 1px solid var(--color-success); }
.result.error { background: var(--color-danger-bg); border: 1px solid var(--color-danger); }
.template-link { color: var(--color-accent); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 0.25rem; }
.template-link:hover { text-decoration: underline; }
.info-text { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.5rem; }
.pagination { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; font-size: 0.8rem; color: var(--color-text-muted); }
.pagination button { padding: 0.25rem 0.75rem; border: 1px solid var(--color-border); border-radius: 4px; background: #ffffff; cursor: pointer; font-size: 0.8rem; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button:hover:not(:disabled) { background: #f3f4f6; }

/* ── Admin: Data Management ── */
.progress-bar-admin { height: 0.5rem; background: var(--color-surface); border-radius: 9999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-primary); border-radius: 9999px; transition: width 0.5s ease; }
.tab-btn { padding: 0.5rem 1.25rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: all 0.2s; border: 1px solid transparent; background: transparent; color: #494551; }
.tab-btn:hover { background: rgba(26,46,53,0.05); color: var(--color-primary); }
.tab-btn.active { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.tool-card { border: 1px solid var(--color-surface); border-radius: 0.75rem; padding: 1.25rem; margin-bottom: 1rem; background: #fff; }
.tool-card h3 { margin-bottom: 0.5rem; color: var(--color-text); font-size: 1rem; font-weight: 600; }
.tool-card p { color: #494551; font-size: 0.875rem; margin-bottom: 1rem; }
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-box { flex: 1; min-width: 180px; background: #fff; border: 1px solid var(--color-surface); border-radius: 0.75rem; padding: 1rem 1.25rem; }
.stat-box .label { font-size: 0.75rem; color: #7a7582; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-box .value { font-size: 1.5rem; font-weight: 700; color: var(--color-primary); margin-top: 0.25rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; padding: 0.625rem 0.75rem; border-bottom: 2px solid var(--color-surface); color: #494551; font-weight: 600; }
td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--color-surface); }
.spinner { display: inline-block; animation: spin 1s linear infinite; font-size: 1.25rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-inline { padding: 0.75rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.toast-success { background: #e6f4ea; color: var(--color-success-text); border: 1px solid var(--color-success-border); }
.toast-error { background: #fce4e4; color: var(--color-danger); border: 1px solid var(--color-danger-border); }
.toast-warning { background: var(--color-warning-bg); color: var(--color-warning-text); border: 1px solid var(--color-warning-border); }
.empty-state { text-align: center; padding: 3rem 1rem; color: #7a7582; }
.empty-state .material-symbols-outlined { font-size: 3rem; margin-bottom: 0.75rem; }

/* ══════════════════════════════════════════════════════
   Calendario (migrado de calendario.html block head)
   ══════════════════════════════════════════════════════ */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: var(--color-border);
    border: 1px solid var(--color-border);
}
.calendar-header-cell {
    background-color: var(--color-primary);
    color: white;
    text-align: center;
    padding: 8px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.calendar-cell {
    background-color: #ffffff;
    min-height: 80px;
    padding: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
    position: relative;
}
.calendar-cell:hover {
    background-color: var(--color-surface);
}
.calendar-cell.today {
    background-color: rgba(26,46,53,0.06);
    box-shadow: inset 0 0 0 2px var(--color-primary);
}
.calendar-cell.other-month {
    background-color: var(--color-surface);
    color: #7a7582;
}
.calendar-cell.selected {
    box-shadow: inset 0 0 0 2px var(--color-accent);
}
.cell-date {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.cell-day-number {
    font-size: 0.625rem;
    color: var(--color-accent);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.event-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 2px;
}
.event-planned { background-color: var(--color-accent); }
.event-done { background-color: #22c55e; }
.event-skipped { background-color: #9ca3af; }
.event-locked { background-color: var(--color-primary); }
.event-chip {
    font-size: 0.625rem;
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 2px;
    line-height: 1.2;
    border-left: 3px solid;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.event-chip.planned {
    background-color: rgba(78,205,196,0.12);
    border-left-color: var(--color-accent);
    color: var(--color-on-accent);
}
.event-chip.done {
    background-color: #dcfce7;
    border-left-color: #22c55e;
    color: #166534;
}
.event-chip.skipped {
    background-color: #f3f4f6;
    border-left-color: #9ca3af;
    color: #4b5563;
}
.event-chip.locked {
    background-color: rgba(26,46,53,0.08);
    border-left-color: var(--color-primary);
    color: var(--color-primary);
}
.route-panel {
    width: 24rem;
    border-left: 1px solid var(--color-border);
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.stop-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--color-surface);
    cursor: pointer;
    transition: background-color 0.15s;
}
.stop-item:hover {
    background-color: var(--color-surface);
}
.stop-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Leaflet map override (migrado de calendario.html) ── */
#map {
    min-height: 256px;
    width: 100%;
}

/* ══════════════════════════════════════════════════════
   Directorio HCP (migrado de hcp_directorio_v2.html block head)
   ══════════════════════════════════════════════════════ */
.hcp-row { cursor: pointer; transition: background-color 0.15s; }
.hcp-row:hover { background-color: var(--color-surface); }
.geo-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.geo-ok { background: #dcfce7; color: #166534; }
.geo-no { background: #fef3c7; color: #92400e; }
.bulk-bar {
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.sort-btn { transition: color 0.15s; }
.sort-btn:hover { color: var(--color-accent); }
.sort-active { color: var(--color-accent); font-weight: 700; }
.active-filter {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: 0.7rem;
    font-weight: 600; background: rgba(26,46,53,0.1); color: var(--color-primary);
    cursor: pointer; transition: background 0.15s;
}
.active-filter:hover { background: rgba(26,46,53,0.18); }

/* ══════════════════════════════════════════════════════
   Perfil HCP (migrado de hcp_profile_v2.html block head)
   ══════════════════════════════════════════════════════ */
#profile-map { height: 350px; border-radius: 0.75rem; }
.detail-card { background: white; border-radius: 0.75rem; border: 1px solid var(--color-surface-2); }
.detail-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; color: #494551; letter-spacing: 0.04em; }
.detail-value { color: var(--color-text); }
.profile-tab {
    position: relative; padding: 0.75rem 1.5rem; font-size: 0.875rem; font-weight: 600;
    color: #494551; cursor: pointer; transition: color 0.15s;
    border-bottom: 2px solid transparent; background: none; border-top: none; border-left: none; border-right: none;
}
.profile-tab:hover { color: var(--color-primary); }
.profile-tab.active {
    color: var(--color-primary); border-bottom-color: var(--color-primary);
}
.profile-tab .tab-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.25rem; height: 1.25rem; padding: 0 4px;
    border-radius: 999px; font-size: 0.65rem; font-weight: 700;
    background: rgba(26,46,53,0.1); color: var(--color-primary); margin-left: 6px;
}
.timeline-item { position: relative; padding-left: 2rem; padding-bottom: 1.5rem; }
.timeline-dot {
    position: absolute; left: 0; top: 0.35rem;
    width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid white; box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}
.timeline-dot.completed { background: #2e7d32; }
.timeline-dot.pending { background: #e65100; }
.timeline-dot.cancelled { background: #c62828; }
.timeline-dot.no_show { background: #757575; }
.timeline-line {
    position: absolute; left: 5px; top: 1rem; width: 2px; bottom: 0;
    background: var(--color-surface-2);
}
.route-card { transition: transform 0.15s, box-shadow 0.15s; }
.route-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
@media (max-width: 640px) {
    .profile-grid { grid-template-columns: 1fr !important; }
    .detail-card { margin-bottom: 0.75rem; }
    .profile-tab { padding: 0.5rem 1rem; font-size: 0.8rem; }
}

/* ══════════════════════════════════════════════════════
   Optimizador (migrado de optimizador_v2.html block head)
   ══════════════════════════════════════════════════════ */
/* Note: .stop-item base styles are shared from Calendario section above.
   Optimizador adds drag-only styles: */
.stop-item.drag-over {
    border-top: 2px solid var(--color-primary);
}
.day-tab-active {
    background-color: var(--color-primary);
    color: white;
}
.kpi-card {
    background: linear-gradient(135deg, var(--color-surface) 0%, #ffffff 100%);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1rem;
}

/* ── RouteMap (migrado de optimizador_v2.html) ── */
#routeMap { height: 350px; width: 100%; border-radius: 0.75rem; z-index: 1; }
@media (max-width: 768px) {
    #routeMap { height: 250px; }
}
