/* ============================================================
   Llamadas-IA · Sistema de diseño
   - brand (azul corporativo #305485): identidad, navegación, KPIs neutros
   - accent (naranja #f97316): atención, CTAs primarias, métricas activas
   ============================================================ */

.nav-link.active {
    background-color: rgba(48, 84, 133, 0.3);
    color: #fff;
}

.fade-in {
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ----------- Status badges (semántica unificada) ------------
   Naranja  -> requiere atención / en proceso / pendiente acción humana
   Verde    -> éxito / cerrado positivamente
   Rojo     -> error / fallo / crítico
   Azul     -> neutral / informativo
   Gris     -> archivado / sin actividad
   ------------------------------------------------------------ */

/* atención / en proceso */
.status-activa,
.status-pending,
.status-pendiente,
.status-in_progress,
.status-syncing,
.status-started,
.status-queued,
.status-refreshing_in_progress { background-color: #ffedd5; color: #9a3412; }

/* éxito */
.status-resuelta,
.status-resolved,
.status-synced,
.status-complete,
.status-completed,
.status-ended { background-color: #d1fae5; color: #065f46; }

/* error / fallo */
.status-error,
.status-failed,
.status-cancelled { background-color: #fee2e2; color: #991b1b; }

/* archivado */
.status-removed { background-color: #e5e7eb; color: #4b5563; }

input:focus, select:focus, textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(48, 84, 133, 0.15);
}

table th {
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

/* ----------- Utilidades de página (compactas y consistentes) ------------ */

/* Encabezado de página: más fino que antes (text-2xl en vez de text-3xl) */
.page-header h1 {
    font-size: 1.5rem;        /* 24px */
    line-height: 2rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.25rem;
}
.page-header p {
    color: #4b5563;
    font-size: 0.875rem;
}

/* KPI card: padding compacto, hover acento */
.kpi-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    transition: box-shadow .15s, border-color .15s;
}
.kpi-card:hover { box-shadow: 0 4px 12px -2px rgba(0,0,0,.06); border-color: #d1d5db; }
.kpi-card .kpi-label { font-size: 0.75rem; color: #6b7280; font-weight: 500; text-transform: uppercase; letter-spacing: .025em; margin-bottom: 0.25rem; }
.kpi-card .kpi-value { font-size: 1.5rem; line-height: 2rem; font-weight: 700; color: #111827; }
.kpi-card .kpi-sub   { font-size: 0.75rem; color: #6b7280; margin-top: 0.125rem; }

/* KPI card destacada (accent): para métricas activas que requieren mirada */
.kpi-card-accent {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 1px solid #fed7aa;
}
.kpi-card-accent .kpi-value { color: #9a3412; }
.kpi-card-accent .kpi-label { color: #c2410c; }

/* KPI card de alerta (alarmas, fallos): naranja oscuro con pulse sutil */
.kpi-card-alert {
    background: #fff7ed;
    border: 1px solid #fdba74;
}
.kpi-card-alert .kpi-value { color: #c2410c; font-weight: 800; }
.kpi-card-alert .kpi-label { color: #9a3412; }

/* Contador "badge" naranja (sidebar, headers) */
.badge-count-accent {
    background: #f97316;
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.125rem 0.4rem;
    border-radius: 9999px;
    line-height: 1;
    min-width: 1.25rem;
    text-align: center;
    display: inline-block;
}

/* Punto pulsante para indicar "vivo / en proceso" */
.dot-pulse {
    width: 8px; height: 8px; border-radius: 9999px;
    background: #f97316;
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.6);
    animation: dotPulse 1.6s infinite;
    display: inline-block;
}
@keyframes dotPulse {
    0%   { box-shadow: 0 0 0 0   rgba(249,115,22,0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(249,115,22,0);   }
    100% { box-shadow: 0 0 0 0   rgba(249,115,22,0);   }
}

/* Botón CTA primario (acciones importantes que abren formularios o lanzan acciones) */
.btn-accent {
    background: #f97316;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn-accent:hover { background: #ea580c; }

/* Botón secundario (azul brand, mantiene estética actual) */
.btn-primary {
    background: #294872;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn-primary:hover { background: #1b2e48; }

/* ----------- Tooltip IA (sin cambios) ------------ */

@keyframes pulse {
    from { height: 20%; opacity: 0.3; }
    to { height: 100%; opacity: 0.8; }
}

.ai-tooltip {
    cursor: help;
}

#ai-tooltip-container {
    position: fixed;
    background: linear-gradient(135deg, #305485 0%, #1b2e48 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-line;
    max-width: 320px;
    min-width: 280px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 99999;
    font-weight: 500;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

#ai-tooltip-container.show {
    opacity: 1;
    transform: translateY(0);
}

#ai-tooltip-container::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1b2e48;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(-8px);
    }
}

/* ===========================================================
   CALENDARIO LABORAL
   =========================================================== */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}
.calendar-cell {
    min-height: 86px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 8px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}
.calendar-cell:hover {
    border-color: #fb923c;
    background: #fff7ed;
}
.calendar-cell.outside {
    background: #f9fafb;
    color: #9ca3af;
    cursor: default;
}
.calendar-cell.outside:hover {
    border-color: #e5e7eb;
    background: #f9fafb;
}
.calendar-cell.weekend {
    background: #f3f4f6;
}
.calendar-cell.today {
    border: 2px solid #305485;
    box-shadow: 0 0 0 1px rgba(48,84,133,0.15);
}
.calendar-cell .cell-day {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1f2937;
    margin-bottom: 4px;
}
.calendar-cell.outside .cell-day {
    color: #9ca3af;
}
.calendar-cell .cell-tag {
    font-size: 0.65rem;
    line-height: 1.1;
    padding: 2px 5px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
    align-self: flex-start;
}
.calendar-cell .cell-name {
    font-size: 0.7rem;
    line-height: 1.2;
    color: #4b5563;
    margin-top: 2px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Tipos de día */
.cell-type-holiday_national { background: #fef2f2; border-color: #fecaca; }
.cell-type-holiday_national .cell-tag { background: #fee2e2; color: #b91c1c; }
.cell-type-holiday_regional { background: #fff7ed; border-color: #fed7aa; }
.cell-type-holiday_regional .cell-tag { background: #ffedd5; color: #c2410c; }
.cell-type-holiday_local { background: #fefce8; border-color: #fde68a; }
.cell-type-holiday_local .cell-tag { background: #fef3c7; color: #a16207; }
.cell-type-company_closure { background: #f5f3ff; border-color: #ddd6fe; }
.cell-type-company_closure .cell-tag { background: #ede9fe; color: #6d28d9; }
.cell-type-special_hours { background: #ecfeff; border-color: #a5f3fc; }
.cell-type-special_hours .cell-tag { background: #cffafe; color: #0e7490; }
.cell-type-working_day { background: #f0fdf4; border-color: #bbf7d0; }
.cell-type-working_day .cell-tag { background: #dcfce7; color: #15803d; }

.legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid;
}
.legend-pill .swatch { width: 10px; height: 10px; border-radius: 3px; }

.office-status-open { background: #dcfce7; color: #15803d; }
.office-status-closed { background: #fee2e2; color: #b91c1c; }

/* Estados de periodos de facturación */
.billing-status-open            { background: #dbeafe; color: #1d4ed8; }
.billing-status-open_unclosed   { background: #fef3c7; color: #b45309; }
.billing-status-closed          { background: #e5e7eb; color: #374151; }
.billing-status-invoiced        { background: #fef3c7; color: #92400e; }
.billing-status-paid            { background: #dcfce7; color: #15803d; }
