/* Sidebar Styles */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 70px;
    min-width: 70px;
    height: 100vh;
    background-color: var(--background-surface);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--box-shadow-md);
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.sidebar.expanded {
    width: 250px;
    min-width: 250px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: var(--spacing-md) var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--primary-color);
    color: var(--text-color-on-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    height: 60px;
    box-sizing: border-box;
}

.sidebar .sidebar-header {
    justify-content: center;
    padding: var(--spacing-md) var(--spacing-md);
    height: 60px;
    box-sizing: border-box;
}

.sidebar.expanded .sidebar-header {
    justify-content: flex-start;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 100%;
    transition: justify-content 0.3s ease;
    overflow: hidden;
    box-sizing: border-box;
    min-height: 40px;
    max-height: 40px;
    flex-shrink: 0;
    flex-grow: 1;
    position: relative;
}

.sidebar.expanded .logo-container {
    justify-content: flex-start;
}

.sidebar-logo-full {
    height: 32px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.sidebar.expanded .sidebar-logo-full {
    opacity: 1;
}

.sidebar-logo-collapsed {
    width: 40px;
    height: 40px;
    object-fit: contain;
    opacity: 1;
    position: absolute;
    transition: opacity 0.3s ease;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 10;
}

.sidebar.expanded .sidebar-logo-collapsed {
    opacity: 0;
}

.sidebar-logo-collapsed:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-color-on-primary);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--border-radius-sm);
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    flex-shrink: 0;
    min-width: 24px;
    min-height: 24px;
    position: absolute;
    right: var(--spacing-md);
    top: 50%;
    transform: translateY(-50%);
}

.sidebar-toggle i {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar .sidebar-toggle {
    display: none;
}

.sidebar.expanded .sidebar-toggle {
    display: flex;
}

/* Sidebar Menu */
.sidebar-menu {
    padding: var(--spacing-md) 0;
    flex: 1;
}

.sidebar .sidebar-menu {
    padding: var(--spacing-md) 0;
    flex: 1;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--text-color-secondary);
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    position: relative;
    height: 48px;
    box-sizing: border-box;
    min-height: 48px;
    max-height: 48px;
}


.sidebar-item:hover {
    background-color: var(--background-surface-alt);
    color: var(--text-color-primary);
}

.sidebar-item.active {
    background-color: var(--primary-color-light);
    color: var(--primary-color-dark);
    border-left-color: var(--primary-color);
}

.sidebar .sidebar-item {
    justify-content: center;
    padding: var(--spacing-md) 0;
    gap: 0;
    border-left: none;
    width: 100%;
    height: 48px;
    display: flex;
    align-items: center;
    position: relative;
    animation: none;
    text-align: center;
    box-sizing: border-box;
    min-height: 48px;
    max-height: 48px;
}

.sidebar.expanded .sidebar-item {
    justify-content: flex-start;
    padding: var(--spacing-md) var(--spacing-lg);
    gap: var(--spacing-md);
    border-left: 3px solid transparent;
}

.sidebar .sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 0 2px 2px 0;
}

.sidebar.expanded .sidebar-item.active::before {
    display: none;
}

.sidebar.expanded .sidebar-item.active {
    border-left-color: var(--primary-color);
}

/* Iconos */
.sidebar-item i {
    width: 24px !important;
    height: 24px !important;
    flex-shrink: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px !important;
    min-height: 24px !important;
    transition: all 0.3s ease;
}

.sidebar .sidebar-item i {
    margin: 0 auto;
    transition: all 0.3s ease;
}

.sidebar.expanded .sidebar-item i {
    margin: 0;
}

.sidebar-item span {
    font-weight: 500;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateX(-20px);
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.expanded .sidebar-item span {
    opacity: 1;
    transform: translateX(0);
    width: auto;
}

/* Estilos específicos para iconos Lucide */
.sidebar-item i[data-lucide] svg,
.sidebar .sidebar-item i[data-lucide] svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    display: block !important;
    flex-shrink: 0 !important;
}

.sidebar svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    flex-shrink: 0 !important;
}

/* Reglas adicionales para garantizar consistencia de iconos */
.sidebar i[data-lucide] {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.sidebar i[data-lucide] svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    flex-shrink: 0 !important;
    display: block !important;
}

