/* Estilos específicos para el Dashboard Analítico */
:root {
    --dashboard-bg: #151a2c;
    --card-bg: #1e253a;
    --card-border: #2a344a;
    --accent-green: #c5ff9b; /* Color de marca 1 */
    --accent-teal: #a6fef8; /* Color de marca 2 */
    --accent-blue: #00c2ff;
    --accent-purple: #8a3cff;
    --accent-pink: #ff61dc;
    --accent-orange: #ffb37a;
    --text-primary: #ffffff;
    --text-secondary: #a0a3bd;
    --chart-grid: #2a344a;
}

.dashboard-container {
    padding-top: 20px;
    min-height: 100vh;
    background-color: var(--dashboard-bg);
    color: var(--text-primary);
}

/* Cabecera del Dashboard */
.dashboard-header {
    margin-bottom: 30px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dashboard-title {
    color: white;
    font-weight: 600;
    font-size: 24px;
    margin-bottom: 5px;
    display: inline-block;
    text-shadow: 0 0 10px rgba(0, 194, 255, 0.5);
}

.dashboard-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 400;
}

.dashboard-controls {
    display: flex;
    gap: 10px;
}

.dashboard-btn {
    padding: 8px 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.dashboard-btn i {
    font-size: 14px;
}

/* KPI Cards */
.kpi-container {
    margin-bottom: 30px;
}

.kpi-card {
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    height: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green), var(--accent-teal));
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.kpi-icon {
    width: 50px;
    height: 50px;
    min-width: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    background: rgba(0, 194, 255, 0.1);
    color: var(--accent-blue);
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.kpi-icon::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
    transform: scale(0);
    opacity: 0;
    transition: all 0.5s ease;
}

.kpi-card:hover .kpi-icon {
    transform: scale(1.1) rotate(5deg);
}

.kpi-card:hover .kpi-icon::after {
    transform: scale(1);
    opacity: 1;
}

.kpi-card:nth-child(2) .kpi-icon {
    background: rgba(197, 255, 155, 0.1);
    color: var(--accent-green);
}

.kpi-card:nth-child(3) .kpi-icon {
    background: rgba(255, 97, 220, 0.1);
    color: var(--accent-pink);
}

.kpi-card:nth-child(4) .kpi-icon {
    background: rgba(255, 179, 122, 0.1);
    color: var(--accent-orange);
}

.kpi-data {
    flex-grow: 1;
}

.kpi-data h6 {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.kpi-data h3 {
    margin: 5px 0 0;
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease, transform 0.3s ease;
}

/* Efecto de actualización para KPIs */
.kpi-card.updating .kpi-data h3 {
    color: var(--accent-blue);
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Dashboard Cards */
.dashboard-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--card-border);
    transition: all 0.3s ease;
}

.dashboard-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(197, 255, 155, 0.4);
    background: linear-gradient(145deg, var(--card-bg), rgba(30, 37, 58, 0.95));
}

/* Efectos de actualización */
.dashboard-card.updating {
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px rgba(0, 194, 255, 0.4);
    animation: card-update 0.5s ease-in-out;
}

@keyframes card-update {
    0% { transform: translateY(0); opacity: 0.8; }
    50% { transform: translateY(-5px); opacity: 1; }
    100% { transform: translateY(0); opacity: 0.8; }
}

.dashboard-card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--card-border);
    background-color: rgba(20, 30, 50, 0.5);
}

