/**
 * Enhanced Stat Cards CSS
 * AgentTech Earn Platform
 * 
 * Extends the base stat-card styles with:
 * - Trend indicators
 * - Interactive states
 * - Icons
 * - Sparklines
 * - Tooltips
 * - Loading skeletons
 */

/* ============================================
   Stat Card Base Enhancements
   ============================================ */

/* Ensure stat cards have proper positioning */
.stat-card {
    position: relative !important;
}

/* Interactive stat cards */
.stat-card.interactive {
    cursor: pointer;
    position: relative;
}

.stat-card.interactive:hover {
    transform: translateY(-6px) !important;
    box-shadow: 0 12px 48px var(--card-shadow) !important;
}

.stat-card.interactive:active {
    transform: translateY(-2px) !important;
}

/* ============================================
   Stat Card Icon
   ============================================ */

.stat-icon {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-size: 1.5rem;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.stat-card:hover .stat-icon {
    opacity: 1;
    transform: scale(1.05);
}

/* ============================================
   Stat Card Content
   ============================================ */

.stat-content {
    position: relative;
    z-index: 1;
    width: 100%;
}

/* Adjust padding when icon is present */
.stat-card:has(.stat-icon) .stat-content {
    padding-top: 0.5rem;
}

/* ============================================
   Stat Subtitle
   ============================================ */

.stat-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.3;
    font-weight: 500;
}

/* ============================================
   Trend Indicators
   ============================================ */

.stat-trend {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    justify-content: center;
}

.stat-trend i {
    font-size: 0.75rem;
}

.stat-trend span {
    font-weight: 700;
}

.stat-trend small {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.7;
    margin-left: 0.25rem;
}

/* Trend direction colors */
.stat-trend.positive {
    color: #10b981;
}

.stat-trend.positive i {
    color: #10b981;
}

.stat-trend.negative {
    color: #ef4444;
}

.stat-trend.negative i {
    color: #ef4444;
}

.stat-trend.neutral {
    color: var(--text-muted);
}

.stat-trend.neutral i {
    color: var(--text-muted);
}

/* ============================================
   Action Indicator (Click Arrow)
   ============================================ */

.stat-action {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    font-size: 0.85rem;
    opacity: 0;
    transition: all 0.3s ease;
}

.stat-card.interactive:hover .stat-action {
    opacity: 1;
    display: flex;
}

.stat-action i {
    color: var(--text-primary);
}

/* ============================================
   Tooltip Icon
   ============================================ */

.stat-tooltip {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    opacity: 0.4;
    transition: opacity 0.2s ease;
    z-index: 2;
}

.stat-tooltip:hover {
    opacity: 1;
}

.stat-tooltip i {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ============================================
   Bootstrap Tooltip Styling Fix
   ============================================ */

/* Ensure Bootstrap tooltips display properly */
.tooltip {
    z-index: 10000 !important;
    pointer-events: none !important;
}

/* Override Bootstrap fade animation for immediate display */
.tooltip.fade {
    opacity: 0;
    transition: opacity 0.15s linear;
}

.tooltip.show {
    opacity: 0.95 !important;
}

.tooltip .tooltip-inner {
    background-color: #1f2937 !important;
    color: #fff !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 0.375rem !important;
    font-size: 0.875rem !important;
    max-width: 300px !important;
    min-width: 200px !important;
    white-space: normal !important;
    text-align: center !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    line-height: 1.4 !important;
}

.tooltip .tooltip-arrow::before {
    border-top-color: #1f2937 !important;
    border-bottom-color: #1f2937 !important;
}

/* ============================================
   Sparkline Container
   ============================================ */

.stat-sparkline {
    margin-top: 1rem;
    height: 30px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.stat-card:hover .stat-sparkline {
    opacity: 0.9;
}

.stat-sparkline canvas {
    width: 100% !important;
    height: 30px !important;
}

/* ============================================
   Loading States
   ============================================ */

.stat-card.loading {
    pointer-events: none;
}

.stat-card.loading .stat-number,
.stat-card.loading .stat-label,
.stat-card.loading .stat-subtitle {
    opacity: 0.3;
}

/* Skeleton loading animation */
.stat-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
    height: 20px;
    margin: 0.5rem 0;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Stat Card Color Variants
   ============================================ */

/* Primary */
.stat-card-primary .stat-icon {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.stat-card-primary:hover .stat-icon {
    background: rgba(59, 130, 246, 0.25);
}

/* Success */
.stat-card-success .stat-icon {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.stat-card-success:hover .stat-icon {
    background: rgba(16, 185, 129, 0.25);
}

/* Warning */
.stat-card-warning .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.stat-card-warning:hover .stat-icon {
    background: rgba(245, 158, 11, 0.25);
}

/* Danger */
.stat-card-danger .stat-icon {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.stat-card-danger:hover .stat-icon {
    background: rgba(239, 68, 68, 0.25);
}

/* Info */
.stat-card-info .stat-icon {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.stat-card-info:hover .stat-icon {
    background: rgba(99, 102, 241, 0.25);
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 767px) {
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .stat-trend {
        font-size: 0.8rem;
        margin-top: 0.5rem;
    }
    
    .stat-trend small {
        font-size: 0.65rem;
    }
    
    .stat-sparkline {
        height: 25px;
        margin-top: 0.75rem;
    }
    
    .stat-action {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

@media (min-width: 1400px) {
    .stat-icon {
        width: 56px;
        height: 56px;
        font-size: 1.75rem;
    }
    
    .stat-trend {
        font-size: 0.9rem;
        margin-top: 1rem;
    }
    
    .stat-sparkline {
        height: 35px;
        margin-top: 1.25rem;
    }
}

/* ============================================
   Dark Mode Adjustments
   ============================================ */

@media (prefers-color-scheme: dark) {
    .stat-icon {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .stat-card:hover .stat-icon {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .stat-action {
        background: rgba(255, 255, 255, 0.03);
    }
}

/* ============================================
   Accessibility
   ============================================ */

/* Focus states for keyboard navigation */
.stat-card.interactive:focus {
    outline: 2px solid var(--primary-bg);
    outline-offset: 2px;
}

.stat-card.interactive:focus:not(:focus-visible) {
    outline: none;
}

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

