/* Store Dashboards - Mobile-First Responsive Design with Theme Support */

/* ===================================
   1. ANIMATIONS & TRANSITIONS
   =================================== */

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

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes shimmer {
    0% { 
        background-position: -1000px 0; 
    }
    100% { 
        background-position: 1000px 0; 
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===================================
   2. DASHBOARD CARDS
   =================================== */

.dashboard-card {
    animation: fadeInUp 0.4s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    overflow: hidden;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

.kpi-card {
    animation: fadeInUp 0.5s ease-out;
    transition: all 0.3s ease;
    border-radius: 16px;
    overflow: hidden;
}

.kpi-card:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.kpi-icon {
    animation: pulse 2s infinite;
    transition: transform 0.3s ease;
}

.kpi-card:hover .kpi-icon {
    transform: scale(1.1);
    animation: none;
}

.stat-row {
    animation: slideIn 0.6s ease-out;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.stat-row:hover {
    background-color: var(--mud-palette-action-hover);
}

.metric-card {
    animation: scaleIn 0.5s ease-out;
    transition: all 0.3s ease;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08);
}

.metric-card:hover {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* ===================================
   3. THEME SUPPORT (Light/Dark Mode)
   =================================== */

.theme-card {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}

.theme-accent {
    background: var(--mud-palette-primary-lighten);
    color: var(--mud-palette-primary-darken);
}

.theme-gradient {
    background: linear-gradient(135deg, var(--mud-palette-primary) 0%, var(--mud-palette-secondary) 100%);
}

/* Theme-aware content boxes */
.theme-surface {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}

.theme-background {
    background: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
}

.theme-warning-light {
    background: var(--mud-palette-warning-lighten, #fff3e0);
    color: var(--mud-palette-warning-darken, #e65100);
}

.theme-info-light {
    background: var(--mud-palette-info-lighten, #e3f2fd);
    color: var(--mud-palette-info-darken, #0d47a1);
}

.theme-success-light {
    background: var(--mud-palette-success-lighten, #e8f5e9);
    color: var(--mud-palette-success-darken, #1b5e20);
}

.theme-error-light {
    background: var(--mud-palette-error-lighten, #ffebee);
    color: var(--mud-palette-error-darken, #c62828);
}

.theme-primary-light {
    background: var(--mud-palette-primary-lighten, #e3f2fd);
    color: var(--mud-palette-primary-darken, #1976d2);
}

.theme-secondary-light {
    background: var(--mud-palette-secondary-lighten, #f3e5f5);
    color: var(--mud-palette-secondary-darken, #7b1fa2);
}

.theme-tertiary-light {
    background: var(--mud-palette-tertiary-lighten, #fff3e0);
    color: var(--mud-palette-tertiary-darken, #f57c00);
}

/* Code block with theme support */
.theme-code-block {
    background: var(--mud-palette-background-grey, #f5f5f5);
    color: var(--mud-palette-text-primary);
    font-family: 'Consolas', monospace;
    padding: 10px;
    border-radius: 4px;
}

/* Text content with theme support */
.theme-text-content {
    color: var(--mud-palette-text-primary, #333);
}

/* Theme-aware padding boxes */
.theme-box-primary {
    background: var(--mud-palette-primary-lighten, #e3f2fd);
    padding: 16px;
}

.theme-box-secondary {
    background: var(--mud-palette-secondary-lighten, #f3e5f5);
    padding: 16px;
}

.theme-box-success {
    background: var(--mud-palette-success-lighten, #e8f5e9);
    padding: 16px;
}

.theme-box-error {
    background: var(--mud-palette-error-lighten, #ffebee);
    padding: 16px;
}

.theme-box-warning {
    background: var(--mud-palette-warning-lighten, #fff3e0);
    padding: 16px;
}

.theme-box-info {
    background: var(--mud-palette-info-lighten, #e3f2fd);
    padding: 16px;
}

/* Text color utilities */
.theme-text-primary {
    color: var(--mud-palette-text-primary) !important;
}

.theme-text-secondary {
    color: var(--mud-palette-text-secondary) !important;
}

.theme-text-disabled {
    color: var(--mud-palette-text-disabled) !important;
}

/* Background utilities */
.theme-bg-surface {
    background: var(--mud-palette-surface) !important;
}

.theme-bg-default {
    background: var(--mud-palette-background) !important;
}

/* Gradient variations for KPI cards */
.theme-gradient-primary {
    background: linear-gradient(135deg, var(--mud-palette-primary) 0%, var(--mud-palette-primary-darken) 100%);
    color: var(--mud-palette-primary-contrast-text, white);
}

.theme-gradient-secondary {
    background: linear-gradient(135deg, var(--mud-palette-secondary) 0%, var(--mud-palette-secondary-darken) 100%);
    color: var(--mud-palette-secondary-contrast-text, white);
}

.theme-gradient-success {
    background: linear-gradient(135deg, var(--mud-palette-success) 0%, var(--mud-palette-success-darken) 100%);
    color: white;
}

.theme-gradient-warning {
    background: linear-gradient(135deg, var(--mud-palette-warning) 0%, var(--mud-palette-warning-darken) 100%);
    color: white;
}

.theme-gradient-info {
    background: linear-gradient(135deg, var(--mud-palette-info) 0%, var(--mud-palette-info-darken) 100%);
    color: white;
}

.theme-gradient-error {
    background: linear-gradient(135deg, var(--mud-palette-error) 0%, var(--mud-palette-error-darken) 100%);
    color: white;
}

/* Semi-transparent overlay for gradient backgrounds */
.theme-overlay-light {
    background: rgba(255, 255, 255, 0.2);
}

.theme-overlay-medium {
    background: rgba(255, 255, 255, 0.1);
}

/* Dark mode specific adjustments */
@media (prefers-color-scheme: dark) {
    .dashboard-card:hover {
        box-shadow: 0 12px 24px rgba(255,255,255,0.08);
    }
    
    .kpi-card:hover {
        box-shadow: 0 8px 20px rgba(255,255,255,0.1);
    }
    
    .theme-warning-light {
        background: rgba(255, 152, 0, 0.15);
        color: var(--mud-palette-warning);
    }
    
    .theme-info-light {
        background: rgba(33, 150, 243, 0.15);
        color: var(--mud-palette-info);
    }
    
    .theme-success-light {
        background: rgba(76, 175, 80, 0.15);
        color: var(--mud-palette-success);
    }
    
    .theme-error-light {
        background: rgba(244, 67, 54, 0.15);
        color: var(--mud-palette-error);
    }
    
    .theme-primary-light {
        background: rgba(33, 150, 243, 0.15);
        color: var(--mud-palette-primary);
    }
    
    .theme-secondary-light {
        background: rgba(156, 39, 176, 0.15);
        color: var(--mud-palette-secondary);
    }
    
    .theme-tertiary-light {
        background: rgba(255, 152, 0, 0.15);
        color: var(--mud-palette-tertiary);
    }
    
    .theme-code-block {
        background: rgba(255, 255, 255, 0.05);
        color: var(--mud-palette-text-primary);
    }
    
    .theme-overlay-light {
        background: rgba(0, 0, 0, 0.2);
    }
    
    .theme-overlay-medium {
        background: rgba(0, 0, 0, 0.3);
    }
}

/* ===================================
   4. MOBILE-FIRST RESPONSIVE DESIGN
   =================================== */

/* Base mobile styles (< 600px) */
.mobile-stack {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 16px;
}

.mobile-full-width {
    width: 100% !important;
}

.mobile-hide {
    display: none !important;
}

.mobile-text-small {
    font-size: 0.875rem !important;
}

/* Tablet styles (600px - 959px) */
@media (min-width: 600px) and (max-width: 959px) {
    .dashboard-card {
        padding: 16px;
    }
    
    .kpi-card .mud-card-content {
        padding: 16px !important;
    }
}

/* Mobile portrait (< 600px) */
@media (max-width: 599px) {
    .kpi-card .mud-card-content {
        padding: 12px !important;
    }
    
    .dashboard-card {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .mobile-button-group {
        flex-direction: column;
        width: 100%;
    }
    
    .mobile-button-group button {
        width: 100%;
    }
    
    /* Reduce font sizes for mobile */
    .mobile-h4 {
        font-size: 1.5rem !important;
    }
    
    .mobile-h5 {
        font-size: 1.25rem !important;
    }
    
    .mobile-h6 {
        font-size: 1rem !important;
    }
    
    /* Stack charts vertically on mobile */
    .chart-container {
        height: 250px !important;
    }
    
    /* Hide certain chart elements on very small screens */
    .mobile-chart-hide-legend .apexcharts-legend {
        display: none !important;
    }
}

/* Desktop styles (>= 960px) */
@media (min-width: 960px) {
    .mobile-stack {
        flex-direction: row !important;
        align-items: center !important;
    }
    
    .mobile-full-width {
        width: auto !important;
    }
    
    .mobile-hide {
        display: inline-flex !important;
    }
}

/* ===================================
   5. LOADING STATES
   =================================== */

.loading-shimmer {
    animation: shimmer 2s infinite;
    background: linear-gradient(
        to right, 
        var(--mud-palette-background-grey) 4%, 
        var(--mud-palette-surface) 25%, 
        var(--mud-palette-background-grey) 36%
    );
    background-size: 1000px 100%;
}

.skeleton-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ===================================
   6. SMOOTH SCROLLING & BEHAVIORS
   =================================== */

html {
    scroll-behavior: smooth;
}

.smooth-scroll {
    scroll-behavior: smooth;
}

/* ===================================
   7. CHART CONTAINERS
   =================================== */

.chart-wrapper {
    position: relative;
    width: 100%;
    transition: all 0.3s ease;
}

.chart-wrapper:hover {
    transform: scale(1.01);
}

/* Mobile chart optimizations */
@media (max-width: 599px) {
    .apexcharts-canvas {
        width: 100% !important;
    }
    
    .apexcharts-legend {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .apexcharts-legend-text {
        font-size: 11px !important;
    }
}

/* ===================================
   8. TABLES RESPONSIVE
   =================================== */

@media (max-width: 599px) {
    .responsive-table {
        font-size: 0.75rem;
    }
    
    .responsive-table th,
    .responsive-table td {
        padding: 8px 4px;
    }
    
    /* Stack table on very small screens if needed */
    .stack-table-mobile tbody,
    .stack-table-mobile tr,
    .stack-table-mobile td {
        display: block;
        width: 100%;
    }
    
    .stack-table-mobile thead {
        display: none;
    }
    
    .stack-table-mobile td {
        text-align: right;
        padding-left: 50%;
        position: relative;
    }
    
    .stack-table-mobile td::before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }
}

/* ===================================
   9. UTILITY CLASSES
   =================================== */

.fade-in {
    animation: fadeInUp 0.6s ease-out;
}

.slide-in {
    animation: slideIn 0.6s ease-out;
}

.scale-in {
    animation: scaleIn 0.5s ease-out;
}

.no-animation {
    animation: none !important;
    transition: none !important;
}

/* Delay animations for staggered effect */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* ===================================
   10. ACCESSIBILITY
   =================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators */
.dashboard-card:focus-visible,
.kpi-card:focus-visible,
.metric-card:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* ===================================
   11. PRINT STYLES
   =================================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    .dashboard-card,
    .kpi-card,
    .metric-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
        animation: none !important;
    }
    
    .print-section {
        page-break-inside: avoid;
    }
}

/* ===================================
   12. PROGRESS BARS & INDICATORS
   =================================== */

.animated-progress {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-striped {
    background-size: 40px 40px;
    animation: progress-striped 1s linear infinite;
}

@keyframes progress-striped {
    0% {
        background-position: 40px 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* ===================================
   13. BADGE & CHIP ENHANCEMENTS
   =================================== */

.animated-chip {
    transition: all 0.2s ease;
}

.animated-chip:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ===================================
   14. SPACING & LAYOUT HELPERS
   =================================== */

.gap-mobile-small {
    gap: 8px;
}

@media (min-width: 600px) {
    .gap-mobile-small {
        gap: 16px;
    }
}

.responsive-padding {
    padding: 12px;
}

@media (min-width: 600px) {
    .responsive-padding {
        padding: 16px;
    }
}

@media (min-width: 960px) {
    .responsive-padding {
        padding: 24px;
    }
}
