/**
 * CSS público do plugin Móveis Planejados - Sistema de Orçamento.
 * Estilos isolados dentro do container .mpo-orcamento-wrapper.
 * Design mobile-first com variáveis CSS.
 */

/* ============================================================
   VARIÁVEIS CSS
   ============================================================ */
.mpo-orcamento-wrapper {
    --mpo-primary:     #4a8f3f;
    --mpo-primary-dark: #2d5a27;
    --mpo-secondary:   #f0f7f0;
    --mpo-text:        #1a1a1a;
    --mpo-text-light:  #666666;
    --mpo-border:      #e0e0e0;
    --mpo-border-focus: #4a8f3f;
    --mpo-radius:      12px;
    --mpo-radius-sm:   8px;
    --mpo-shadow:      0 2px 16px rgba(0,0,0,0.08);
    --mpo-shadow-hover: 0 4px 24px rgba(0,0,0,0.12);
    --mpo-success:     #4CAF50;
    --mpo-error:       #F44336;
    --mpo-warning:     #FF9800;
    --mpo-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    --mpo-transition:  0.2s ease;
    --mpo-max-width:   860px;

    /* Reset localizado */
    box-sizing: border-box;
    font-family: var(--mpo-font);
    color: var(--mpo-text);
    line-height: 1.5;
    max-width: var(--mpo-max-width);
    margin: 0 auto;
    padding: 0 16px;
}

.mpo-orcamento-wrapper *,
.mpo-orcamento-wrapper *::before,
.mpo-orcamento-wrapper *::after {
    box-sizing: border-box;
}

/* ============================================================
   HONEYPOT - Visualmente oculto mas acessível
   ============================================================ */
.mpo-honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ============================================================
   CABEÇALHO DO FORMULÁRIO
   ============================================================ */
.mpo-form-header {
    text-align: center;
    padding: 32px 16px 24px;
}

.mpo-form-titulo {
    font-size: clamp(22px, 4vw, 32px);
    font-weight: 800;
    color: var(--mpo-text);
    margin: 0 0 12px;
}

.mpo-form-subtitulo {
    font-size: 16px;
    color: var(--mpo-text-light);
    margin: 0;
}

/* ============================================================
   BARRA DE PROGRESSO
   ============================================================ */
.mpo-progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px 32px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.mpo-progress-bar::-webkit-scrollbar { display: none; }

.mpo-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mpo-step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--mpo-border);
    color: var(--mpo-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    transition: background var(--mpo-transition), color var(--mpo-transition);
}

.mpo-step-label {
    font-size: 11px;
    color: var(--mpo-text-light);
    transition: color var(--mpo-transition);
    white-space: nowrap;
}

.mpo-progress-step.active .mpo-step-number,
.mpo-progress-step.completed .mpo-step-number {
    background: var(--mpo-primary);
    color: #fff;
}

.mpo-progress-step.active .mpo-step-label,
.mpo-progress-step.completed .mpo-step-label {
    color: var(--mpo-primary);
    font-weight: 600;
}

.mpo-progress-step.completed .mpo-step-number::after {
    content: '✓';
    font-size: 16px;
}

.mpo-progress-step.completed .mpo-step-number {
    font-size: 0;
}

.mpo-progress-line {
    height: 2px;
    width: 32px;
    background: var(--mpo-border);
    flex-shrink: 0;
    transition: background var(--mpo-transition);
    margin-bottom: 20px;
}

.mpo-progress-line.completed {
    background: var(--mpo-primary);
}

/* ============================================================
   ETAPAS DO FORMULÁRIO
   ============================================================ */
.mpo-step {
    animation: mpoFadeIn 0.3s ease;
    padding: 0 4px;
}

@keyframes mpoFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mpo-step-title {
    font-size: clamp(18px, 3vw, 22px);
    font-weight: 700;
    color: var(--mpo-text);
    margin: 0 0 8px;
}

.mpo-step-desc {
    font-size: 15px;
    color: var(--mpo-text-light);
    margin: 0 0 24px;
}

