/* ========================================
   Price History Chart Widget
   Integrates with deal-detail.css design
   ======================================== */

/* Widget Container */
.phc-widget {
    --phc-primary: hsl(204, 85%, 62%);
    --phc-accent: hsl(0, 65%, 52%);
    --phc-foreground: hsl(220, 20%, 10%);
    --phc-muted: hsl(220, 10%, 46%);
    --phc-border: hsl(220, 13%, 91%);
    --phc-secondary: hsl(220, 14%, 96%);
    --phc-card: hsl(0, 0%, 100%);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
}

.phc-widget *, .phc-widget *::before, .phc-widget *::after {
    box-sizing: border-box;
}

/* Header */
.phc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}

.phc-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    margin-bottom: 0.3rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--phc-foreground);
}

.phc-title svg {
    color: var(--phc-primary);
}

/* Toggle - Segmented Control Style */
.phc-toggle-container {
    margin-bottom: 0.2rem;
}

.phc-toggle {
    display: flex;
    position: relative;
    background: var(--phc-secondary);
    border-radius: 0.5rem;
    padding: 0.25rem;
    gap: 0;
}

.phc-toggle input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.phc-toggle label {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--phc-muted);
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: color 0.2s ease;
    border-radius: 0.375rem;
    white-space: nowrap;
}

.phc-toggle input[type="radio"]:checked + label {
    color: var(--phc-foreground);
}


.phc-toggle-indicator {
    position: absolute;
    top: 0.25rem;
    left: 0.25rem;
    width: calc(50% - 0.25rem);
    height: calc(100% - 0.5rem);
    background: var(--phc-card);
    border-radius: 0.375rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

/* Chart Wrapper */
.phc-chart-wrapper {
    position: relative;
    height: 180px;
    margin-bottom: 0.2rem;
    background: linear-gradient(180deg, hsla(204, 85%, 62%, 0.03) 0%, transparent 100%);
    border-radius: 0.5rem;
    padding: 0.5rem 0;
}

.phc-chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Empty State */
.phc-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    background: linear-gradient(180deg, hsla(220, 14%, 96%, 0.5) 0%, transparent 100%);
    border-radius: 0.5rem;
}

.phc-empty-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--phc-muted);
    letter-spacing: 0.01em;
}

.phc-empty-sub {
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--phc-muted);
    opacity: 0.6;
}

/* Price Summary */
.phc-summary {
    display: flex;
    justify-content: space-between;
    padding-top: 0.75rem;
    border-top: 1px solid var(--phc-border);
}

.phc-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.phc-summary-label {
    font-size: 0.6875rem;
    text-transform: none;
    letter-spacing: normal;
    color: var(--phc-muted);
    font-weight: 500;
}

.phc-summary-value {
    font-size: 0.9375rem;
    font-weight: 700;
}

.phc-summary-low .phc-summary-value {
    color: var(--phc-foreground);
}

.phc-summary-low.is-lowest .phc-summary-label {
    background: var(--phc-accent);
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.phc-summary-low.is-lowest .phc-summary-value {
    color: var(--phc-accent);
}

.phc-summary-high .phc-summary-value {
    color: var(--phc-foreground);
}

/* Grid - Lowest Price Indicator */
.oferta-card.phc-grid-lowest {
    position: relative;
    overflow: visible;
    border-radius: 0 0 12px 12px;
    margin-top: 24px;
    box-shadow: 0 0 0 1px hsl(0, 65%, 75%), 0 4px 12px rgba(200, 50, 50, 0.15) !important;
}

.oferta-card.phc-grid-lowest::before {
    animation: phc-pulse-banner 2s ease-in-out infinite;
}

.oferta-card.phc-grid-lowest::after {
    content: "";
    position: absolute;
    top: 0;
    left: -2px;
    right: -2px;
    bottom: 0;
    border-radius: 0 0 12px 12px;
    pointer-events: none;
    animation: phc-pulse-border 2s ease-in-out infinite;
}

@keyframes phc-pulse-border {
    0%, 100% {
        box-shadow: 0 0 0 0px transparent;
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(200, 50, 50, 0.3);
    }
}

@keyframes phc-pulse-banner {
    0%, 100% {
        box-shadow: 0 0 0 0px transparent;
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(200, 50, 50, 0.3);
    }
}

.oferta-card.phc-grid-lowest::before {
    content: "Preço Histórico";
    position: absolute;
    bottom: 100%;
    left: -2px;
    right: -2px;
    background: hsl(0, 65%, 52%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    padding: 1px 0;
    letter-spacing: 0.04em;
    border-radius: 12px 12px 0 0;
    box-sizing: content-box;
}

.oferta-card.phc-grid-lowest .oferta-card-price,
.oferta-card.phc-grid-lowest .oferta-card-price-currency,
.oferta-card.phc-grid-lowest .oferta-card-price-integer,
.oferta-card.phc-grid-lowest .oferta-card-price-cents {
    color: hsl(0, 65%, 52%) !important;
}

/* Price/Payment separator */
.price-payment-separator {
    color: #999;
    font-size: 12px;
    font-weight: 400;
}

.oferta-card-price-row .price-payment-separator,
.oferta-card-price-row .oferta-card-payment {
    align-self: center;
}

/* Deal page - Lowest Price */
.deal-page .price-primary.phc-lowest-price {
    flex-wrap: wrap;
}

.deal-page .price-primary.phc-lowest-price .current-price {
    color: hsl(0, 65%, 52%) !important;
}

.phc-deal-badge {
    flex-basis: 100%;
    width: fit-content;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: hsl(0, 65%, 52%);
    padding: 2px 10px;
    border-radius: 4px;
    letter-spacing: 0.03em;
    line-height: 1.5;
    margin-top: 2px;
}

/* compact_grid.php fallback */
.price_for_grid.phc-grid-lowest .oferta-card-price,
.price_for_grid.phc-grid-lowest .oferta-card-price span {
    color: hsl(0, 65%, 52%) !important;
}

/* Responsive */
@media (max-width: 767px) {
    .phc-widget {
        padding: 0;
    }

    .phc-title {
        font-size: 0.9375rem;
    }

    .phc-toggle label {
        padding: 0.4375rem 0.5rem;
        font-size: 0.75rem;
    }

    .phc-chart-wrapper {
        height: 160px;
    }

    .phc-summary-value {
        font-size: 0.875rem;
    }
}
