/* public/css/main.css */
:root {
    /* Colores Principales extraídos de los requerimientos */
    --bg-body: #e2e8f0;
    --bg-card: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --brand-primary: #2563eb;
    --brand-primary-hover: #1d4ed8;
    --brand-success: #10b981;
    --brand-success-hover: #059669;
    --brand-accent: #1e293b;
    --brand-danger: #ef4444;
    --border-color: #cbd5e1;
    --header-bg: #f8fafc;
    
    /* Layout Variables */
    --sidebar-width: 250px;
    --header-height: 70px;
    --font-family-base: 'Inter', sans-serif;
}

body {
    font-family: var(--font-family-base);
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* Base Layout Wrapper */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* Header */
.app-header {
    background-color: var(--bg-card);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--brand-accent);
    letter-spacing: -0.5px;
    margin: 0;
}

/* Sidebar Toggle Button (Desktop & Mobile) */
.btn-sidebar-toggle {
    background: transparent;
    border: none;
    font-size: 1.15rem;
    color: var(--brand-accent);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.btn-sidebar-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--brand-primary);
}

.btn-sidebar-toggle:active {
    transform: scale(0.92);
}

[data-bs-theme="dark"] .btn-sidebar-toggle {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .btn-sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #60a5fa;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--brand-accent);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    white-space: nowrap;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
}

/* Preload state to avoid animation jump on initial load */
html.sidebar-collapsed-preload .app-sidebar {
    transition: none !important;
}

@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
    }

    .app-wrapper.sidebar-collapsed .app-sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        visibility: hidden;
    }
}

