/**
 * purchase-form.css — formulário de compra unificada (perfume + cosmético).
 *
 * Prefixo `pf-`. Mobile-first: o bloco base é o do celular e o único
 * @media (min-width: 768px) ACRESCENTA o desktop. Não copiar o CSS de
 * create-purchase-cosmeticos.html, que é desktop-first com max-width:680px.
 *
 * Largura da página sai de .ds-page (design-system.css) — nunca 1280px na mão.
 * As classes de modal/botão do cosFeedback vêm de cosmeticos/styles/cosmeticos.css.
 */

/* ===== Casca ===== */
.pf-back {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--ds-gold-dark);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.pf-card {
    background: var(--ds-card);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius);
    padding: 17px;
    box-shadow: var(--ds-card-shadow);
}

.pf-title { margin: 0; color: var(--ds-text); font-size: 21px; }
.pf-sub { margin: 5px 0 20px; color: var(--ds-text-muted); font-size: 14px; }

/* ===== Seletor de domínio ===== */
.pf-domain {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 22px;
}

.pf-domain-btn {
    /* min-width:0 — filho de grid com texto: sem isso a faixa não encolhe */
    min-width: 0;
    min-height: 52px;
    padding: 10px 12px;
    border: 2px solid var(--ds-border);
    border-radius: var(--ds-radius-btn);
    background: var(--ds-card);
    color: var(--ds-text-muted);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--ds-transition);
}

.pf-domain-btn:hover:not(:disabled) { border-color: var(--ds-border-gold); }

.pf-domain-btn.is-active {
    border-color: var(--ds-gold);
    background: var(--ds-accent-bg);
    color: var(--ds-gold-dark);
}

.pf-domain-btn:disabled { opacity: .55; cursor: not-allowed; }

.pf-domain-note {
    margin: -14px 0 22px;
    color: var(--ds-text-muted);
    font-size: 12px;
}

/* ===== Campos ===== */
.pf-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

.pf-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.pf-field label,
.pf-item label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ds-text-muted);
}

.pf-field select,
.pf-field input,
.pf-item input,
.pf-item select {
    width: 100%;
    min-width: 0;
    height: 44px;
    box-sizing: border-box;
    padding: 0 13px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-card);
    color: var(--ds-text);
    font: inherit;
    font-size: 16px; /* iOS não dá zoom no foco a partir de 16px */
}

.pf-field select:focus,
.pf-field input:focus,
.pf-item input:focus,
.pf-item select:focus {
    outline: none;
    border-color: var(--ds-gold);
    box-shadow: 0 0 0 3px var(--ds-accent-bg);
}

.pf-seller { margin: 8px 0 0; color: var(--ds-text-muted); font-size: 13px; }

/* Tipo da compra (só perfume) */
.pf-tipo { display: flex; flex-wrap: wrap; gap: 18px; }

.pf-tipo-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    color: var(--ds-text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.pf-tipo-opt input { width: 20px; height: 20px; accent-color: var(--ds-gold); }
.pf-hint { margin: 6px 0 0; color: var(--ds-text-muted); font-size: 12px; }

/* ===== Itens ===== */
.pf-items {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--ds-border);
}

.pf-items-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 15px;
}

.pf-items-head h2 { margin: 0; color: var(--ds-text); font-size: 17px; }

.pf-add {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-bg-hover);
    color: var(--ds-gold-dark);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.pf-item-list { display: grid; gap: 12px; }

.pf-item {
    /* z-index: a lista de sugestões do combo precisa cobrir a linha de baixo */
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--ds-border);
    border-radius: 10px;
    background: var(--ds-bg-hover);
}

.pf-item:focus-within { z-index: 10; }
.pf-item > div { min-width: 0; }
.pf-item-product { grid-column: 1 / -1; }

/* Combo de produto */
.pf-combo { position: relative; }
.pf-combo input { padding-right: 42px; }

.pf-combo-clear {
    position: absolute;
    z-index: 21;
    right: 5px;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ds-text-muted);
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.pf-combo-clear:hover { background: var(--ds-bg-hover); color: var(--ds-text); }

.pf-results {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 210px;
    overflow: auto;
    background: var(--ds-card);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    box-shadow: var(--ds-card-shadow-lg);
}

.pf-results button {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 11px 13px;
    border: 0;
    border-bottom: 1px solid var(--ds-border);
    background: transparent;
    color: var(--ds-text);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.pf-results button:hover { background: var(--ds-bg-hover); }
.pf-results-empty { padding: 11px 13px; color: var(--ds-text-muted); font-size: 14px; }

/* Tamanho fica dentro da célula do produto: some junto quando o produto
   tem um tamanho só, sem deixar buraco na grade. */
.pf-variant { display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }

.pf-item-total {
    grid-column: 1 / 2;
    height: 44px;
    display: flex;
    align-items: center;
    color: var(--ds-gold-dark);
    font-weight: 700;
    font-size: 14px;
}

.pf-remove {
    grid-column: 2 / 3;
    height: 44px;
    padding: 0 13px;
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: var(--ds-danger-bg);
    color: #c41e1e;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

/* ===== Totais e ação ===== */
.pf-grand {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 2px solid var(--ds-border);
    color: var(--ds-gold-dark);
    font-size: 17px;
    font-weight: 700;
    text-align: left;
}

/* Barra fixa no rodapé: no celular o formulário é longo e "Salvar" precisa
   ficar no alcance do polegar (mesmo padrão de cosmeticos/styles/cosmeticos.css). */
.pf-actions {
    position: sticky;
    bottom: 0;
    z-index: 30;
    margin: 20px -17px -17px;
    padding: 12px 17px calc(12px + env(safe-area-inset-bottom));
    background: var(--ds-card);
    border-top: 1px solid var(--ds-border);
}

.pf-save {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: var(--ds-gold-gradient);
    color: #1a1305;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.pf-save:disabled { opacity: .6; cursor: wait; }

.pf-back-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    margin-top: 16px;
}

/* ===== Desktop ===== */
@media (min-width: 768px) {
    .pf-card { padding: 24px; }
    .pf-title { font-size: 23px; }
    .pf-grid { grid-template-columns: 1fr 1fr; }
    .pf-field-full { grid-column: 1 / -1; }

    .pf-items-head { flex-direction: row; justify-content: space-between; align-items: center; }
    .pf-add { width: auto; }

    .pf-item { grid-template-columns: minmax(0, 2fr) 84px 130px 130px auto; }
    .pf-item-product { grid-column: auto; }
    .pf-item-total { grid-column: auto; }
    .pf-remove { grid-column: auto; }

    .pf-grand { font-size: 19px; text-align: right; }

    .pf-actions {
        position: static;
        margin: 0;
        padding: 0;
        background: transparent;
        border-top: 0;
    }

    .pf-save { margin-top: 24px; }
}
