/* Sales Metrics Widget - Horizontal Scrollable Cards Design */

/* Main Container - Full Width with Horizontal Scroll */
.sales-metrics-section-full {
    width: 100%;
    margin: 0;
    padding: 0;
    margin-bottom: 48px; /* Match announcements section spacing */
}

.sales-metrics-section {
    position: relative;
    padding: 0;
    background: transparent;
}

/* Horizontal Scroll Container - Blue scrollbar, no background */
.sales-metrics-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 12px 0; /* Extra padding for scrollbar */
}

/* Blue scrollbar with no background track */
.sales-metrics-scroll-container::-webkit-scrollbar {
    height: 8px;
    display: block;
}

.sales-metrics-scroll-container::-webkit-scrollbar-track {
    background: transparent; /* No background */
}

.sales-metrics-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(var(--bs-primary-rgb), 0.3);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.sales-metrics-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--bs-primary-rgb), 0.5);
}

[data-bs-theme="dark"] .sales-metrics-scroll-container::-webkit-scrollbar-track {
    background: transparent; /* No background in dark mode */
}

[data-bs-theme="dark"] .sales-metrics-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(var(--bs-primary-rgb), 0.3);
}

[data-bs-theme="dark"] .sales-metrics-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--bs-primary-rgb), 0.5);
}

/* Firefox scrollbar - blue with no background */
.sales-metrics-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--bs-primary-rgb), 0.3) transparent;
}

[data-bs-theme="dark"] .sales-metrics-scroll-container {
    scrollbar-color: rgba(var(--bs-primary-rgb), 0.3) transparent;
}

/* Grid/Flex Layout for Cards */
.sales-metrics-grid {
    display: flex;
    gap: 1rem; /* Match announcement cards gap (16px) */
    min-width: min-content;
    padding: 0;
}

/* Individual Metric Card - Same width as announcement cards for uniformity */
.sales-metric-card {
    background: white;
    border-radius: 16px;
    padding: 28px; /* Increased padding to make cards taller */
    min-width: 380px; /* Match announcement card width */
    max-width: 380px;
    min-height: 200px; /* Ensure minimum height for taller appearance */
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 20px; /* Increased gap between elements for better vertical spacing */
    position: relative;
    overflow: hidden;
    justify-content: space-between; /* Distribute content evenly */
}

[data-bs-theme="dark"] .sales-metric-card {
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sales-metric-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Top Section: Just Label (no icon) */
.sales-metric-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.sales-metric-label-section {
    flex: 1;
}

.sales-metric-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0;
}

[data-bs-theme="dark"] .sales-metric-label {
    color: #9ca3af;
}

/* Middle Section: Value + Mini Graph with MORE SPACE */
.sales-metric-middle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px; /* INCREASED: more space between value and graph */
    flex: 1; /* Take up available space to push comparison to bottom */
}

.sales-metric-value {
    font-size: 1.9rem; /* Slightly larger */
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #111827;
    line-height: 1;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .sales-metric-value {
    color: #f9fafb;
}

/* Mini Graph Container - More space */
.sales-metric-mini-graph {
    flex: 1;
    height: 44px; /* Slightly taller */
    min-width: 120px; /* Wider minimum */
    position: relative;
}

.sales-metric-mini-graph svg {
    width: 100%;
    height: 100%;
}

/* Bottom Section: Comparison with previous value */
.sales-metric-comparison {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 14px; /* Slightly increased padding */
    border-radius: 8px;
    align-self: flex-start;
    margin-top: auto; /* Push to bottom if card is taller */
}

.sales-metric-comparison.positive {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.sales-metric-comparison.negative {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

[data-bs-theme="dark"] .sales-metric-comparison.positive {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

[data-bs-theme="dark"] .sales-metric-comparison.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.sales-metric-comparison i {
    font-size: 0.75rem;
}

/* "vs." text in grey, smaller */
.vs-text {
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 4px;
}

[data-bs-theme="dark"] .vs-text {
    color: #6b7280;
}

/* Loading State */
.sales-metrics-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    width: 100%;
}

.sales-metrics-loading .spinner-border {
    width: 2rem;
    height: 2rem;
    border-width: 0.25em;
}

/* Skeleton Loading Cards */
.sales-metric-skeleton {
    background: white;
    border-radius: 16px;
    padding: 28px; /* Match metric card padding */
    min-width: 380px; /* Match announcement card width */
    max-width: 380px;
    min-height: 200px; /* Match metric card min-height */
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 20px; /* Match metric card gap */
}

[data-bs-theme="dark"] .sales-metric-skeleton {
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

[data-bs-theme="dark"] .skeleton-line {
    background: linear-gradient(90deg, #374151 0%, #4b5563 50%, #374151 100%);
    background-size: 200% 100%;
}

.skeleton-value {
    height: 30px;
    width: 60%;
    background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 6px;
}

[data-bs-theme="dark"] .skeleton-value {
    background: linear-gradient(90deg, #374151 0%, #4b5563 50%, #374151 100%);
    background-size: 200% 100%;
}

.skeleton-graph {
    height: 44px;
    flex: 1;
    background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

[data-bs-theme="dark"] .skeleton-graph {
    background: linear-gradient(90deg, #374151 0%, #4b5563 50%, #374151 100%);
    background-size: 200% 100%;
}

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

/* Error State */
.sales-metrics-error {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 0.9rem;
}

[data-bs-theme="dark"] .sales-metrics-error {
    color: #9ca3af;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .sales-metrics-grid {
        gap: 16px;
        padding: 0 16px;
    }
    
    .sales-metric-card {
        min-width: 340px; /* Slightly smaller on mobile for better fit */
        max-width: 340px;
        padding: 20px;
    }
    
    .sales-metric-value {
        font-size: 1.6rem;
    }
    
    .sales-metric-middle {
        gap: 16px;
    }
    
    .sales-metric-mini-graph {
        min-width: 100px;
    }
}

/* Smooth Scroll Behavior */
.sales-metrics-scroll-container {
    scroll-behavior: smooth;
}

/* Animation on Load */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sales-metric-card {
    animation: fadeInSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sales-metric-card:nth-child(1) { animation-delay: 0s; }
.sales-metric-card:nth-child(2) { animation-delay: 0.1s; }
.sales-metric-card:nth-child(3) { animation-delay: 0.15s; }
.sales-metric-card:nth-child(4) { animation-delay: 0.2s; }

/* Smooth transitions */
.sales-metric-card,
.sales-metric-label,
.sales-metric-value,
.sales-metric-comparison {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