/* Main Content Adjustment */
.main-content {
    margin-left: 70px;
    min-height: 100vh; /* Changed to min-height for scroll */
    background-color: var(--background-body);
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: calc(100% - 70px); /* Ensure it takes remaining width */
    box-sizing: border-box;
    overflow-y: auto; /* Allow vertical scrolling */
    height: 100vh; /* Set fixed height to enable proper scrolling */
}

.sidebar.expanded + .main-content {
    margin-left: 250px;
    width: calc(100% - 250px); /* Adjust width when sidebar is expanded */
}

/* Main Content Section Styles */
.main-content-section {
    display: block;
    padding: 0;
    min-height: 100vh;
    overflow-y: auto;
}

/* Home Section Styles */
.welcome-container {
    max-width: none;
    margin: 0;
    padding: var(--spacing-lg);
    height: 100vh;
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
}

.welcome-header {
    text-align: center;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    background: linear-gradient(135deg, var(--primary-color-light), var(--accent-color-light));
    border-radius: var(--border-radius-lg);
    color: var(--text-color-primary);
}

.welcome-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 var(--spacing-xs) 0;
    color: var(--primary-color-dark);
}

.motivational-quote {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-color-secondary);
    margin: 0 auto;
    max-width: 600px;
}

.home-content {
    margin-top: var(--spacing-lg);
    height: calc(100% - 120px);
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.home-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--spacing-lg);
    align-items: stretch;
    height: 100%;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

/* Calendar Widget */
.calendar-widget {
    background-color: var(--background-surface);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-sm);
    border: 1px solid var(--border-color);
}

.calendar-widget.compact {
    padding: var(--spacing-md);
    max-width: 300px;
}

.calendar-widget h3 {
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--text-color-primary);
    font-size: 1.3rem;
}

.calendar-container {
    background-color: var(--background-body);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color-secondary);
}

.calendar-widget.compact .calendar-container {
    min-height: 200px;
    padding: var(--spacing-sm);
}

/* Quick Stats */
.quick-stats {
    background-color: var(--background-surface);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-sm);
    border: 1px solid var(--border-color);
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    gap: var(--spacing-md);
}

.quick-stats h3 {
    margin: 0;
    color: var(--text-color-primary);
    font-size: 1.2rem;
    display: none; /* Ocultar visualmente el título */
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    flex: 0 0 auto; /* No expandir, tamaño fijo */
    overflow: visible;
    padding-right: 0;
    box-sizing: border-box;
    align-content: start;
    grid-auto-rows: minmax(80px, auto);
    max-height: 280px; /* Altura ajustada para las nuevas tarjetas */
}

.quick-stats .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

/* Google Calendar Container */
.calendar-container {
    flex: 1;
    background-color: #121212;
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    min-height: 400px;
    max-height: none; /* Permitir que crezca */
    overflow: hidden;
    box-sizing: border-box;
}

.calendar-container iframe {
    border-radius: var(--border-radius-sm);
    width: 100%;
    height: 100%;
    min-height: 380px;
    background-color: #121212;
}

/* Scrollbar para estadísticas */
.stats-grid::-webkit-scrollbar {
    width: 6px;
}

.stats-grid::-webkit-scrollbar-track {
    background: var(--background-surface-alt);
    border-radius: 3px;
}

.stats-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.stats-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-color-tertiary);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--background-surface) 0%, var(--background-surface-alt) 100%);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 80px;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.stat-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--primary-color);
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color-light) 0%, var(--background-surface) 100%);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-trend {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.stat-trend.positive {
    color: #10b981;
}

.stat-trend.negative {
    color: #ef4444;
}

.stat-trend.neutral {
    color: var(--text-color-secondary);
}

.stat-card i {
    width: 28px;
    height: 28px;
    color: var(--primary-color);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.stat-card:hover i {
    color: var(--primary-color-dark);
    transform: scale(1.1);
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    flex: 1;
    min-width: 0;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color-primary);
    line-height: 1.2;
    transition: all 0.3s ease;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-color-secondary);
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* KPI Types - Different colors for different metrics */
.stat-card.revenue {
    border-left: 4px solid var(--success-color);
}

.stat-card.revenue i {
    color: var(--success-color);
}

.stat-card.leads {
    border-left: 4px solid var(--primary-color);
}

.stat-card.leads i {
    color: var(--primary-color);
}

.stat-card.conversion {
    border-left: 4px solid var(--accent-color);
}

.stat-card.conversion i {
    color: var(--accent-color);
}

.stat-card.campaigns {
    border-left: 4px solid var(--warning-color);
}

.stat-card.campaigns i {
    color: var(--warning-color);
}

.stat-card.time {
    border-left: 4px solid var(--info-color);
}

.stat-card.time i {
    color: var(--info-color);
}

.stat-card.meetings {
    border-left: 4px solid var(--purple-color);
}

.stat-card.meetings i {
    color: var(--purple-color);
}

.stat-card.lost {
    border-left: 4px solid var(--danger-color);
}

.stat-card.lost i {
    color: var(--danger-color);
}

/* Animation for number changes */
.stat-number.animating {
    animation: numberPulse 0.6s ease-in-out;
}

@keyframes numberPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); color: var(--primary-color); }
    100% { transform: scale(1); }
}

