/* ============================================
   VARIABLES GLOBALES OPTIMIZADAS - LIGHT THEME
   ============================================ */
:root {
    /* Colores principales - azul profesional */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    
    /* Colores de texto y fondos LIGHT THEME */
    --dark: #1e293b;
    --gray: #64748b;
    --light: #f1f5f9;
    --white: #ffffff;
    
    /* Fondos y superficies */
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    --card-bg: #ffffff;
    --panel: #ffffff;
    --panel-2: #f1f5f9;
    --border: #e2e8f0;
    
    /* Sombras más sutiles */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.08);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   HEADER DEL DASHBOARD
   ============================================ */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 24px 28px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.header-left h1 {
    margin: 0;
    font-size: 1.75rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}

.header-left h1 i {
    color: var(--primary);
}

.header-subtitle {
    margin: 5px 0 0;
    color: var(--gray);
    font-size: 0.9rem;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Dropdown de acciones rápidas */
.quick-actions-dropdown {
    position: relative;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.25);
}

.dropdown-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.dropdown-trigger i:last-child {
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.quick-actions-dropdown.active .dropdown-trigger i:last-child {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    min-width: 280px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: var(--transition);
    z-index: 100;
}

.quick-actions-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--dark);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.dropdown-item:hover {
    background: var(--light);
    border-left-color: var(--primary);
}

.dropdown-item i {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.dropdown-item-content {
    flex: 1;
}

.item-title {
    display: block;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 2px;
    font-size: 14px;
}

.item-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--gray);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* Perfil de usuario */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.user-profile:hover {
    background: var(--white);
    border-color: var(--primary);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray);
}

/* ============================================
   BANNER DE ESTADO DE CONEXIÓN
   ============================================ */
.connection-status-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 4px solid var(--warning);
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.4s ease;
}

.connection-status-banner.connected {
    border-left-color: var(--success);
    background: linear-gradient(to right, rgba(16, 185, 129, 0.05), transparent);
}

.connection-status-banner.disconnected {
    border-left-color: var(--danger);
    background: linear-gradient(to right, rgba(239, 68, 68, 0.05), transparent);
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}

.banner-content i {
    font-size: 1.1rem;
}

.connection-status-banner.connected .banner-content i {
    color: var(--success);
}

.connection-status-banner.disconnected .banner-content i {
    color: var(--danger);
}

.btn-banner {
    padding: 8px 14px;
    background: var(--white);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-banner:hover {
    background: var(--primary);
    color: white;
}

/* ============================================
   GRID DE ESTADÍSTICAS - CORREGIDO
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.stat-card.primary::before {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.stat-card.success::before {
    background: linear-gradient(90deg, var(--success), #34d399);
}

.stat-card.warning::before {
    background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.stat-card.revenue::before {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.stat-card.success .stat-icon {
    background: linear-gradient(135deg, var(--success), #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.stat-card.warning .stat-icon {
    background: linear-gradient(135deg, var(--warning), #d97706);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.stat-card.revenue .stat-icon {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.stat-badge {
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.stat-badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-badge.revenue {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.stat-content h3 {
    margin: 0 0 8px;
    color: var(--gray);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--dark);
    margin: 8px 0;
    line-height: 1.2;
}

.stat-description {
    color: var(--gray);
    font-size: 0.85rem;
    margin: 5px 0;
}

.stat-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.stat-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
}

.stat-footer a:hover {
    color: var(--primary-dark);
}

.stat-footer .percentage {
    font-weight: 700;
    color: var(--primary);
    margin-right: 4px;
}

/* ============================================
   SECCIÓN DE GRÁFICOS - CORREGIDO
   ============================================ */
.charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-container {
    background: var(--white) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.chart-container.large {
    grid-column: span 1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.chart-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-title i {
    color: var(--primary);
    font-size: 1.2rem;
}

.chart-title h3 {
    margin: 0;
    color: var(--dark);
    font-size: 1.1rem;
    font-weight: 600;
}

.chart-controls select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--dark);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.chart-controls select:hover {
    border-color: var(--primary);
}

.chart-controls select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.chart-body {
    height: 300px;
    position: relative;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

/* ============================================
   SECCIÓN DE ACTIVIDAD - CORREGIDO
   ============================================ */
.activity-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.activity-container,
.quick-stats-container {
    background: var(--white) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: var(--primary);
    font-size: 1.1rem;
}

.section-title h3 {
    margin: 0;
    color: var(--dark);
    font-size: 1.05rem;
    font-weight: 600;
}

.section-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
}

.section-link:hover {
    color: var(--primary-dark);
}

/* Lista de clientes recientes */
.recent-clients-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-client-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.recent-client-item:hover {
    background: var(--white);
    border-color: var(--primary);
    transform: translateX(3px);
}

.client-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.client-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.client-name {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 2px;
    font-size: 0.9rem;
}

.client-plan {
    font-size: 0.8rem;
    color: var(--gray);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.status-badge.activo {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.suspendido {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* Estadísticas rápidas */
.quick-stats-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quick-stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.quick-stat-item:hover {
    background: var(--white);
    border-color: var(--primary);
}

.quick-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.quick-stat-icon.danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.quick-stat-icon.warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.quick-stat-icon.success {
    background: linear-gradient(135deg, var(--success), #059669);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.quick-stat-icon.info {
    background: linear-gradient(135deg, var(--info), #0284c7);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.25);
}

.quick-stat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.quick-stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 2px;
}

.quick-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--dark);
}

.quick-stat-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0;
}

.quick-stat-action:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================
   ESTADOS Y ANIMACIONES
   ============================================ */
.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--gray);
}

.spinner {
    width: 38px;
    height: 38px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 14px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.empty-state i,
.error-state i {
    font-size: 2.5rem;
    margin-bottom: 14px;
    opacity: 0.4;
    color: var(--gray);
}

.empty-state p,
.error-state p {
    margin: 8px 0 16px;
    font-size: 0.95rem;
    color: var(--gray);
}

/* ============================================
   FILTER ROW - Inputs corregidos
   ============================================ */
.filter-row select,
.filter-row input,
.filter-row textarea,
.filter-row .form-control,
.filter-row .form-select {
    background: var(--panel-2) !important;
    color: var(--dark) !important;
    border: 1px solid var(--border) !important;
}

.filter-row select option {
    background: var(--white);
    color: var(--dark);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .activity-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .header-right {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .quick-actions-dropdown {
        order: -1;
        width: 100%;
    }
    
    .dropdown-trigger {
        width: 100%;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .connection-status-banner {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        padding: 18px;
    }
    
    .header-left h1 {
        font-size: 1.4rem;
    }
    
    .stat-value {
        font-size: 1.8rem;
    }
    
    .stat-card {
        padding: 18px;
    }
}

/* ============================================
   SUBMENU FIX
   ============================================ */
.has-submenu .submenu {
    display: none;
}

.has-submenu.open .submenu {
    display: block;
}