/* ==========================================================================
   Ecolivros — Página de produto no sistema visual da homepage
   Carregado só em is_product(), depois de main.css / woocommerce.css / home.css.
   Um fundo, um cartão, Hanken Grotesk, floresta como cor de ação.
   ========================================================================== */

body.eco-product-page {
    --p-bg:       #f6f5f1;
    --p-card:     #ffffff;
    --p-line:     #e6e3da;
    --p-line-2:   #d6d2c6;
    --p-ink:      #18261e;
    --p-soft:     #5d6862;
    --p-forest:   #173f2b;
    --p-forest-2: #1f5a3a;
    --p-tint:     #eaf1ec;
    --p-warm:     #fbeee3;
    --p-warm-ink: #8a4a1c;
    --p-live:     #d9472f;
    --p-font:     'Hanken Grotesk', 'Inter', system-ui, sans-serif;
    background: var(--p-bg) !important;
}
body.eco-product-page .eco-breadcrumb,
body.eco-product-page .eco-product-single,
body.eco-product-page .eco-section,
body.eco-product-page .eco-author,
body.eco-product-page .ep-buybar { font-family: var(--p-font); color: var(--p-ink); }

/* ── Migalhas ─────────────────────────────────────────────────────────── */
body.eco-product-page .eco-breadcrumb { font-size: 13.5px; color: var(--p-soft); padding: 18px 0 14px; }
body.eco-product-page .eco-breadcrumb a { color: var(--p-soft); }
body.eco-product-page .eco-breadcrumb a:hover { color: var(--p-forest); }
body.eco-product-page .eco-breadcrumb > span:last-child { color: var(--p-ink); font-weight: 600; }