/* Tooltip styles */
.stat-card[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--background-surface-alt);
    color: var(--text-color-primary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: var(--box-shadow-md);
    border: 1px solid var(--border-color);
}


/* CRM Section Adjustments */
#crm-section .crm-header {
    position: fixed;
    top: 0;
    left: 70px;
    right: 0;
    background-color: var(--background-surface);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--box-shadow-sm);
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-sm);
    height: 60px; /* Fixed height */
    box-sizing: border-box;
}

.sidebar.expanded + .main-content #crm-section .crm-header {
    left: 250px;
}

/* News Section Styles */
.news-container {
    max-width: 1200px;
    margin: 0 auto;
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--border-color);
}

.news-header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color-primary);
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--spacing-lg);
}

.news-card {
    background-color: var(--background-surface);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-md);
}

.news-card.placeholder {
    opacity: 0.7;
    border-style: dashed;
}

.news-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--spacing-lg);
    background-color: var(--background-surface-alt);
    border-bottom: 1px solid var(--border-color);
}

.news-card-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color-primary);
}

.news-date {
    font-size: 0.85rem;
    color: var(--text-color-secondary);
    background-color: var(--primary-color-light);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
}

.news-card-content {
    padding: var(--spacing-lg);
}

.news-card-content p {
    margin: 0;
    color: var(--text-color-secondary);
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .welcome-container {
        margin: 0;
        padding: var(--spacing-md);
        height: 100vh;
    }
    
    .home-layout {
        grid-template-columns: 1.5fr 1fr;
        gap: var(--spacing-lg);
    }
    
    .home-content {
        height: calc(100% - 100px);
    }
    
    .notifications-section {
        height: calc(100% - 40px);
        max-height: calc(100% - 40px);
    }
    
    .quick-stats {
        height: calc(100% - 40px);
        max-height: calc(100% - 40px);
        padding: var(--spacing-md);
    }
    
    .stats-grid {
        gap: var(--spacing-sm);
    }
    
    .stat-card {
        min-height: 85px;
        padding: var(--spacing-sm);
    }
}

@media (max-width: 768px) {
    .welcome-container {
        margin: 0;
        padding: var(--spacing-md);
        height: 100vh;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar.expanded + .main-content {
        margin-left: 0;
    }
    
    .home-layout {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .home-content {
        height: calc(100% - 100px);
    }
    
    .notifications-section {
        height: calc(100% - 20px);
        max-height: calc(100% - 20px);
    }
    
    .quick-stats {
        height: calc(100% - 20px);
        max-height: calc(100% - 20px);
        padding: var(--spacing-sm);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .stat-card {
        min-height: 80px;
        padding: var(--spacing-sm);
    }
    
    .stat-number {
        font-size: 1.3rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .welcome-header h1 {
        font-size: 2.2rem;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
    }
    
    #crm-section .crm-header {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .welcome-container {
        margin: 0;
        padding: var(--spacing-sm);
        height: 100vh;
    }
    
    .welcome-header {
        padding: var(--spacing-lg);
    }
    
    .welcome-header h1 {
        font-size: 1.8rem;
    }
    
    .motivational-quote {
        font-size: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
    }
    
    .stat-card {
        min-height: 70px;
        padding: var(--spacing-xs);
        flex-direction: row;
        text-align: left;
    }
    
    .stat-info {
        align-items: flex-start;
    }
    
    .stat-number {
        font-size: 1.2rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
}
}