.sidebar-header {
    height: var(--header-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.app-sidebar > nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

/* Widget fijo inferior: Volver a Llamar */
.sidebar-callbacks-panel {
    flex: 0 0 auto;
    background: rgba(15, 23, 42, 0.72);
    border-top: 2px solid rgba(148, 163, 184, 0.25);
    display: flex;
    flex-direction: column;
    white-space: normal;
    transition: border-color 0.25s ease, background 0.25s ease;
}

.sidebar-callbacks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 9px 12px;
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #ffffff;
    transition: background 0.25s ease;
}

/* Estado SIN pendientes: fondo verde pastel suave y colapsado */
.sidebar-callbacks-panel.cb-state-clear {
    border-top-color: #6ee7b7;
}

.sidebar-callbacks-panel.cb-state-clear .sidebar-callbacks-header {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border-bottom: none;
}

.sidebar-callbacks-panel.cb-state-clear .sidebar-callbacks-list {
    display: none;
}

.sidebar-callbacks-panel.cb-state-clear .sidebar-callbacks-count {
    background: rgba(6, 95, 70, 0.14);
    color: #065f46;
}

.sidebar-callbacks-panel.cb-state-clear .sidebar-cb-btn {
    background: rgba(6, 95, 70, 0.08);
    border-color: rgba(6, 95, 70, 0.22);
    color: #065f46;
}

.sidebar-callbacks-panel.cb-state-clear .sidebar-cb-btn:hover,
.sidebar-callbacks-panel.cb-state-clear .sidebar-cb-btn.active {
    background: #065f46;
    border-color: #065f46;
    color: #ffffff;
}

/* Estado CON pendientes (hoy / próximos): ámbar llamativo y siempre abierto */
.sidebar-callbacks-panel.cb-state-pending {
    border-top-color: #fbbf24;
    box-shadow: 0 -4px 14px rgba(217, 119, 6, 0.25);
}

.sidebar-callbacks-panel.cb-state-pending .sidebar-callbacks-header {
    background: linear-gradient(135deg, #ea580c 0%, #d97706 100%);
}

.sidebar-callbacks-panel.cb-state-pending .sidebar-callbacks-count {
    background: #ffffff;
    color: #c2410c;
}

/* Estado CON futuros (+7d): azul informativo y abierto */
.sidebar-callbacks-panel.cb-state-future {
    border-top-color: #60a5fa;
    box-shadow: 0 -4px 14px rgba(37, 99, 235, 0.25);
}

.sidebar-callbacks-panel.cb-state-future .sidebar-callbacks-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.sidebar-callbacks-panel.cb-state-future .sidebar-callbacks-count {
    background: #ffffff;
    color: #1d4ed8;
}

/* Estado CON vencidas: rojo urgente y siempre abierto */
.sidebar-callbacks-panel.cb-state-overdue {
    border-top-color: #f87171;
    box-shadow: 0 -4px 16px rgba(220, 38, 38, 0.35);
}

.sidebar-callbacks-panel.cb-state-overdue .sidebar-callbacks-header {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.sidebar-callbacks-panel.cb-state-overdue .sidebar-callbacks-count {
    background: #ffffff;
    color: #b91c1c;
    animation: cbPulse 1.4s ease-in-out infinite;
}

/* Estado CON registros ya todos contactados: verde abierto */
.sidebar-callbacks-panel.cb-state-done {
    border-top-color: #34d399;
    box-shadow: 0 -4px 14px rgba(16, 185, 129, 0.22);
}

.sidebar-callbacks-panel.cb-state-done .sidebar-callbacks-header {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
}

.sidebar-callbacks-panel.cb-state-done .sidebar-callbacks-count {
    background: #ffffff;
    color: #047857;
}

.sidebar-callbacks-datebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.55);
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    font-size: 10px;
    color: #cbd5e1;
}

.sidebar-callbacks-panel.cb-state-clear .sidebar-callbacks-datebar {
    background: rgba(6, 95, 70, 0.1);
    color: #065f46;
    border-bottom-color: rgba(6, 95, 70, 0.18);
}

.sidebar-cb-date {
    flex: 1 1 auto;
    min-width: 0;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #f8fafc;
    border-radius: 4px;
    font-size: 10px;
    padding: 1px 5px;
    line-height: 1.3;
    color-scheme: dark;
}

.sidebar-callbacks-panel.cb-state-clear .sidebar-cb-date {
    background: #ffffff;
    color: #065f46;
    border-color: rgba(6, 95, 70, 0.3);
    color-scheme: light;
}

@keyframes cbPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.sidebar-callbacks-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.sidebar-callbacks-count {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    line-height: 1.4;
}

.sidebar-callbacks-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.sidebar-cb-btn {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    cursor: pointer;
    line-height: 1.2;
    transition: all 0.15s ease;
}

.sidebar-cb-btn:hover,
.sidebar-cb-btn.active {
    background: #ffffff;
    border-color: #ffffff;
    color: #0f172a;
}

.sidebar-callbacks-list {
    max-height: 215px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px 6px 6px 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

.sidebar-cb-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 5px 7px;
    margin-bottom: 3px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid #38bdf8;
    transition: background 0.15s ease;
}

.sidebar-cb-item:hover {
    background: rgba(255, 255, 255, 0.11);
}

.sidebar-cb-item.cb-vencida {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.14);
}

.sidebar-cb-item.cb-vencida:hover {
    background: rgba(239, 68, 68, 0.24);
}

.sidebar-cb-item.cb-hoy {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.11);
}

.sidebar-cb-item.cb-hoy:hover {
    background: rgba(245, 158, 11, 0.2);
}

.sidebar-cb-item.cb-contactado {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.12);
}

.sidebar-cb-item.cb-contactado:hover {
    background: rgba(16, 185, 129, 0.22);
}

.sidebar-cb-status-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 3px;
}

.sidebar-cb-tag {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.25;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.15px;
    white-space: nowrap;
}