/* ── Grelha principal ─────────────────────────────────────────────────── */
body.eco-product-page .eco-product-single {
    display: grid !important; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 40px; align-items: start; background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important;
}
body.eco-product-page .eco-product-gallery {
    position: sticky; top: 96px; width: auto !important; max-width: none !important; margin: 0 !important;
    background: var(--p-card); border: 1px solid var(--p-line); border-radius: 16px; padding: 14px;
}
body.eco-product-page .eco-product-gallery .woocommerce-product-gallery { width: 100% !important; margin: 0 !important; float: none !important; }
body.eco-product-page .eco-product-gallery .woocommerce-product-gallery__image {
    display: flex !important; align-items: center; justify-content: center;
    background: #8de57e !important; border-radius: 10px; overflow: hidden;
}
body.eco-product-page .eco-product-gallery .woocommerce-product-gallery__image img { border-radius: 0; }
body.eco-product-page .eco-product-gallery .woocommerce-product-gallery__trigger { top: 12px !important; right: 12px !important; background: #fff !important; border-radius: 8px !important; }
body.eco-product-page .eco-product-gallery .flex-control-thumbs { display: flex; gap: 8px; margin-top: 10px !important; }
body.eco-product-page .eco-product-gallery .flex-control-thumbs li { width: 64px !important; margin: 0 !important; }
body.eco-product-page .eco-product-gallery .flex-control-thumbs img { border-radius: 6px; opacity: .65; border: 1px solid var(--p-line); }
body.eco-product-page .eco-product-gallery .flex-control-thumbs img.flex-active { opacity: 1; border-color: var(--p-forest-2); }

body.eco-product-page .eco-product-summary {
    display: flex; flex-direction: column; gap: 14px;
    width: auto !important; max-width: none !important; margin: 0 !important; padding: 0 !important;
    background: none !important; border: 0 !important; box-shadow: none !important;
}
body.eco-product-page .eco-product-summary > * { margin-top: 0 !important; margin-bottom: 0 !important; }

/* Categoria, título, autor */
body.eco-product-page .eco-eyebrow { display: flex; }
body.eco-product-page .eco-eyebrow__cat a {
    display: inline-flex; padding: 6px 10px; border-radius: 7px; background: var(--p-tint);
    color: var(--p-forest) !important; font: 600 13px/1 var(--p-font); text-decoration: none; border: 0;
}
body.eco-product-page .eco-eyebrow__sep { margin: 0 4px; color: var(--p-soft); }
body.eco-product-page .eco-product-summary .product_title {
    font: 700 32px/1.15 var(--p-font) !important; letter-spacing: -.015em; color: var(--p-ink) !important; margin: 0 !important;
}
body.eco-product-page .eco-product-author { font: 400 17px/1.3 var(--p-font); color: var(--p-soft); margin: -6px 0 0 !important; }

/* Etiquetas: estado, disponível, último exemplar */
body.eco-product-page .eco-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
body.eco-product-page .eco-meta-row > *,
body.eco-product-page .eco-meta-row .eco-tag {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; margin: 0 !important;
    background: var(--p-card) !important; border: 1px solid var(--p-line) !important; border-radius: 8px !important;
    font: 600 13.5px/1 var(--p-font) !important; color: var(--p-ink) !important;
    text-transform: none !important; letter-spacing: 0 !important; box-shadow: none !important;
}
body.eco-product-page .eco-meta-row .eco-tag svg { color: var(--p-forest-2); }
body.eco-product-page .eco-meta-row .eco-tag--unique { background: var(--p-warm) !important; border-color: transparent !important; color: var(--p-warm-ink) !important; }
body.eco-product-page .eco-meta-row .eco-pts-badge { display: none !important; } /* aparece por cima do botão */

/* Preço */
body.eco-product-page .eco-price-block { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 0 !important; }
body.eco-product-page .eco-price-block__row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
body.eco-product-page .eco-price-block__amount,
body.eco-product-page .eco-price-block__amount .amount,
body.eco-product-page .eco-price-block__amount ins {
    font: 800 34px/1 var(--p-font) !important; color: var(--p-ink) !important; text-decoration: none; letter-spacing: -.01em;
}
body.eco-product-page .eco-price-block__amount del,
body.eco-product-page .eco-price-block__amount del .amount { font: 500 18px/1 var(--p-font) !important; color: var(--p-soft) !important; margin-right: 6px; }
body.eco-product-page .eco-price-block__amount small,
body.eco-product-page .eco-price-block__amount .woocommerce-price-suffix { font: 500 14px/1 var(--p-font) !important; color: var(--p-soft) !important; margin-left: 4px; }
body.eco-product-page .eco-price-block__deal {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px;
    background: var(--p-tint); color: var(--p-forest); font: 500 13.5px/1 var(--p-font); border: 0;
}
body.eco-product-page .eco-price-block__deal-pct { font-weight: 700; }
body.eco-product-page .eco-price-block__co2 { display: flex; align-items: center; gap: 6px; font: 400 13.5px/1.3 var(--p-font); color: var(--p-soft); }
body.eco-product-page .eco-price-block__co2 svg { width: 14px; height: 14px; color: var(--p-forest-2); flex-shrink: 0; }
body.eco-product-page .eco-summary-divider { display: none; }

/* Stock: "Em stock" já está dito nas etiquetas; só mostramos "Esgotado" */
body.eco-product-page .eco-product-summary > .eco-stock--ok { display: none !important; }
body.eco-product-page .eco-product-summary > .eco-stock--out {
    display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; padding: 9px 12px; border-radius: 8px;
    background: #fbe6e0; color: #a3321f; border: 0; font: 700 14px/1 var(--p-font); box-shadow: none;
}

/* Pontos: chip discreto antes do cartão de compra */
body.eco-product-page .eco-product-summary > .eco-pts-badge {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 11px; border-radius: 8px; background: var(--p-tint) !important; border: 0 !important;
    color: var(--p-forest) !important; font: 500 13.5px/1 var(--p-font) !important; box-shadow: none !important;
}

/* ── Cartão de compra ─────────────────────────────────────────────────── */
body.eco-product-page .eco-product-summary form.cart {
    display: flex !important; flex-direction: column; gap: 10px;
    padding: 16px !important; margin: 0 !important;
    background: var(--p-card); border: 1px solid var(--p-line); border-radius: 16px; box-shadow: none;
}
body.eco-product-page form.cart .quantity { display: none !important; }
body.eco-product-page .eco-delivery-info { display: flex; flex-direction: column; gap: 0; margin: 0 0 4px !important; }
body.eco-product-page .eco-delivery-row {
    background: none !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
    padding: 10px 2px !important; margin: 0 !important; font-family: var(--p-font);
}
body.eco-product-page .eco-delivery-row + .eco-delivery-row { border-top: 1px solid var(--p-line) !important; }
body.eco-product-page .eco-delivery-row__ico { background: var(--p-tint) !important; color: var(--p-forest-2) !important; border-radius: 9px !important; border: 0 !important; }
body.eco-product-page .eco-delivery-row__main { font: 600 15px/1.3 var(--p-font) !important; color: var(--p-ink) !important; }
body.eco-product-page .eco-delivery-row__sub,
body.eco-product-page .eco-delivery-row__content small { font: 400 13.5px/1.35 var(--p-font) !important; color: var(--p-soft) !important; }

body.eco-product-page form.cart .single_add_to_cart_button {
    width: 100% !important; height: 54px; margin: 0 !important; border-radius: 12px !important;
    background: var(--p-forest) !important; color: #fff !important; border: 0 !important; box-shadow: none !important;
    font: 700 16px/1 var(--p-font) !important; letter-spacing: 0 !important; text-transform: none !important;
}
body.eco-product-page form.cart .single_add_to_cart_button:hover { background: #0f2c1d !important; }
body.eco-product-page .ecobox-product-btn-wrap { margin: 0 !important; }
body.eco-product-page .ecobox-product-btn-wrap button,
body.eco-product-page .ecobox-product-btn-wrap a {
    width: 100%; min-height: 46px; border-radius: 12px !important; margin: 0 !important;
    background: var(--p-card) !important; border: 1.5px solid var(--p-line-2) !important; color: var(--p-ink) !important;
    font: 600 14.5px/1 var(--p-font) !important; box-shadow: none !important;
}
body.eco-product-page .ecobox-product-btn-wrap button:hover,
body.eco-product-page .ecobox-product-btn-wrap a:hover { border-color: var(--p-forest-2) !important; background: var(--p-tint) !important; }
body.eco-product-page form.cart .eco-product-wishlist-btn {
    position: static !important; width: 100% !important; height: 40px; margin: 0 !important;
    display: inline-flex !important; align-items: center; justify-content: center; gap: 8px;
    background: none !important; border: 0 !important; box-shadow: none !important; border-radius: 10px !important;
    color: var(--p-soft) !important; font: 600 14px/1 var(--p-font) !important;
}
body.eco-product-page form.cart .eco-product-wishlist-btn:hover { color: var(--p-forest) !important; background: var(--p-bg) !important; }
body.eco-product-page form.cart .eco-product-wishlist-btn svg { width: 18px; height: 18px; }
body.eco-product-page form.cart .eco-product-card__fav--active { color: var(--p-live) !important; }

/* Vendido pela Ecolivros */
body.eco-product-page .eco-seller-card {
    width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
    padding: 12px 14px !important; background: var(--p-card) !important; border: 1px solid var(--p-line) !important;
    border-radius: 14px !important; box-shadow: none !important; font-family: var(--p-font);
}
body.eco-product-page .eco-seller-card strong { font: 600 14.5px/1.3 var(--p-font); color: var(--p-ink); }
body.eco-product-page .eco-seller-card__brand { color: var(--p-forest-2) !important; }
body.eco-product-page .eco-seller-card__trust { font: 400 13px/1.3 var(--p-font); color: var(--p-soft); }

/* Sinopse (vem a seguir ao cartão de compra) */
body.eco-product-page .eco-sinopse {
    padding: 16px 0 0 !important; border-top: 1px solid var(--p-line); background: none !important; border-radius: 0 !important;
}
body.eco-product-page .eco-sinopse > :first-child,
body.eco-product-page .eco-sinopse__title,
body.eco-product-page .eco-sinopse h2,
body.eco-product-page .eco-sinopse h3 {
    font: 700 17px/1.2 var(--p-font) !important; color: var(--p-ink) !important; text-transform: none !important; letter-spacing: 0 !important; margin: 0 0 8px !important;
}
body.eco-product-page .eco-sinopse p,
body.eco-product-page .eco-sinopse__text { font: 400 16px/1.6 var(--p-font) !important; color: #2c3a32 !important; }
body.eco-product-page .eco-product-excerpt { font: 400 15px/1.55 var(--p-font); color: var(--p-soft); }

/* Vendido em leilão */
body.eco-product-page .eco-leilao-vendido { background: var(--p-card) !important; border: 1px solid var(--p-line) !important; border-radius: 16px !important; box-shadow: none !important; font-family: var(--p-font); }

/* ── Autor ────────────────────────────────────────────────────────────── */
body.eco-product-page .eco-author { margin-top: 48px !important; padding-top: 0 !important; border-top: 0 !important; }
body.eco-product-page .eco-author__card {
    background: var(--p-card) !important; border: 1px solid var(--p-line) !important; border-radius: 16px !important;
    padding: 22px !important; box-shadow: none !important; gap: 20px;
}
body.eco-product-page .eco-author__photo { border-radius: 12px !important; overflow: hidden; }
body.eco-product-page .eco-author__label { font: 600 12px/1 var(--p-font) !important; letter-spacing: .04em !important; color: var(--p-soft) !important; }
body.eco-product-page .eco-author__name { font: 700 22px/1.2 var(--p-font) !important; color: var(--p-ink) !important; }
body.eco-product-page .eco-author__meta { font: 400 14px/1.3 var(--p-font) !important; color: var(--p-soft) !important; }
body.eco-product-page .eco-author__tag { background: var(--p-bg) !important; border: 1px solid var(--p-line) !important; border-radius: 6px !important; color: var(--p-ink) !important; font: 500 12.5px/1 var(--p-font) !important; padding: 6px 8px !important; }
body.eco-product-page .eco-author__bio { font: 400 15.5px/1.6 var(--p-font) !important; color: #2c3a32 !important; max-width: 760px; }
body.eco-product-page .eco-author__btn { color: var(--p-forest-2) !important; font: 600 14.5px/1 var(--p-font) !important; text-decoration: underline !important; text-underline-offset: 3px; border: 0 !important; background: none !important; padding: 0 !important; }

/* ── Secções em baixo ─────────────────────────────────────────────────── */
body.eco-product-page .eco-section { margin-top: 40px !important; padding-top: 0 !important; border-top: 0 !important; }
body.eco-product-page .eco-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px !important; padding: 0 !important; border: 0 !important; }
body.eco-product-page .eco-section__title {
    font: 700 22px/1.2 var(--p-font) !important; color: var(--p-ink) !important; letter-spacing: -.01em;
    padding-left: 0 !important; border-left: 0 !important; margin: 0 !important;
}
body.eco-product-page .eco-section__title::before { display: none !important; }
body.eco-product-page .eco-section__title em { font-style: normal; color: var(--p-ink) !important; }
body.eco-product-page .eco-section__link { font: 600 14.5px/1 var(--p-font) !important; color: var(--p-forest-2) !important; text-decoration: underline !important; text-underline-offset: 3px; }

body.eco-product-page .eco-section .eco-product-grid { display: grid !important; grid-template-columns: repeat(5, minmax(0, 1fr)) !important; gap: 16px !important; }
body.eco-product-page .eco-section .eco-product-card {
    position: relative; display: flex !important; flex-direction: column;
    background: var(--p-card) !important; border: 1px solid var(--p-line) !important; border-radius: 12px !important;
    padding: 8px !important; box-shadow: none !important; transition: border-color .15s, box-shadow .15s, transform .15s;
}
body.eco-product-page .eco-section .eco-product-card:hover { border-color: var(--p-line-2) !important; transform: translateY(-2px); box-shadow: 0 10px 24px -14px rgba(24, 38, 30, .35) !important; }
body.eco-product-page .eco-section .eco-product-card__img-link {
    display: block; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: #8de57e; padding: 0 !important;
}
body.eco-product-page .eco-section .eco-product-card__img-link img { width: 100% !important; height: 100% !important; object-fit: cover; display: block; margin: 0 !important; border-radius: 0 !important; }
body.eco-product-page .eco-section .eco-product-card__body { display: flex; flex-direction: column; gap: 3px; flex: 1; padding: 10px 4px 4px !important; }
body.eco-product-page .eco-section .eco-product-card__title,
body.eco-product-page .eco-section .eco-product-card__title a {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em;
    font: 600 15px/1.35 var(--p-font) !important; color: var(--p-ink) !important; margin: 0 !important; text-decoration: none;
}
body.eco-product-page .eco-section .eco-product-card__author { font: 400 14px/1.35 var(--p-font) !important; color: var(--p-soft) !important; margin: 0 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.eco-product-page .eco-section .eco-product-card__price-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; }
body.eco-product-page .eco-section .eco-product-card__price,
body.eco-product-page .eco-section .eco-product-card__price .amount { font: 700 17px/1.1 var(--p-font) !important; color: var(--p-ink) !important; }
body.eco-product-page .eco-section .eco-product-card__price del,
body.eco-product-page .eco-section .eco-product-card__price del .amount { font-weight: 400 !important; font-size: 14px !important; color: var(--p-soft) !important; }
body.eco-product-page .eco-section .eco-product-card__price ins { text-decoration: none; }

/* Lotes em leilão */
body.eco-product-page .eco-auction-lot-card { background: var(--p-card) !important; border: 1px solid var(--p-line) !important; border-radius: 12px !important; box-shadow: none !important; padding: 8px !important; font-family: var(--p-font); }
body.eco-product-page .eco-auction-lot-card__img { border-radius: 8px; overflow: hidden; aspect-ratio: 3 / 4; background: #8de57e; }
body.eco-product-page .eco-auction-lot-card__img img { width: 100%; height: 100%; object-fit: cover; }
body.eco-product-page .eco-auction-lot-card__live { background: var(--p-live) !important; color: #fff !important; border-radius: 6px !important; font: 700 12px/1 var(--p-font) !important; }
body.eco-product-page .eco-auction-lot-card__title { font: 600 15px/1.35 var(--p-font) !important; color: var(--p-ink) !important; }
body.eco-product-page .eco-auction-lot-card__price { font: 700 17px/1 var(--p-font) !important; color: var(--p-ink) !important; }

/* ── Barra de compra fixa (telemóvel) ─────────────────────────────────── */
.ep-buybar { display: none; }
@media (max-width: 768px) {
    .ep-buybar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 9400; /* o JS sobe a barra quando o menu de baixo está visível */
        display: flex; align-items: center; gap: 12px; padding: 10px 14px;
        background: var(--p-card); border-top: 1px solid var(--p-line); box-shadow: 0 -4px 14px rgba(24, 38, 30, .07);
        transform: translateY(130%); transition: transform .2s ease, bottom .2s ease;
    }
    .ep-buybar.is-on { transform: none; }
    .ep-buybar__img { width: 36px; aspect-ratio: 3 / 4; border-radius: 5px; object-fit: cover; background: #8de57e; flex-shrink: 0; }
    .ep-buybar__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
    .ep-buybar__name { font: 600 13.5px/1.2 var(--p-font); color: var(--p-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .ep-buybar__price { font: 800 17px/1 var(--p-font); color: var(--p-ink); }
    .ep-buybar__btn {
        height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--p-forest); color: #fff;
        font: 700 15px/1 var(--p-font); white-space: nowrap; cursor: pointer;
    }
}

/* ── Responsivo ───────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    body.eco-product-page .eco-section .eco-product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}
@media (max-width: 900px) {
    body.eco-product-page .eco-product-single { grid-template-columns: 1fr; gap: 20px; }
    body.eco-product-page .eco-product-gallery { position: static; padding: 10px; }
    body.eco-product-page .eco-section .eco-product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 600px) {
    body.eco-product-page .eco-product-summary .product_title { font-size: 25px !important; }
    body.eco-product-page .eco-price-block__amount,
    body.eco-product-page .eco-price-block__amount .amount,
    body.eco-product-page .eco-price-block__amount ins { font-size: 29px !important; }
    body.eco-product-page .eco-product-summary form.cart { padding: 12px !important; }
    body.eco-product-page .eco-section .eco-product-grid {
        display: flex !important; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px !important; padding-bottom: 6px;
        margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none;
    }
    body.eco-product-page .eco-section .eco-product-grid::-webkit-scrollbar { display: none; }
    body.eco-product-page .eco-section .eco-product-card { flex: 0 0 44%; scroll-snap-align: start; }
    body.eco-product-page .eco-author__card { padding: 16px !important; }
    body.eco-product-page .eco-section__title { font-size: 20px !important; }
}
