:root {
    --primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --warning: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --dark: linear-gradient(135deg, #434343 0%, #000000 100%);
    --glass: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.18);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --bg-primary: #f7fafc;
    --bg-secondary: #edf2f7;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
    animation: backgroundMove 20s ease-in-out infinite;
    z-index: -1;
}

@keyframes backgroundMove {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-30px) rotate(0.5deg); }
    66% { transform: translateY(20px) rotate(-0.5deg); }
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 30px;
    position: relative;
}

/* Header estilizado */
.header {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.header-content {
    position: relative;
    z-index: 2;
}

.header h1 {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 10px;
    line-height: 1.1;
}

.header-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 30px;
    font-weight: 400;
}

.controls {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 20px;
    align-items: center;
}

/* Upload button mejorado */
.upload-container {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    background: var(--success);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.upload-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(79, 172, 254, 0.4);
}

.upload-container input[type=file] {
    position: absolute;
    left: -9999px;
}

.upload-container label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
}

.upload-container label i {
    font-size: 20px;
}

/* Query input mejorado */
.query-container {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.query-container:focus-within {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.3);
}

.query-input {
    flex: 1;
    padding: 18px 24px;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
    font-weight: 500;
}

.query-input::placeholder {
    color: var(--text-secondary);
}

.query-suggestions {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
    pointer-events: none;
}

/* Botones premium */
.btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 28px;
    border: none;
    border-radius: 16px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

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

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Status indicators */
.data-status {
    display: none;
    align-items: center;
    gap: 15px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px 30px;
    margin: 20px 0;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

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

/* Examples section */
.examples {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

.examples h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
    text-align: center;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.example-item {
    background: rgba(255, 255, 255, 0.6);
    padding: 15px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.example-item:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.example-item i {
    font-size: 18px;
    color: #667eea;
}

/* Dashboard grid */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

/* Widget premium styling */
.widget {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 30px;
    box-shadow: var(--shadow);
    border: 1px solid var(--glass-border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.widget:hover {
    transform: translateY(-8px);
    box-shadow: 0 25px 50px rgba(31, 38, 135, 0.3);
}

.widget:hover::before {
    opacity: 1;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.widget-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.widget-close {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-close:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.chart-container {
    position: relative;
    height: 400px;
    margin: 20px 0;
}

/* Loading animation */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 500;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Insights panel */
.insight {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 25px;
    border-radius: 16px;
    margin-top: 25px;
    font-size: 16px;
    line-height: 1.6;
    position: relative;
    overflow: hidden;
}

.insight::before {
    content: '💡';
    font-size: 24px;
    position: absolute;
    top: 20px;
    right: 25px;
    opacity: 0.7;
}

/* Metrics grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.metric-card {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.metric-card:hover {
    transform: scale(1.05);
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
    position: relative;
    z-index: 2;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.metric-label {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 500;
    position: relative;
    z-index: 2;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    text-align: center;
}

/* Table styling */
.data-table {
    max-height: 400px;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 15px 18px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-table th {
    background: rgba(102, 126, 234, 0.1);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    backdrop-filter: blur(10px);
}

.data-table tbody {
    max-height: 300px;
    overflow-y: auto;
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Status notifications */
.status {
    position: fixed;
    top: 30px;
    right: 30px;
    padding: 20px 30px;
    border-radius: 16px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    z-index: 1000;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 350px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.status.show {
    opacity: 1;
    transform: translateX(0);
}

.status.success {
    background: linear-gradient(135deg, #00b894, #00a085);
}

.status.error {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.status.info {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
}

/* Animaciones */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(30px);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== ESTILOS DRILL-DOWN ===== */

/* Widget controls mejorados */
.widget-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.widget-expand-btn {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-expand-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(116, 185, 255, 0.4);
}

/* Metric cards con drill-down */
.metric-card-drilldown {
    position: relative;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
}

.metric-card-drilldown:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.6) !important;
}

.metric-card-drilldown::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: 16px;
}

.metric-card-drilldown:hover::after {
    opacity: 1;
}

.drill-down-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 16px;
    opacity: 0.7;
    transition: all 0.3s ease;
    z-index: 3;
}

.metric-card-drilldown:hover .drill-down-icon {
    opacity: 1;
    transform: scale(1.2);
}

.drill-down-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 3;
}

.metric-card-drilldown:hover .drill-down-hint {
    opacity: 1;
}

/* Contenedor de drill-down */
.drill-down-container {
    margin-top: 25px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    display: none;
}

.drill-down-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.drill-down-header h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.collapse-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

/* Tabla de drill-down */
.drill-down-table {
    max-height: 300px;
    overflow-y: auto;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.drill-down-table table {
    width: 100%;
    border-collapse: collapse;
}

.drill-down-table th {
    background: rgba(102, 126, 234, 0.2);
    color: var(--text-primary);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    backdrop-filter: blur(10px);
}

.drill-down-table td {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.drill-down-table tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

.drill-down-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Cards de drill-down */
.drill-down-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.drill-down-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.drill-down-card:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.drill-down-card-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.drill-down-card-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Widget expandido */
.widget-expanded {
    grid-column: 1 / -1;
    max-width: none;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.widget-expanded .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.widget-expanded .metric-card {
    min-height: 140px;
}

/* Loading pequeño para drill-down */
.loading-small {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: var(--text-secondary);
    font-size: 16px;
    gap: 10px;
}

.loading-small i {
    font-size: 18px;
}

/* Estados de hover mejorados */
.metric-card-drilldown:hover .metric-value {
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.3);
}

.metric-card-drilldown:hover .metric-label {
    color: rgba(255, 255, 255, 0.95);
}

/* Responsive design */
@media (max-width: 1200px) {
    .dashboard {
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    }
    
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 2.5rem;
    }
    
    .controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .example-grid {
        grid-template-columns: 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .metric-card {
        min-height: 100px;
        padding: 15px;
    }
    
    .metric-value {
        font-size: 1.5rem !important;
    }
    
    .metric-label {
        font-size: 0.8rem;
    }
    
    .drill-down-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .drill-down-card {
        padding: 12px;
    }
    
    .drill-down-card-value {
        font-size: 1.2rem;
    }
    
    .drill-down-table {
        font-size: 0.8rem;
    }
    
    .drill-down-table th,
    .drill-down-table td {
        padding: 8px 10px;
    }
    
    .widget-expanded .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-card {
        min-height: 80px;
        padding: 12px;
    }
    
    .metric-value {
        font-size: 1.3rem !important;
    }
    
    .metric-label {
        font-size: 0.75rem;
    }
    
    .drill-down-cards {
        grid-template-columns: 1fr;
    }
    
    .drill-down-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .drill-down-header h4 {
        font-size: 1rem;
    }
    
    .widget-expanded .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* Scroll customization */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2, #f093fb);
}