.sidebar-cb-tag.tag-pending {
    background: rgba(148, 163, 184, 0.22);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.sidebar-cb-tag.tag-nocontact {
    background: rgba(245, 158, 11, 0.24);
    color: #fde68a;
    border: 1px solid rgba(245, 158, 11, 0.45);
}

.sidebar-cb-tag.tag-contact {
    background: rgba(16, 185, 129, 0.24);
    color: #a7f3d0;
    border: 1px solid rgba(16, 185, 129, 0.45);
}

.sidebar-cb-status-detail {
    font-size: 9px;
    color: #cbd5e1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.sidebar-cb-main-link {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
    text-decoration: none;
    color: #f1f5f9;
}

.sidebar-cb-main-link:hover {
    color: #ffffff;
}

.sidebar-cb-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-cb-nit {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11.5px;
    font-weight: 700;
    color: #f8fafc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-cb-time {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.7);
    color: #fde68a;
    flex-shrink: 0;
}

.sidebar-cb-item.cb-vencida .sidebar-cb-time {
    background: rgba(220, 38, 38, 0.85);
    color: #ffffff;
}

.sidebar-cb-item.cb-proxima .sidebar-cb-time {
    color: #bae6fd;
}

.sidebar-cb-item.cb-contactado .sidebar-cb-time {
    background: rgba(5, 150, 105, 0.85);
    color: #ffffff;
}

.sidebar-cb-sub {
    font-size: 10px;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}

.sidebar-cb-ver-group {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.sidebar-cb-ver {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9.5px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    text-decoration: none;
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.5);
    transition: all 0.15s ease;
}

.sidebar-cb-ver:hover {
    color: #ffffff;
    border-color: #60a5fa;
    background: rgba(37, 99, 235, 0.6);
}

.sidebar-cb-ver.ver-primary-v2 {
    background: #2563eb;
    border-color: #3b82f6;
    color: #ffffff;
}

.sidebar-cb-ver.ver-primary-v1 {
    background: #475569;
    border-color: #64748b;
    color: #ffffff;
}

.sidebar-cb-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 11px;
    padding: 12px 8px;
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.sidebar-menu li {
    position: relative;
    width: 100%;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    padding: 8px 20px; /* Reducido para compactar */
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu .nav-link:hover, .sidebar-menu .nav-link.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
    border-left-color: var(--brand-primary);
}

.nav-icon {
    width: 24px;
    display: inline-block;
    text-align: center;
    margin-right: 10px;
    font-size: 16px;
}

/* Submenús */
.has-submenu .nav-link {
    justify-content: space-between;
}

.submenu-arrow {
    font-size: 10px;
    transition: transform 0.3s;
    opacity: 0.5;
    margin-left: auto;
}

.has-submenu.open > .nav-link .submenu-arrow {
    transform: rotate(180deg);
}

.submenu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
}

.has-submenu.open > .submenu-list {
    max-height: 1000px;
    transition: max-height 0.3s ease-in-out;
}

.submenu-link {
    display: flex;
    align-items: center;
    padding: 6px 20px 6px 45px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 12.5px;
    transition: all 0.2s;
}

.submenu-link:hover, .submenu-link.active {
    background-color: rgba(255, 255, 255, 0.03);
    color: #fff;
}

.submenu-link.active {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Main Content Area */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-content {
    padding: 24px;
}

.table-danger-light {
    background-color: #fff5f5 !important;
}

.cell-error {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
    font-weight: 700 !important;
    border: 1px solid #fca5a5 !important;
}

/* Typography Helpers */
.page-title {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    color: var(--brand-accent);
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Common Utilities */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--brand-primary); }
/* --- Responsive Design (Mobile First adjustments) --- */
@media (max-width: 991px) {
    :root {
        --sidebar-width: 280px;
    }

    .app-sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: transform 0.3s ease-in-out;
        box-shadow: 10px 0 15px rgba(0,0,0,0.1);
    }

    .app-wrapper.sidebar-open .app-sidebar {
        transform: translateX(var(--sidebar-width));
    }

    /* Overlay para cerrar el menú al hacer clic fuera */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    .app-wrapper.sidebar-open .sidebar-overlay {
        display: block;
    }

    .app-header {
        padding: 0 15px;
    }

    .app-header-brand {
        font-size: 1.1rem;
    }

    .user-status-container {
        display: none; /* Ocultar en móviles para ganar espacio, o mover a menú lateral */
    }

    .app-content {
        padding: 15px;
    }
}
