/* ============================= */
/* SIDEBAR */
/* ============================= */

.sidebar {
    width: 250px;
    min-height: 100vh;
    background: #2c343f;
    padding: 1.5rem 1rem;
}

@media (min-width: 768px) {
    .sidebar {
        position: relative;
        display: block;
    }

    .flex-grow-1 {
        margin-left: 0;
    }
}

@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -250px;
        height: 100vh;
        z-index: 1050;
        transition: all 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1040;
    }

    .flex-grow-1 {
        width: 100%;
    }

    #sidebarOverlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1040;
        display: none;
    }

    #sidebarOverlay.active {
        display: block;
    }
}

/* ============================= */
/* NAV LINKS */
/* ============================= */

.sidebar .nav-link {
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    border-radius: 6px;
    padding: 6px 14px;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar .nav-link i {
    width: 18px;
    text-align: center;
    font-size: var(--crm-icon-size);
}

/* ============================= */
/* TOPBAR */
/* ============================= */

.topbar {
    font-size: 12px;
    padding: 8px 20px;
    background-color: #1f2937;
    border-bottom: 1px solid #111827;
}

/* ============================= */
/* FEEDBACK VISUAL */
/* ============================= */

.lead-updated {
    animation: flashRow 1.2s ease;
}

@keyframes flashRow {
    0% { background: #fff3cd; }
    100% { background: transparent; }
}

/* ============================= */
/* CRM SHELL REFRESH */
/* ============================= */

.crm-shell {
    background: linear-gradient(180deg, #eef2f7 0%, #f8fafc 100%);
}

.crm-sidebar {
    width: 280px !important;
    min-height: 100vh;
    background: linear-gradient(180deg, #172033 0%, #111827 100%);
    border-right: 1px solid rgba(255,255,255,0.06);
    box-shadow: 10px 0 30px rgba(15, 23, 42, 0.18);
    overflow-y: auto;
}

.crm-sidebar-header {
    padding: 0.25rem 0.35rem 0.75rem 0.35rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.crm-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.crm-brand-subtitle {
    color: rgba(255,255,255,0.58);
    font-size: 0.78rem;
    margin-top: 0.1rem;
}

.crm-nav-list {
    gap: 0.2rem;
}

.crm-nav-section {
    color: rgba(255,255,255,0.42);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.8rem 0.85rem 0.35rem;
}

.crm-sidebar .nav-link {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255,255,255,0.76);
    border-radius: 12px;
    padding: 0.72rem 0.9rem;
    transition: all 0.18s ease;
}

.crm-sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
    transform: translateX(2px);
}

.crm-sidebar .nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(79,70,229,0.42) 0%, rgba(59,130,246,0.20) 100%);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

.crm-sidebar .nav-link i {
    width: 18px;
    text-align: center;
}

.crm-main {
    min-width: 0;
}

.crm-topbar {
    min-height: 76px;
    background: rgba(15, 23, 42, 0.94);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: #fff;
    box-shadow: 0 8px 25px rgba(15, 23, 42, 0.10);
}

.crm-page-kicker {
    color: rgba(255,255,255,0.62);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.crm-page-title {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
}

.crm-user-btn {
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.06);
}

.crm-user-btn:hover,
.crm-user-btn:focus,
.crm-user-btn:active {
    color: #fff !important;
    background: rgba(255,255,255,0.10) !important;
    border-color: rgba(255,255,255,0.28) !important;
}

.crm-content-wrap {
    padding: 1.5rem;
}

.crm-card {
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.crm-stat-card {
    padding: 1.35rem 1.4rem;
}

.crm-stat-label {
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.crm-stat-value {
    color: #0f172a;
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 0.35rem;
}

.crm-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #eef2ff 100%);
    color: #334155;
}

@media (max-width: 767px) {
    .crm-content-wrap {
        padding: 1rem;
    }
}


/* ==========================================
   AJUSTES V8 - SIDEBAR FIJA / TOPBAR STICKY
========================================== */
.crm-shell {
    align-items: stretch;
}

.crm-sidebar {
    flex: 0 0 280px;
}

.crm-main {
    min-width: 0;
    min-height: 100vh;
}

.crm-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
}

@media (min-width: 768px) {
    .crm-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        align-self: flex-start;
    }
}

@media (max-width: 767px) {
    .crm-sidebar {
        width: 280px !important;
        left: -280px;
    }

    .crm-sidebar.active {
        left: 0;
    }
}


/* Ajustes de estructura v9 */
@media (min-width: 768px) {
    .crm-sidebar {
        position: sticky;
        top: 0;
        align-self: flex-start;
        height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        flex: 0 0 280px;
    }
}

.crm-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(12px);
}

.crm-main {
    min-width: 0;
    width: 100%;
}

/* Ajustes visuales v10 */
@media (min-width: 768px) {
    .crm-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
    }

    .crm-topbar {
        position: sticky;
        top: 0;
        z-index: 1020;
    }
}


/* Ajustes v15 sidebar */
.crm-sidebar {
    width: 240px !important;
    max-width: 240px;
    padding: 0.5rem !important;
}

.sidebar.crm-sidebar {
    width: 240px !important;
}

.crm-sidebar-header {
    padding: 0.1rem 0.1rem 0.55rem 0.1rem;
    margin-bottom: 0.5rem !important;
}

.crm-brand {
    font-size: 1rem;
}

.crm-brand-subtitle {
    font-size: 0.72rem;
}

.crm-nav-section {
    font-size: 0.66rem;
    padding: 0.55rem 0.5rem 0.2rem;
}

.crm-sidebar .nav-link {
    font-size: 13px;
    padding: 0.5rem;
    border-radius: 10px;
}

.crm-sidebar .nav-link i {
    width: 16px;
    font-size: 0.85rem;
}

.crm-sidebar .collapse .nav-link {
    padding: 0.45rem 0.5rem;
}

@media (max-width: 767px) {
    .sidebar.crm-sidebar {
        left: -240px;
    }
}

.crm-topbar-icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.06);
    color: #fff;
    border-radius: 10px;
}

.crm-topbar-icon-btn:hover,
.crm-topbar-icon-btn:focus,
.crm-topbar-icon-btn:active {
    color: #fff !important;
    background: rgba(255,255,255,0.12) !important;
    border-color: rgba(255,255,255,0.28) !important;
}

.crm-topbar-notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35);
}

.crm-task-offcanvas {
    width: min(420px, 100vw);
}

.crm-task-offcanvas .offcanvas-header {
    border-bottom: 1px solid #e5e7eb;
}

.crm-task-panel-section + .crm-task-panel-section {
    margin-top: 1.25rem;
}

.crm-task-panel-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.crm-task-panel-section__header h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #111827;
}

.crm-task-panel-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.crm-task-notification-item {
    width: 100%;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 14px;
    padding: 0.9rem 1rem;
    text-align: left;
    transition: all 0.18s ease;
}

.crm-task-notification-item:hover {
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.crm-task-notification-item.is-overdue {
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(254, 242, 242, 0.75);
}

.crm-task-notification-item.is-important {
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.12);
}

.crm-task-notification-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.crm-task-notification-item__top strong {
    color: #111827;
    font-size: 0.92rem;
}

.crm-task-notification-item__lead {
    color: #475569;
    font-size: 0.82rem;
    margin-bottom: 0.35rem;
}

.crm-task-notification-item__meta {
    color: #64748b;
    font-size: 0.78rem;
}

.crm-empty-state--compact {
    padding: 0.9rem 1rem;
    border-radius: 14px;
}
