/* ==========================================================================
   RubberLive — front-end styles

   Every color/size the admin can configure is applied as a CSS custom
   property on .rubberlive-wrapper (see includes/render.php), with sensible
   fallbacks here so the widget still looks right even if a property is
   somehow missing. --rubberlive-bg defaults to "transparent" so the widget
   automatically inherits whatever background the page already has.
   ========================================================================== */

.rubberlive-wrapper {
    background-color: var(--rubberlive-bg, transparent);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--rubberlive-text, #a2c6a8);
    padding: 24px;
    border-radius: var(--rubberlive-radius, 12px);
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

/* Visually merge bottom margins if we are in combined mode */
.view-combined .rubberlive-price-widget {
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 25px;
}

/* --- PRICE TRENDS --- */
.rubberlive-price-widget {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rubberlive-trends-title {
    font-size: 13px;
    letter-spacing: 1.6px;
    color: var(--rubberlive-text, #a2c6a8);
    font-weight: 700;
    text-transform: uppercase;
}
.rubberlive-main-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.rubberlive-arrow {
    font-size: 26px;
    line-height: 1;
}
.rubberlive-arrow.down { color: var(--rubberlive-down, #ff6060); }
.rubberlive-arrow.up { color: var(--rubberlive-up, #4ef07d); }

.rubberlive-price-val {
    font-size: clamp(34px, 6vw, 52px);
    font-weight: 800;
    color: var(--rubberlive-heading, #ffffff);
    line-height: 1;
    letter-spacing: -0.5px;
}
.rubberlive-unit {
    font-size: 18px;
    color: var(--rubberlive-accent, #4ef07d);
    font-weight: 600;
}
.rubberlive-percentage-badge {
    padding: 4px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 700;
    margin-left: 4px;
}
.rubberlive-percentage-badge.down {
    background-color: color-mix(in srgb, var(--rubberlive-down, #ff6060) 14%, transparent);
    border: 1px solid var(--rubberlive-down, #ff6060);
    color: var(--rubberlive-down, #ff6060);
}
.rubberlive-percentage-badge.up {
    background-color: color-mix(in srgb, var(--rubberlive-up, #4ef07d) 14%, transparent);
    border: 1px solid var(--rubberlive-up, #4ef07d);
    color: var(--rubberlive-up, #4ef07d);
}
.rubberlive-sub-row {
    font-size: 13px;
    color: var(--rubberlive-text, #a2c6a8);
    margin-top: 4px;
    letter-spacing: 0.3px;
}
.rubberlive-sub-caption {
    text-transform: uppercase;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.6px;
    opacity: 0.8;
    margin-right: 4px;
}
.rubberlive-sub-row .white-text {
    color: var(--rubberlive-heading, #ffffff);
    font-weight: 700;
    margin-left: 6px;
}

/* --- CHART --- */
.rubberlive-canvas-container {
    position: relative;
    height: var(--rubberlive-chart-height, 380px);
    width: 100%;
    margin-bottom: 18px;
}

/* Year toggle buttons, placed below the chart. Each button carries its
   dataset's color via the --btn-color custom property (set inline in PHP)
   so the filter row visually matches the chart's line colors. */
.rubberlive-year-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}
.filter-btn {
    background: transparent;
    border: 1.5px solid var(--btn-color, #355e44);
    color: var(--btn-color, #a2c6a8);
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    opacity: 0.55;
    transition: opacity 0.2s ease, transform 0.15s ease;
}
.filter-btn:hover {
    opacity: 0.85;
}
.filter-btn:active {
    transform: scale(0.96);
}
.filter-btn.active {
    opacity: 1;
    background-color: var(--btn-color, #355e44);
    color: #0f1f16;
}
.filter-btn:focus-visible {
    outline: 2px solid var(--rubberlive-accent, #4ef07d);
    outline-offset: 2px;
}

/* --- STAT CARDS --- */
.rubberlive-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.stat-card {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: calc(var(--rubberlive-radius, 12px) * 0.6);
    padding: 16px 20px;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.14);
}
.stat-label {
    display: block;
    font-size: 11px;
    color: var(--rubberlive-text, #a2c6a8);
    letter-spacing: 0.8px;
    margin-bottom: 6px;
    font-weight: 700;
    text-transform: uppercase;
}
.stat-main {
    font-size: 26px;
    font-weight: 800;
    color: var(--rubberlive-heading, #ffffff);
}
.stat-main-green {
    font-size: 26px;
    font-weight: 800;
    color: var(--rubberlive-accent, #4ef07d);
}
.stat-unit {
    font-size: 13px;
    color: var(--rubberlive-text, #a2c6a8);
    font-weight: 500;
}

/* --- RESPONSIVE --- */
@media (max-width: 640px) {
    .rubberlive-wrapper {
        padding: 18px;
    }
    .rubberlive-price-val {
        font-size: 38px;
    }
    .rubberlive-canvas-container {
        height: min(var(--rubberlive-chart-height, 380px), 280px);
    }
    .rubberlive-stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .filter-btn, .stat-card {
        transition: none;
    }
}

/* --- Compact / "reference only" preview mode (used in the admin panel) --- */
.rubberlive-compact {
    padding: 14px;
}
.rubberlive-compact .rubberlive-price-val {
    font-size: 28px;
}
.rubberlive-compact .rubberlive-trends-title {
    font-size: 11px;
}
.rubberlive-compact .rubberlive-unit {
    font-size: 13px;
}
.rubberlive-compact .rubberlive-percentage-badge {
    font-size: 11px;
    padding: 2px 10px;
}
.rubberlive-compact .rubberlive-canvas-container {
    margin-bottom: 10px;
}
.rubberlive-compact .rubberlive-year-filters {
    margin-bottom: 0;
    gap: 5px;
}
.rubberlive-compact .filter-btn {
    padding: 3px 10px;
    font-size: 11px;
}