.dashboard-card-header h5 {
    margin: 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.dashboard-card-header h5 i {
    margin-right: 10px;
    color: var(--accent-green);
    font-size: 14px;
    transition: color 0.3s ease;
}

.dashboard-card:hover .dashboard-card-header h5 i {
    color: var(--accent-teal);
}

.dashboard-card-body {
    padding: 20px;
    overflow: hidden;
}

/* Chart Containers */
.chart-container {
    width: 100%;
    height: 300px;
    position: relative;
}

.chart-container.small {
    height: 200px;
}

/* ApexCharts Customization */
.apexcharts-tooltip {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
}

.apexcharts-tooltip-title {
    background-color: rgba(20, 30, 50, 0.7) !important;
    border-bottom: 1px solid var(--card-border) !important;
}

.apexcharts-xaxis-label, .apexcharts-yaxis-label {
    fill: var(--text-secondary) !important;
}

.apexcharts-grid line {
    stroke: var(--chart-grid) !important;
    stroke-dasharray: 3;
    stroke-opacity: 0.3;
}

.apexcharts-tooltip-marker {
    width: 10px !important;
    height: 10px !important;
    border-radius: 50% !important;
}

/* Iconos animados */
.animated-icon {
    position: absolute;
    z-index: 1;
    opacity: 0.7;
    filter: drop-shadow(0 0 5px rgba(0, 194, 255, 0.5));
    animation: float 3s ease-in-out infinite;
}

.animated-icon.home {
    top: 20px;
    right: 20px;
    font-size: 20px;
    color: var(--accent-green);
    animation-delay: 0.5s;
}

.animated-icon.chart {
    top: 70px;
    right: 50px;
    font-size: 16px;
    color: var(--accent-teal);
    animation-delay: 1s;
}

.animated-icon.money {
    top: 30px;
    right: 80px;
    font-size: 18px;
    color: var(--accent-blue);
    animation-delay: 1.5s;
}

@keyframes float {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

.pulse-icon {
    display: inline-block;
    animation: pulse-animation 2s infinite;
    margin-right: 8px;
    color: var(--accent-green);
}

@keyframes pulse-animation {
    0% { transform: scale(1); }
    15% { transform: scale(1.2); }
    30% { transform: scale(1); }
    100% { transform: scale(1); }
}

/* GridStack Dashboard Customization */
.grid-stack {
    background: transparent;
    margin-top: 20px;
    padding: 0 10px;
}

.grid-stack-item {
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.grid-stack-item-content {
    width: 100%;
    height: 100%;
    background: transparent;
    position: relative;
    padding: 5px;
    box-sizing: border-box;
}

.grid-stack-item .dashboard-card {
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.grid-stack-item.ui-draggable-dragging .dashboard-card {
    border-color: var(--accent-blue);
    box-shadow: 0 10px 40px rgba(0, 194, 255, 0.3);
    transform: rotate(2deg);
}

.grid-stack-item.ui-resizable-resizing .dashboard-card {
    border-color: var(--accent-green);
    box-shadow: 0 5px 25px rgba(197, 255, 155, 0.3);
}

.dashboard-card-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    cursor: move;
}

.dashboard-card-header::after {
    content: '⋮⋮';
    position: absolute;
    right: 50px;
    color: var(--text-secondary);
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.dashboard-card:hover .dashboard-card-header::after {
    opacity: 0.7;
}

.card-controls {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.card-controls .btn {
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.card-controls .btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.dashboard-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    min-height: 0;
}

.chart-container {
    flex: 1;
    min-height: 400px;
    max-height: 550px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue) rgba(255, 255, 255, 0.1);
}

.chart-container::-webkit-scrollbar {
    width: 6px;
}

.chart-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chart-container::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 3px;
}

.chart-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-green);
}

/* Chart content enhancement */
.chart-container canvas,
.chart-container svg {
    max-width: 100% !important;
    height: auto !important;
}

.chart-container .chart-wrapper {
    position: relative;
    height: 100%;
    width: 100%;
}

/* Simetría perfecta en el espaciado */
.grid-stack-item {
    margin: 0 !important;
}

.grid-stack > .grid-stack-item {
    position: absolute;
    padding: 0;
}

.grid-stack > .grid-stack-item > .grid-stack-item-content {
    margin: 5px;
    width: calc(100% - 10px);
    height: calc(100% - 10px);
}

/* GridStack resize handles customization */
.ui-resizable-handle {
    background: var(--accent-green);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grid-stack-item:hover .ui-resizable-handle {
    opacity: 0.8;
}

.ui-resizable-se {
    bottom: 3px;
    right: 3px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
}

/* Dashboard Controls Enhancement */
.dashboard-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.dashboard-btn.grid-toggle {
    background: linear-gradient(45deg, var(--accent-green), var(--accent-teal));
    border: none;
    color: white;
    transition: all 0.3s ease;
}

.dashboard-btn.grid-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(197, 255, 155, 0.4);
}

.dashboard-btn.grid-toggle.locked {
    background: linear-gradient(45deg, var(--accent-orange), var(--accent-pink));
}

/* Full screen modal for expanded charts */
.chart-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.chart-modal.active {
    display: flex;
}

.chart-modal-content {
    width: 90vw;
    height: 90vh;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    border: 1px solid var(--card-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.chart-modal-close {
    background: var(--accent-pink);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chart-modal-close:hover {
    background: #ff3d9a;
    transform: scale(1.1);
}

.chart-modal-body {
    height: calc(100% - 80px);
    overflow: hidden;
}

/* Drag indicator */
.grid-stack-placeholder {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green)) !important;
    opacity: 0.4 !important;
    border-radius: 12px !important;
    border: 2px dashed rgba(255, 255, 255, 0.8) !important;
    animation: placeholderPulse 1.5s ease-in-out infinite !important;
    box-shadow: 0 4px 15px rgba(0, 194, 255, 0.3) !important;
}

@keyframes placeholderPulse {
    0%, 100% { 
        opacity: 0.4;
        transform: scale(1);
    }
    50% { 
        opacity: 0.6;
        transform: scale(1.01);
    }
}

/* Loading states */
.chart-loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 14px;
}

.chart-loading-indicator i {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--accent-blue);
}

/* Animation for grid layout changes - más suave y sin conflictos */
.grid-stack-item.grid-stack-animate {
    transition: left 0.3s ease, 
                top 0.3s ease, 
                width 0.3s ease, 
                height 0.3s ease;
}

/* Feedback visual durante el drag sin escalado que cause problemas */
.grid-stack-item.ui-draggable-dragging {
    z-index: 1000;
    opacity: 0.8;
    filter: brightness(1.1);
}

.grid-stack-item.ui-draggable-dragging .dashboard-card {
    border-color: var(--accent-blue);
    box-shadow: 0 10px 30px rgba(0, 194, 255, 0.3);
}

/* Efecto de hover suave */
.grid-stack-item:hover .dashboard-card {
    box-shadow: 0 5px 15px rgba(0, 194, 255, 0.1);
    transform: translateY(-2px);
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dashboard-controls {
        margin-top: 15px;
        width: 100%;
        justify-content: space-between;
    }
    
    .chart-container {
        min-height: 180px;
    }
    
    .chart-modal-content {
        width: 95vw;
        height: 95vh;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .kpi-card {
        padding: 15px;
    }
    
    .kpi-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 20px;
    }
    
    .kpi-data h3 {
        font-size: 22px;
    }
    
    .chart-container {
        min-height: 150px;
    }
    
    .grid-stack {
        min-height: auto;
    }
    
    .dashboard-card-header h5 {
        font-size: 14px;
    }
    
    .card-controls .btn {
        padding: 2px 6px;
        font-size: 12px;
    }
}

/* Keyframes para animaciones de notificaciones */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}