/* ============================================================
   CARDS DE AMBIENTE E MATERIAL
   ============================================================ */
.mpo-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.mpo-card-item {
    position: relative;
    cursor: pointer;
    border: 2px solid var(--mpo-border);
    border-radius: var(--mpo-radius);
    transition: border-color var(--mpo-transition), box-shadow var(--mpo-transition), transform var(--mpo-transition);
    overflow: hidden;
    background: #fff;
    display: block;
}

.mpo-card-item:hover {
    border-color: var(--mpo-primary);
    box-shadow: var(--mpo-shadow-hover);
    transform: translateY(-2px);
}

.mpo-card-item input[type="radio"],
.mpo-card-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mpo-card-item:has(input:checked) {
    border-color: var(--mpo-primary);
    box-shadow: 0 0 0 3px rgba(74, 143, 63, 0.2);
    background: var(--mpo-secondary);
}

.mpo-card-inner {
    padding: 16px 12px 12px;
    text-align: center;
}

.mpo-card-icon {
    font-size: 32px;
    line-height: 1;
    margin-bottom: 8px;
}

.mpo-card-nome {
    font-size: 13px;
    font-weight: 600;
    color: var(--mpo-text);
    line-height: 1.3;
}

.mpo-card-desc {
    font-size: 12px;
    color: var(--mpo-text-light);
    margin-top: 4px;
    line-height: 1.3;
}

.mpo-card-tipo {
    font-size: 11px;
    color: var(--mpo-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.mpo-card-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--mpo-primary);
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity var(--mpo-transition), transform var(--mpo-transition);
    font-weight: 700;
}

.mpo-card-item:has(input:checked) .mpo-card-check {
    opacity: 1;
    transform: scale(1);
}

/* Swatch de cor para materiais */
.mpo-color-swatch-lg {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin: 0 auto 8px;
    border: 2px solid var(--mpo-border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.mpo-material-img img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: var(--mpo-radius-sm);
    margin-bottom: 8px;
}

.mpo-multiplicador {
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 20px;
    display: inline-block;
}

.mpo-multi-up    { background: #fff3e0; color: #e65100; }
.mpo-multi-down  { background: #e8f5e9; color: #2e7d32; }
.mpo-multi-base  { background: #f5f5f5; color: #666; }

/* ============================================================
   PEÇAS - CHECKBOXES
   ============================================================ */
.mpo-pecas-grid {
    grid-template-columns: 1fr;
}

.mpo-peca-card .mpo-card-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    text-align: left;
    padding: 14px 16px;
}

.mpo-peca-info { flex: 1; }
.mpo-peca-preco {
    font-size: 12px;
    color: var(--mpo-primary);
    font-weight: 600;
    white-space: nowrap;
    margin-top: 4px;
}

/* ============================================================
   SUBTOTAL
   ============================================================ */
.mpo-subtotal {
    background: var(--mpo-secondary);
    border: 1px solid #c8e6c9;
    border-radius: var(--mpo-radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 8px;
}

.mpo-subtotal-label { font-size: 14px; color: var(--mpo-text-light); }
.mpo-subtotal-valor { font-size: 16px; font-weight: 700; color: var(--mpo-primary-dark); }

/* ============================================================
   CAMPOS DO FORMULÁRIO
   ============================================================ */
.mpo-form-group {
    margin-bottom: 20px;
}

.mpo-form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 0;
}

.mpo-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--mpo-text);
    margin-bottom: 6px;
}

.mpo-required { color: var(--mpo-error); margin-left: 2px; }

.mpo-input,
.mpo-select,
.mpo-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--mpo-border);
    border-radius: var(--mpo-radius-sm);
    font-size: 15px;
    font-family: var(--mpo-font);
    color: var(--mpo-text);
    background: #fff;
    transition: border-color var(--mpo-transition), box-shadow var(--mpo-transition);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.mpo-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

.mpo-input:focus,
.mpo-select:focus,
.mpo-textarea:focus {
    border-color: var(--mpo-primary);
    box-shadow: 0 0 0 3px rgba(74, 143, 63, 0.15);
}

