/* Showcase Charts - self-contained replica of core's chart styles */
/* Scoped under #mrt-charts-preview */

#mrt-charts-preview {
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    background: #ffffff;
    border: none;
    box-shadow: none;
    border-radius: 18px;
    padding: 15px;
}

#mrt-charts-preview .mrt-performance-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    margin-top: 5px;
}

#mrt-charts-preview .mrt-performance-title-text {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-left: 5px;
}

#mrt-charts-preview .mrt-performance-title-sub {
    font-weight: 500;
    font-size: 0.65rem;
    color: #94a3b8;
    letter-spacing: 0.05em;
    text-transform: none;
}

/* Pagination */
#mrt-charts-preview .mrt-preview-pagination-wrapper {
    position: relative;
    width: 100%;
}

#mrt-charts-preview .mrt-preview-pagination-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 5px;
}

#mrt-charts-preview .mrt-preview-nav-arrow {
    background: none;
    border: none;
    color: #667eea;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px 10px;
    transition:
        color 0.3s ease,
        transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.7;
    flex-shrink: 0;
}

#mrt-charts-preview .mrt-preview-nav-arrow:hover {
    color: #764ba2;
    transform: scale(1.2);
    opacity: 1;
}

#mrt-charts-preview .mrt-preview-nav-arrow:active {
    transform: scale(1.1);
}

#mrt-charts-preview .mrt-preview-pagination-indicator {
    font-size: 0.85em;
    color: #888;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

#mrt-charts-preview .mrt-preview-page-current {
    font-weight: 700;
    color: #667eea;
}

#mrt-charts-preview .mrt-preview-pages-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    min-height: 200px;
}

#mrt-charts-preview .mrt-preview-pages-container::-webkit-scrollbar {
    display: none;
}

#mrt-charts-preview .mrt-preview-page {
    flex: 0 0 100%;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    min-height: 420px;
}

#mrt-charts-preview .mrt-preview-page.active {
    opacity: 1;
}

/* ---- Chart Lazy Container (replicated from core weight-chart.css) ---- */

#mrt-charts-preview .mrt-chart-lazy-container {
    position: relative;
    width: 100%;
    height: 400px;
    min-height: 400px;
    overflow: hidden;
    border-radius: 18px;
    transform: translateZ(0);
    backface-visibility: hidden;
    mask-image: radial-gradient(white, black);
}

/* Scanning Line Animation */
#mrt-charts-preview .mrt-chart-lazy-container::before {
    content: "";
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 45%,
        rgba(139, 92, 246, 0.05) 46%,
        rgba(139, 92, 246, 0.3) 49.5%,
        rgba(255, 255, 255, 1) 50%,
        rgba(139, 92, 246, 0.3) 50.5%,
        rgba(139, 92, 246, 0.05) 54%,
        transparent 55%
    );
    filter: drop-shadow(0 0 5px rgba(139, 92, 246, 0.5));
    animation:
        ch-chart-scan 8s cubic-bezier(0.4, 0, 0.2, 1) infinite,
        ch-scan-pulse 3s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 5;
    mix-blend-mode: multiply;
    opacity: 0.6;
}

/* Dot Pattern */
#mrt-charts-preview .mrt-chart-lazy-container::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    opacity: 0.6;
    z-index: 0;
}

@keyframes ch-chart-scan {
    0% {
        transform: translateY(-20%);
        opacity: 0;
    }
    15% {
        opacity: 0.3;
    }
    85% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(180%);
        opacity: 0;
    }
}

@keyframes ch-scan-pulse {
    from {
        opacity: 0.2;
    }
    to {
        opacity: 0.5;
    }
}

/* Skeleton Placeholder */
#mrt-charts-preview .mrt-skeleton-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: ch-skeleton-shimmer 1.5s infinite;
    border-radius: 18px;
    z-index: 5;
    transition: opacity 300ms ease-out;
    pointer-events: none;
}

#mrt-charts-preview .mrt-skeleton-placeholder.is-hiding {
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    #mrt-charts-preview .mrt-skeleton-placeholder {
        transition: none;
    }
}

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

/* Force canvases to fill container */
#mrt-charts-preview .mrt-chart-lazy-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Exercise Chart Scanning Line - Indigo */
#mrt-charts-preview #exerciseChartContainer::before {
    background: linear-gradient(
        to bottom,
        transparent 45%,
        rgba(79, 70, 229, 0.05) 46%,
        rgba(79, 70, 229, 0.3) 49.5%,
        rgba(255, 255, 255, 1) 50%,
        rgba(79, 70, 229, 0.3) 50.5%,
        rgba(79, 70, 229, 0.05) 54%,
        transparent 55%
    );
    filter: drop-shadow(0 0 5px rgba(79, 70, 229, 0.5));
}

/* Dark Mode */
html.maxreptracker-dark-mode-enabled #mrt-charts-preview {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.05);
}

html.maxreptracker-dark-mode-enabled
    #mrt-charts-preview
    .mrt-performance-title-text {
    color: rgba(255, 255, 255, 0.7);
}

html.maxreptracker-dark-mode-enabled
    #mrt-charts-preview
    .mrt-performance-title-sub {
    color: rgba(255, 255, 255, 0.4);
}

html.maxreptracker-dark-mode-enabled
    #mrt-charts-preview
    .mrt-chart-lazy-container::before {
    mix-blend-mode: screen;
    opacity: 0.6;
}

html.maxreptracker-dark-mode-enabled
    #mrt-charts-preview
    .mrt-chart-lazy-container::after {
    background-image: radial-gradient(
        rgba(255, 255, 255, 0.05) 1px,
        transparent 1px
    );
}

html.maxreptracker-dark-mode-enabled
    #mrt-charts-preview
    .mrt-skeleton-placeholder {
    background: #2d2d2d;
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    background-size: 200% 100%;
}

/* Responsive */
@media (max-width: 480px) {
    #mrt-charts-preview .mrt-preview-pagination-header {
        padding: 0 2px;
    }
    #mrt-charts-preview .mrt-chart-lazy-container {
        height: 300px;
        min-height: 300px;
    }
}

@media (max-width: 360px) {
    #mrt-charts-preview .mrt-preview-nav-arrow {
        font-size: 1.2em;
        padding: 5px 6px;
    }
    #mrt-charts-preview .mrt-chart-lazy-container {
        height: 250px;
        min-height: 250px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #mrt-charts-preview .mrt-chart-lazy-container::before,
    #mrt-charts-preview .mrt-skeleton-placeholder,
    #mrt-charts-preview .mrt-preview-page.active {
        animation: none !important;
    }
}
