/* ================================================================
   PÁGINA DO PRODUTO / PERSONALIZAÇÃO
================================================================ */

.main-header {
    position: relative;
}

.back-btn {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 1.1rem;
    text-decoration: none;
    padding: 0.5rem;
}

.product-page {
    padding-bottom: 4rem;
}

/* --- Info --- */
.product-info {
    padding: 1.5rem 1.5rem 0.5rem;
    text-align: center;
}

.product-info h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.25;
}

.product-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-top: 0.35rem;
}

.product-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* --- Preview --- */
.preview-section {
    margin: 1rem 1.5rem;
}

.preview-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    touch-action: none;
}

.preview-stage>img#productImage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
}

.engrave-zone {
    position: absolute;
    border: 1.5px dashed rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    pointer-events: none;
}

/* Alças flutuantes (ficam no palco, fora da camada, para não
   serem afetadas pelo mix-blend-mode da camada) */
.resize-handle {
    position: absolute;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    box-shadow: var(--shadow-sm);
    cursor: nwse-resize;
    touch-action: none;
    z-index: 20;
    user-select: none;
    -webkit-user-select: none;
}

.resize-handle.visible {
    display: flex;
}

.delete-handle {
    background: var(--accent-red);
    cursor: pointer;
    font-size: 0.85rem;
}

.preview-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* --- Camadas de personalização --- */
.custom-layer {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    max-width: 95%;
    touch-action: none;
}

.custom-layer:active {
    cursor: grabbing;
}

.custom-layer.selected {
    outline: 1.5px dashed var(--accent-red);
    outline-offset: 4px;
}

.custom-layer--text {
    white-space: nowrap;
    line-height: 1.1;
    text-align: center;
}

/* parágrafo: largura fixa (em % do palco) e quebra de linha */
.custom-layer--paragraph {
    white-space: pre-line;
    overflow-wrap: break-word;
    line-height: 1.25;
}

.custom-layer--image img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

/* O blend precisa ficar na própria camada (o transform dela cria um
   stacking context que isolaria um blend aplicado só no <img>). */
.custom-layer--image.engrave-dark {
    mix-blend-mode: multiply;
}

.custom-layer--text.engrave-dark {
    mix-blend-mode: multiply;
}

/* --- Painel --- */
.customize-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    margin: 1rem 1.5rem;
    padding: 1.25rem;
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.panel-title i {
    color: var(--accent-brown);
    margin-right: 0.35rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    flex: 1;
    padding: 0.6rem 0.25rem;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.tab-btn i {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.tab-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.tab-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* --- Campos --- */
.field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0.9rem 0 0.35rem;
}

.tab-content input[type="text"],
.tab-content textarea,
.tab-content select {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: #fff;
    color: var(--text-main);
}

.tab-content textarea {
    display: block;
    resize: vertical;
    min-height: 4.5rem;
}

.tab-content input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

.row-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.5rem;
}

.row-inline .field-label {
    margin: 0;
}

/* --- Botões --- */
.btn-primary,
.btn-secondary,
.btn-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem;
    margin-top: 0.9rem;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
    border: none;
}

.btn-secondary {
    background: #fff;
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
}

.btn-remove {
    background: #fff;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

.btn-primary:active,
.btn-secondary:active,
.btn-remove:active {
    transform: scale(0.97);
}

/* --- Upload de foto --- */
.upload-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    text-align: center;
}

.upload-drop i {
    font-size: 1.6rem;
    color: var(--accent-brown);
}

.photo-preview-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.photo-preview-row figure {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.photo-preview-row img,
.convert-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
}

.convert-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 0.5rem;
    text-align: center;
}

.convert-placeholder i {
    font-size: 1.25rem;
}

.photo-preview-row figcaption {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.photo-preview-row>i {
    color: var(--text-muted);
}

/* --- Barra de progresso da conversão automática --- */
.convert-progress {
    width: 100%;
    height: 8px;
    margin-top: 0.7rem;
    background: var(--border-color);
    border-radius: 999px;
    overflow: hidden;
}

.convert-progress-bar {
    height: 100%;
    width: 0;
    background: var(--primary-color);
    border-radius: 999px;
    transition: width 0.25s ease;
}

/* --- Galeria --- */
.gallery-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.gallery-filters button {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #fff;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.gallery-filters button.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.gallery-item {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: #fff;
    padding: 0.6rem 0.4rem 0.4rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.gallery-item:hover,
.gallery-item.selected {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.gallery-item svg,
.gallery-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

/* --- Busca da galeria --- */
.gallery-search {
    position: relative;
    margin-bottom: 0.75rem;
}

.gallery-search i {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.gallery-search input {
    width: 100%;
    padding: 0.65rem 0.8rem 0.65rem 2.2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    background: #fff;
    color: var(--text-main);
}

.gallery-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.gallery-empty {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 1rem 0;
}

.gallery-item span {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 0.25rem;
}

/* --- Ações finais --- */
.product-actions {
    margin: 1rem 1.5rem 0;
}

.btn-whatsapp-order {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.95rem;
    margin-top: 0.75rem;
    border-radius: var(--border-radius-sm);
    background: #25D366;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
}

.btn-whatsapp-order i {
    font-size: 1.15rem;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
    padding: 0.7rem 1.2rem;
    border-radius: 999px;
    font-size: 0.78rem;
    z-index: 999;
    max-width: 90%;
    text-align: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}