.mpo-input.mpo-has-error,
.mpo-select.mpo-has-error,
.mpo-textarea.mpo-has-error {
    border-color: var(--mpo-error);
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1);
}

.mpo-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ============================================================
   MEDIDAS POR PEÇA
   ============================================================ */
.mpo-peca-medidas {
    border: 1px solid var(--mpo-border);
    border-radius: var(--mpo-radius);
    padding: 16px;
    margin-bottom: 16px;
    background: #fafafa;
}

.mpo-peca-medidas-titulo {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 14px;
    color: var(--mpo-text);
}

.mpo-medidas-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mpo-medidas-label {
    font-size: 13px;
    color: var(--mpo-text-light);
    margin-bottom: 4px;
    display: block;
}

.mpo-medidas-grid .mpo-input {
    padding: 10px 12px;
    font-size: 14px;
}

/* ============================================================
   CHECKBOXES CUSTOMIZADOS
   ============================================================ */
.mpo-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.mpo-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--mpo-text);
    line-height: 1.4;
}

.mpo-checkbox { display: none; }

.mpo-checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--mpo-border);
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--mpo-transition), border-color var(--mpo-transition);
}

.mpo-checkbox:checked + .mpo-checkbox-custom {
    background: var(--mpo-primary);
    border-color: var(--mpo-primary);
}

.mpo-checkbox:checked + .mpo-checkbox-custom::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.mpo-link-btn {
    background: none;
    border: none;
    color: var(--mpo-primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    font-family: var(--mpo-font);
}

/* ============================================================
   ERROS DE VALIDAÇÃO
   ============================================================ */
.mpo-field-error {
    font-size: 13px;
    color: var(--mpo-error);
    margin-top: 4px;
    min-height: 18px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mpo-field-error:not(:empty)::before {
    content: '⚠';
    font-size: 12px;
}

.mpo-error-box {
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: var(--mpo-radius-sm);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #b71c1c;
}

/* ============================================================
   NAVEGAÇÃO ENTRE ETAPAS (BOTÕES)
   ============================================================ */
.mpo-step-nav {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--mpo-border);
    flex-wrap: wrap;
}

.mpo-btn-prev,
.mpo-btn-next,
.mpo-btn-submit,
.mpo-btn-primary {
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--mpo-transition), color var(--mpo-transition), transform var(--mpo-transition), opacity var(--mpo-transition);
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mpo-font);
    line-height: 1;
}

.mpo-btn-prev {
    background: transparent;
    color: var(--mpo-text-light);
    border-color: var(--mpo-border);
}

.mpo-btn-prev:hover {
    background: #f5f5f5;
    color: var(--mpo-text);
}

.mpo-btn-next,
.mpo-btn-submit,
.mpo-btn-primary {
    background: var(--mpo-primary);
    color: #fff;
    border-color: var(--mpo-primary);
}

.mpo-btn-next:hover,
.mpo-btn-submit:hover,
.mpo-btn-primary:hover {
    background: var(--mpo-primary-dark);
    border-color: var(--mpo-primary-dark);
    transform: translateY(-1px);
}

.mpo-btn-submit:active {
    transform: translateY(0);
}

.mpo-btn-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Spinner do botão de submit */
.mpo-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mpoSpin 0.8s linear infinite;
    display: none;
}

.mpo-btn-submit.loading .mpo-spinner { display: block; }
.mpo-btn-submit.loading .mpo-btn-text { opacity: 0.7; }

@keyframes mpoSpin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   LOADING STATE (CARREGAMENTO DE PEÇAS)
   ============================================================ */
.mpo-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px;
    color: var(--mpo-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.mpo-loading .mpo-spinner {
    display: block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--mpo-border);
    border-top-color: var(--mpo-primary);
    border-radius: 50%;
    animation: mpoSpin 0.8s linear infinite;
}

/* ============================================================
   RESUMO (ETAPA 6)
   ============================================================ */
