/**
 * Analytics Module CSS
 * Comprehensive styling for analytics dashboards
 * @version 1.0.0
 */

/* ============================================================================
   Color System (Tailwind-compatible custom colors)
   ============================================================================ */
:root {
    --primary: #8B5CF6;
    --success-green: #10B981;
    --warning-yellow: #F59E0B;
    --danger-red: #EF4444;
    --info-blue: #3B82F6;
    --insight-purple: #8B5CF6;
    --intelligence-cyan: #06B6D4;
    --marriage-gold: #D4AF37;
    --love-pink: #EC4899;
    --eternity-blue: #3B82F6;
    --strategy-indigo: #6366F1;
    --celebration-orange: #F97316;
    --dark-900: #111827;
    --dark-800: #1F2937;
    --dark-700: #374151;
    --dark-600: #4B5563;
}

/* ============================================================================
   Glassmorphism Effects
   ============================================================================ */
.glassmorphism {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glassmorphism {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================================================
   Grid Layouts
   ============================================================================ */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .analytics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================================================
   Metric Cards
   ============================================================================ */
.metric-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    transform: translateY(-0.25rem);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.metric-card:hover::before {
    left: 100%;
}

.metric-value {
    font-variant-numeric: tabular-nums;
}

.metric-change {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

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

@media (min-width: 1024px) {
    .chart-container {
        height: 350px;
    }
}

/* ============================================================================
   Animations
   ============================================================================ */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.6s ease-out;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse-dot {
    animation: pulse 2s infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.kpi-dashboard {
    background: linear-gradient(135deg, #8B5CF6, #06B6D4, #D4AF37);
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
}

@keyframes strategicPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

.strategic-indicator {
    animation: strategicPulse 4s ease-in-out infinite;
}

@keyframes intelligenceFlow {
    0% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.4;
    }
}

.intelligence-flow {
    animation: intelligenceFlow 3s ease-in-out infinite;
}

@keyframes insightGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(139, 92, 246, 0);
    }
}

.insight-highlight {
    animation: insightGlow 3s ease-in-out infinite;
}

/* ============================================================================
   Business Intelligence Cards
   ============================================================================ */
.intelligence-card {
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.intelligence-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.strategic-metric {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(6, 182, 212, 0.1));
    border-radius: 0.5rem;
}

.executive-summary {
    position: relative;
    overflow: hidden;
}

/* ============================================================================
   Funnel Visualization
   ============================================================================ */
.funnel-stage {
    position: relative;
    transition: all 0.3s ease;
}

.funnel-stage:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.conversion-arrow {
    transition: transform 0.3s ease;
}

.conversion-arrow:hover {
    transform: translateX(4px);
}

/* ============================================================================
   Progress Bars
   ============================================================================ */
.progress-bar {
    transition: width 1s ease-in-out;
}

.regional-bar {
    transition: width 0.8s ease-out;
    width: 0;
}

/* ============================================================================
   Modals
   ============================================================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.flex {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s ease-out;
}

.dark .modal-container {
    background: var(--dark-800);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-body {
    max-height: calc(85vh - 8rem);
    overflow-y: auto;
}

/* Custom scrollbar for modals */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.5);
    border-radius: 6px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.7);
}

.dark .modal-body::-webkit-scrollbar-track {
    background: var(--dark-700);
}

.dark .modal-body::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.6);
}

/* ============================================================================
   Loading States
   ============================================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 100;
}

.dark .loading-overlay {
    background: rgba(17, 24, 39, 0.9);
}

.loading-overlay.flex {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================================================
   Tables
   ============================================================================ */
.analytics-table {
    width: 100%;
    border-collapse: collapse;
}

.analytics-table th {
    background: rgba(139, 92, 246, 0.1);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--dark-900);
    border-bottom: 2px solid rgba(139, 92, 246, 0.2);
}

.dark .analytics-table th {
    background: var(--dark-700);
    color: white;
    border-bottom-color: rgba(139, 92, 246, 0.3);
}

.analytics-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dark .analytics-table td {
    border-bottom-color: var(--dark-700);
}

.analytics-table tr:hover {
    background: rgba(139, 92, 246, 0.05);
}

.dark .analytics-table tr:hover {
    background: rgba(139, 92, 246, 0.1);
}

/* ============================================================================
   Buttons
   ============================================================================ */
.intelligence-view-btn {
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.intelligence-view-btn.active {
    background-color: var(--success-green);
    color: white;
}

.bi-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bi-tool-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.dark .bi-tool-btn {
    border-color: var(--dark-600);
}

.dark .bi-tool-btn:hover {
    background: var(--dark-700);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 768px) {
    .chart-container {
        height: 250px;
    }

    .modal-container {
        max-width: 95vw;
    }

    .analytics-grid {
        gap: 1rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .funnel-stage {
        margin-bottom: 1rem;
    }
}

/* ============================================================================
   Print Styles
   ============================================================================ */
@media print {
    .modal,
    .loading-overlay,
    header,
    footer,
    button {
        display: none !important;
    }

    .chart-container {
        break-inside: avoid;
    }

    .metric-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    body {
        background: white;
        color: black;
    }
}

/* ============================================================================
   Accessibility
   ============================================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus styles for keyboard navigation */
button:focus-visible,
a:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================================================
   Custom Utilities
   ============================================================================ */
.text-success-green {
    color: var(--success-green);
}

.text-warning-yellow {
    color: var(--warning-yellow);
}

.text-danger-red {
    color: var(--danger-red);
}

.text-insight-purple {
    color: var(--insight-purple);
}

.text-intelligence-cyan {
    color: var(--intelligence-cyan);
}

.text-marriage-gold {
    color: var(--marriage-gold);
}

.text-love-pink {
    color: var(--love-pink);
}

.text-eternity-blue {
    color: var(--eternity-blue);
}

.text-strategy-indigo {
    color: var(--strategy-indigo);
}

.text-celebration-orange {
    color: var(--celebration-orange);
}

.bg-success-green {
    background-color: var(--success-green);
}

.bg-warning-yellow {
    background-color: var(--warning-yellow);
}

.bg-danger-red {
    background-color: var(--danger-red);
}

.bg-insight-purple {
    background-color: var(--insight-purple);
}

.bg-intelligence-cyan {
    background-color: var(--intelligence-cyan);
}

.bg-marriage-gold {
    background-color: var(--marriage-gold);
}

.bg-eternity-blue {
    background-color: var(--eternity-blue);
}

/* ============================================================================
   Dark Mode Enhancements
   ============================================================================ */
.dark {
    color-scheme: dark;
}

.dark .bg-white {
    background-color: var(--dark-800);
}

.dark .text-gray-900 {
    color: white;
}

.dark .border-gray-200 {
    border-color: var(--dark-700);
}

/* Smooth transitions for dark mode */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Override transition for specific elements */
.metric-card,
.intelligence-card,
.funnel-stage,
button {
    transition: all 0.3s ease;
}
