:root {
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --accent: #0668E1;
    --bg-main: #f7f9fb;
    --bg-sidebar: #f2f4f6;
    --bg-card: #ffffff;
    --text-main: #191c1e;
    --text-muted: #45464d;
    --border: rgba(0, 0, 0, 0.04);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-blur: 16px;
    --glass-border: rgba(255, 255, 255, 0.12);
    --radius-lg: 28px;
    --radius-md: 18px;
    --shadow-premium: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --shadow-ambient: 0 10px 40px rgba(0,0,0,0.02);
    --danger: #ef4444;
    --sidebar-width: 70px;
}

[data-theme="dark"] {
    --bg-main: #0b141a;
    --bg-sidebar: #111b21;
    --bg-card: #202c33;
    --text-main: #e9edef;
    --text-muted: #8696a0;
    --border: rgba(255, 255, 255, 0.05);
    --glass-bg: rgba(17, 27, 33, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --sidebar-width: 70px;
}

/* Custom Scrollbar - Diseño Minimalista y Premium */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2); /* Color primario suave por defecto */
    border-radius: 20px;
    border: none;
    transition: background 0.3s;
}

/* Ocultar botones de flecha (Los de tu imagen) */
::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* Esquinas de la barra */
::-webkit-scrollbar-corner {
    background: transparent;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3); /* Un poco más visible en oscuro */
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary); /* Se vuelve sólido al pasar el ratón */
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

/* Soporte para Firefox (Scrollbar-width y color) */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

[data-theme="dark"], [data-theme="dark"] * {
    scrollbar-color: rgba(99, 102, 241, 0.4) transparent;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

/* Sidebar Navigation */
#navbar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 0 20px 13px;
    gap: 15px;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

#navbar:hover {
    width: 220px; /* Slightly wider for better label fit */
}

.nav-item {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.nav-item i {
    width: 44px;
    text-align: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.nav-label {
    display: block;
    margin-left: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0;
    transform: translateX(-15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

#navbar:hover .nav-item {
    width: 194px;
}

#navbar:hover .nav-label {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.nav-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* Main Content Container */
.crm-main-container {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    padding: 40px;
}

[data-theme="dark"] .crm-main-container {
    background-color: var(--bg-main);
}

.crm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh; /* Limitar altura al 90% de la pantalla */
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    position: relative;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 24px;
    overflow-y: auto; /* Scroll interno si el contenido es largo */
    flex: 1;
}

/* Generic Card Style */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    border: 1px solid transparent;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary { 
    background: var(--primary); 
    color: white; 
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { 
    background: var(--primary-hover); 
    transform: translateY(-2px); 
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: var(--primary-hover);
    color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-success {
    background: #10b981;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.4);
}

.btn-warning {
    background: #f59e0b;
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(245, 158, 11, 0.4);
}

/* Card & Modal Action Buttons */
.btn-action {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-card);
    color: var(--text-muted);
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-action-success {
    color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.btn-action-success:hover {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.btn-action-primary {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.btn-action-primary:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-close-modal {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(0,0,0,0.05);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-modal:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg);
}

[data-theme="dark"] .btn-close-modal {
    background: rgba(255,255,255,0.05);
}

/* Animations */
@keyframes revealUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.animate-reveal {
    animation: revealUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-fade {
    animation: fadeIn 0.4s ease forwards;
}

/* ========================================================
   RESPONSIVO / MOBILE (Tablets & Phones)
   ======================================================== */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    #navbar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        min-height: 65px;
        flex-direction: row;
        justify-content: space-around;
        padding: 5px 10px;
        border-right: none;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
        background: var(--bg-sidebar);
        z-index: 9999;
    }

    .nav-item {
        width: 44px;
        height: 44px;
        margin-bottom: 0;
        font-size: 1.1rem;
    }

    .nav-item::after {
        display: none !important; /* Deshabilitar tooltips en móvil */
    }

    .crm-main-container {
        padding: 15px;
        padding-bottom: 80px; /* Respetamos el panel fijo inferior */
        width: 100%;
        height: 100dvh; /* Adaptación dinámica si lo soporta el navegador, evitamos 100vh puro */
        overflow-y: auto;
    }

    .crm-grid {
        grid-template-columns: 1fr; /* Una sola columna en móvil */
        gap: 16px;
    }

    .modal-content {
        width: 95%;
        padding: 20px 15px;
        max-height: 85vh;
    }
}

.hidden-item {
    display: none !important;
}