.mpo-resumo-card {
    border: 1px solid var(--mpo-border);
    border-radius: var(--mpo-radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.mpo-resumo-secao {
    padding: 16px 20px;
    border-bottom: 1px solid var(--mpo-border);
}

.mpo-resumo-secao:last-child { border-bottom: none; }

.mpo-resumo-titulo {
    font-size: 13px;
    font-weight: 700;
    color: var(--mpo-text-light);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 0 0 10px;
}

.mpo-resumo-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding: 4px 0;
    gap: 16px;
}

.mpo-resumo-label { color: var(--mpo-text-light); }
.mpo-resumo-valor { font-weight: 600; text-align: right; }

.mpo-estimativa-resumo {
    background: var(--mpo-secondary);
    border: 2px solid var(--mpo-primary);
    border-radius: var(--mpo-radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 24px;
}

.mpo-estimativa-label {
    font-size: 13px;
    color: var(--mpo-text-light);
    margin-bottom: 8px;
}

.mpo-estimativa-valor {
    font-size: 28px;
    font-weight: 800;
    color: var(--mpo-primary-dark);
}

.mpo-estimativa-obs {
    font-size: 12px;
    color: var(--mpo-text-light);
    margin-top: 6px;
}

/* ============================================================
   POLÍTICA DE PRIVACIDADE MODAL
   ============================================================ */
.mpo-politica-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 16px;
}

.mpo-politica-overlay[hidden] { display: none; }

.mpo-politica-box {
    background: #fff;
    border-radius: var(--mpo-radius);
    padding: 28px;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.mpo-politica-box h4 {
    margin: 0 0 16px;
    font-size: 18px;
}

/* ============================================================
   TELA DE SUCESSO
   ============================================================ */
.mpo-success-screen[hidden] { display: none; }

.mpo-success-screen {
    padding: 48px 24px;
}

.mpo-success-inner {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.mpo-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    color: var(--mpo-success);
}

.mpo-success-icon svg {
    width: 100%;
    height: 100%;
}

/* Animação do checkmark SVG */
.mpo-checkmark {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: mpoCheck 0.5s ease-out 0.3s forwards;
}

@keyframes mpoCheck {
    to { stroke-dashoffset: 0; }
}

.mpo-success-titulo {
    font-size: 24px;
    font-weight: 800;
    color: var(--mpo-text);
    margin: 0 0 12px;
}

.mpo-success-numero {
    font-size: 36px;
    font-weight: 900;
    color: var(--mpo-primary-dark);
    letter-spacing: 3px;
    margin: 12px 0 16px;
    background: var(--mpo-secondary);
    border-radius: var(--mpo-radius-sm);
    padding: 12px 20px;
    display: inline-block;
}

.mpo-success-prazo {
    font-size: 15px;
    color: var(--mpo-text-light);
    margin: 0 0 24px;
    line-height: 1.6;
}

.mpo-btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 700;
    transition: background var(--mpo-transition), transform var(--mpo-transition);
    font-family: var(--mpo-font);
}

.mpo-btn-whatsapp:hover {
    background: #128C7E;
    transform: translateY(-2px);
    color: #fff;
    text-decoration: none;
}

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */

/* Mobile: até 480px */
@media (max-width: 480px) {
    .mpo-orcamento-wrapper {
        padding: 0 8px;
    }

    .mpo-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mpo-step-nav {
        flex-direction: column-reverse;
    }

    .mpo-btn-prev,
    .mpo-btn-next,
    .mpo-btn-submit {
        width: 100%;
        justify-content: center;
    }

    .mpo-progress-bar {
        padding: 0 0 24px;
    }

    .mpo-step-label { display: none; }

    .mpo-medidas-grid {
        grid-template-columns: 1fr;
    }
}

/* Tablet: 481px a 767px */
@media (min-width: 481px) and (max-width: 767px) {
    .mpo-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .mpo-form-row {
        grid-template-columns: 1fr 1fr;
    }
}

/* Desktop: 768px+ */
@media (min-width: 768px) {
    .mpo-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .mpo-form-row {
        grid-template-columns: 1fr 1fr;
    }

    .mpo-medidas-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Large Desktop: 1024px+ */
@media (min-width: 1024px) {
    .mpo-cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
