/**
 * Widget Expansion System Styles
 * ================================
 * Enhanced styling for widget expansion modal
 */

/* ==================== Expansion Modal ==================== */

#widget-expansion-modal {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#widget-expansion-modal > div {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==================== Tabs ==================== */

.expansion-tab {
    transition: all 0.2s ease;
    position: relative;
}

.expansion-tab:hover:not(.active) {
    background-color: rgba(59, 130, 246, 0.1);
    color: rgb(59, 130, 246);
}

.expansion-tab.active {
    color: rgb(59, 130, 246);
}

/* Dark mode for tabs */
.dark .expansion-tab {
    color: rgb(156, 163, 175);
}

.dark .expansion-tab.active {
    color: rgb(96, 165, 250);
    border-bottom-color: rgb(96, 165, 250);
}

.dark .expansion-tab:hover:not(.active) {
    background-color: rgba(96, 165, 250, 0.1);
    color: rgb(96, 165, 250);
}

/* ==================== AI Chat ==================== */

#ai-chat-container::-webkit-scrollbar {
    width: 6px;
}

#ai-chat-container::-webkit-scrollbar-track {
    background: transparent;
}

#ai-chat-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.dark #ai-chat-container::-webkit-scrollbar-thumb {
    background: #4b5563;
}

/* ==================== Stats Cards ==================== */

.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark .stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ==================== Chart Container ==================== */

#expansion-chart {
    min-height: 400px;
}

/* ==================== Value Cards (Overview) ==================== */

.value-card {
    transition: transform 0.2s ease;
}

.value-card:hover {
    transform: scale(1.02);
}

/* ==================== Loading States ==================== */

.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.dark .loading-skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

/* ==================== Quick Question Buttons ==================== */

.ai-quick-question {
    transition: all 0.2s ease;
}

.ai-quick-question:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ==================== Responsive Design ==================== */

@media (max-width: 768px) {
    #widget-expansion-modal > div {
        max-height: 100vh;
        border-radius: 0;
    }

    #ai-assistant-panel {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
    }

    .expansion-tab {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    .expansion-tab i {
        display: none;
    }
}

@media (max-width: 640px) {
    #ai-assistant-panel {
        width: 100%;
    }

    .value-card {
        font-size: 0.875rem;
    }

    .value-card .text-4xl {
        font-size: 2rem;
    }
}

/* ==================== Trend Indicators ==================== */

.trend-up {
    color: #10b981;
}

.trend-down {
    color: #ef4444;
}

.trend-stable {
    color: #6b7280;
}

/* ==================== Anomaly Badges ==================== */

.anomaly-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.anomaly-badge.extreme {
    background-color: #fee2e2;
    color: #991b1b;
}

.dark .anomaly-badge.extreme {
    background-color: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
}

.anomaly-badge.moderate {
    background-color: #fed7aa;
    color: #92400e;
}

.dark .anomaly-badge.moderate {
    background-color: rgba(249, 115, 22, 0.2);
    color: #fdba74;
}

/* ==================== Data Source Info ==================== */

#data-source-info {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

/* ==================== Export Button Animation ==================== */

#expansion-export-btn {
    position: relative;
    overflow: hidden;
}

#expansion-export-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#expansion-export-btn:active::after {
    width: 200px;
    height: 200px;
}

/* ==================== AI Assistant Panel Animation ==================== */

#ai-assistant-panel {
    transition: all 0.3s ease;
}

#ai-assistant-panel[style*="display: flex"] {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== Raw Data Display ==================== */

#raw-data-display {
    font-family: 'Courier New', Monaco, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
}

#raw-data-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#raw-data-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.dark #raw-data-container::-webkit-scrollbar-track {
    background: #1e293b;
}

#raw-data-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.dark #raw-data-container::-webkit-scrollbar-thumb {
    background: #475569;
}

#raw-data-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dark #raw-data-container::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ==================== Tooltip ==================== */

[title] {
    position: relative;
}

/* ==================== Color Utilities ==================== */

.bg-blue-100 { background-color: #dbeafe; }
.bg-green-100 { background-color: #d1fae5; }
.bg-purple-100 { background-color: #e9d5ff; }
.bg-cyan-100 { background-color: #cffafe; }
.bg-red-100 { background-color: #fee2e2; }
.bg-emerald-100 { background-color: #d1fae5; }
.bg-orange-100 { background-color: #ffedd5; }
.bg-pink-100 { background-color: #fce7f3; }
.bg-indigo-100 { background-color: #e0e7ff; }

.dark .bg-blue-100 { background-color: rgba(59, 130, 246, 0.2); }
.dark .bg-green-100 { background-color: rgba(16, 185, 129, 0.2); }
.dark .bg-purple-100 { background-color: rgba(139, 92, 246, 0.2); }
.dark .bg-cyan-100 { background-color: rgba(6, 182, 212, 0.2); }
.dark .bg-red-100 { background-color: rgba(239, 68, 68, 0.2); }
.dark .bg-emerald-100 { background-color: rgba(16, 185, 129, 0.2); }
.dark .bg-orange-100 { background-color: rgba(249, 115, 22, 0.2); }
.dark .bg-pink-100 { background-color: rgba(236, 72, 153, 0.2); }
.dark .bg-indigo-100 { background-color: rgba(99, 102, 241, 0.2); }

.text-blue-600 { color: #2563eb; }
.text-green-600 { color: #059669; }
.text-purple-600 { color: #7c3aed; }
.text-cyan-600 { color: #0891b2; }
.text-red-600 { color: #dc2626; }
.text-emerald-600 { color: #059669; }
.text-orange-600 { color: #ea580c; }
.text-pink-600 { color: #db2777; }
.text-indigo-600 { color: #4f46e5; }

/* ==================== Print Styles ==================== */

@media print {
    #widget-expansion-modal {
        position: static;
        background: white;
    }

    #ai-assistant-panel,
    .expansion-tab,
    button {
        display: none !important;
    }

    .expansion-tab-content {
        display: block !important;
    }
}

/* ==================== Accessibility ==================== */

.expansion-tab:focus,
button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.dark .expansion-tab:focus,
.dark button:focus {
    outline-color: #60a5fa;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .expansion-tab.active {
        border-bottom-width: 3px;
    }

    button {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
