/* ============================================
   RESET E CONFIGURAÇÕES GERAIS
   ============================================ */

/* Remove margens e padding padrão */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Configuração do corpo da página */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5; /* Cinza claro de fundo */
    min-height: 100vh;
    padding: 0;
}

/* ============================================
   TOPBAR (Barra Verde de Segurança)
   ============================================ */

.topbar {
    background-color: #4CAF50; /* Verde vibrante */
    width: 100%;
    padding: 12px 0; /* Espaçamento vertical */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Sombra sutil */
}

.topbar-content {
    max-width: 600px; /* Largura máxima do conteúdo */
    margin: 0 auto; /* Centraliza horizontalmente */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px; /* Espaço entre ícone e texto */
}

/* Ícone de checkmark */
.check-icon {
    color: white;
    font-size: 20px;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.2); /* Fundo branco semi-transparente */
    width: 28px;
    height: 28px;
    border-radius: 50%; /* Deixa circular */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Texto de segurança */
.security-text {
    color: white;
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 0.5px; /* Espaçamento entre letras */
    text-transform: uppercase; /* Tudo em maiúsculas */
}

/* ============================================
   CONTAINER PRINCIPAL
   ============================================ */

.checkout-container {
    max-width: 600px; /* Largura máxima do card */
    margin: 30px auto; /* Centraliza e adiciona espaço superior */
    padding: 0 20px; /* Espaçamento lateral em telas menores */
}

/* ============================================
   CARD DO CHECKOUT
   ============================================ */

.checkout-card {
    background-color: white;
    border-radius: 8px; /* Bordas arredondadas */
    padding: 30px; /* Espaçamento interno */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Sombra suave */
}

/* ============================================
   SEÇÃO DE IDENTIFICAÇÃO
   ============================================ */

.identification-section {
    display: flex;
    align-items: center;
    gap: 12px; /* Espaço entre badge e título */
    margin-bottom: 25px; /* Espaço abaixo */
}

/* Badge azul com número */
.step-badge {
    background-color: #2196F3; /* Azul */
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%; /* Circular */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0; /* Não encolhe */
}

/* Título da seção */
.section-title {
    color: #333; /* Preto/cinza escuro */
    font-size: 20px;
    font-weight: 600; /* Semi-bold */
    margin: 0; /* Remove margem padrão */
}

/* ============================================
   FORMULÁRIO
   ============================================ */

.identification-form {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Espaço entre os campos */
}

/* Grupo de campo do formulário */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Espaço entre label e input */
}

/* Label dos campos */
.form-group label {
    color: #333;
    font-size: 14px;
    font-weight: 500; /* Peso médio */
}

/* Inputs do formulário */
.form-input {
    padding: 12px 15px; /* Espaçamento interno */
    border: 1px solid #e0e0e0; /* Borda cinza clara */
    border-radius: 6px; /* Bordas arredondadas */
    font-size: 15px;
    color: #333;
    transition: border-color 0.2s; /* Animação suave */
    font-family: inherit; /* Usa a fonte do body */
}

/* Placeholder dos inputs */
.form-input::placeholder {
    color: #999; /* Cinza claro */
}

/* Quando o input está em foco */
.form-input:focus {
    outline: none; /* Remove contorno padrão */
    border-color: #4CAF50; /* Borda verde */
}

/* Quando o input tem erro (validação) */
.form-input.error {
    border-color: #f44336; /* Borda vermelha para erro */
}

/* Espaçamento entre cards */
.checkout-card + .checkout-card {
    margin-top: 20px; /* Espaço entre cards */
}

/* ============================================
   SEÇÃO DO PRODUTO PRINCIPAL
   ============================================ */

.product-section-title {
    color: #333;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.product-display {
    display: flex;
    align-items: center;
    gap: 20px; /* Espaço entre imagem e texto */
}

.product-image-container {
    flex-shrink: 0; /* Não encolhe */
    width: 150px; /* Largura fixa para a imagem */
    min-width: 150px; /* Largura mínima */
    border-radius: 8px;
    overflow: hidden; /* Corta a imagem se necessário */
    background-color: #f5f5f5; /* Fundo caso a imagem não carregue */
}

.product-image {
    width: 100%;
    height: auto; /* Mantém proporção da imagem */
    display: block;
}

.product-info {
    flex: 1; /* Ocupa o espaço restante */
    display: flex;
    flex-direction: column;
    gap: 10px; /* Espaço entre nome e preço */
}

.product-name {
    color: #333;
    font-size: 20px;
    font-weight: 600;
    margin: 0; /* Remove margem padrão */
}

.product-price {
    color: #4CAF50; /* Verde para o preço */
    font-size: 22px;
    font-weight: 700; /* Negrito */
}

/* ============================================
   SEÇÃO DE UPSELLS/ORDERBUMPS
   ============================================ */

.upsells-title {
    color: #333;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.upsell-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    background-color: #fafafa;
}

.upsell-content {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
}

.upsell-icon {
    font-size: 40px;
    flex-shrink: 0;
}

.upsell-info {
    flex: 1;
}

.upsell-title {
    color: #2196F3;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
}

.upsell-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
}

.upsell-price {
    color: #4CAF50;
    font-size: 16px;
    font-weight: 600;
}

.upsell-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #333;
    font-size: 14px;
}

.upsell-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ============================================
   SEÇÃO DE PAGAMENTO
   ============================================ */

.payment-methods {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 25px;
}

.payment-method-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background-color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s;
    position: relative;
}

.payment-method-btn:hover {
    border-color: #4CAF50;
}

.payment-method-btn.active {
    border-color: #2196F3;
    background-color: #f0f7ff;
}

.payment-method-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.payment-icon {
    font-size: 24px;
}

/* Ícone de imagem específico para o PIX */
.pix-icon {
    width: 32px;
    height: auto;
    display: block;
}

.check-selected {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #4CAF50;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

/* ============================================
   FORMULÁRIO DE CARTÃO
   ============================================ */

.payment-form {
    margin-top: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
}

.card-input-wrapper {
    position: relative;
}

.card-input-wrapper .input-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 16px;
    pointer-events: none;
}

.help-icon {
    cursor: help;
    pointer-events: auto !important;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.security-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background-color: #f5f5f5;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
    margin: 15px 0;
}

.security-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
    font-size: 14px;
    border-left: 4px solid #c62828;
}

/* ============================================
   FORMULÁRIO DE PIX
   ============================================ */

.pix-content {
    text-align: center;
}

.pix-info {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
}

.pix-qr-container {
    background-color: #f5f5f5;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Imagem do QR (vinda da API ou gerada no frontend) */
.pix-qr-container .pix-qr-image,
.pix-qr-container img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* QR gerado pela biblioteca QRCode.js (table + img) */
.pix-qr-container table {
    margin: 0 auto;
}
.pix-qr-container table img {
    max-width: 100%;
    height: auto;
}

.pix-loading {
    color: #999;
    font-size: 14px;
}

.pix-code-container {
    margin-bottom: 20px;
    text-align: left;
}

.pix-code-container label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

.pix-code-wrapper {
    display: flex;
    gap: 10px;
    align-items: stretch; /* Garante que ambos tenham a mesma altura */
}

.pix-code-wrapper input {
    flex: 1;
    min-width: 0; /* Permite que o input encolha abaixo do tamanho do conteúdo */
    word-break: break-all; /* Quebra palavras longas */
    overflow-wrap: break-word; /* Quebra palavras muito longas */
    overflow-x: hidden; /* Esconde scroll horizontal */
    text-overflow: ellipsis; /* Mostra "..." se o texto for muito longo */
    max-width: 100%; /* Garante que não ultrapasse o container */
}

.copy-btn {
    padding: 12px 16px; /* Reduzido padding horizontal para mobile */
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
    white-space: nowrap; /* Evita quebra de texto no botão */
    flex-shrink: 0; /* Não encolhe o botão */
    min-width: fit-content; /* Mantém tamanho mínimo do conteúdo */
}

.copy-btn:hover {
    background-color: #1976D2;
}

.pix-total {
    margin: 20px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 6px;
    font-size: 18px;
    color: #333;
}

.pix-total strong {
    color: #4CAF50;
}

/* ============================================
   BOTÃO DE PAGAR
   ============================================ */

.pay-button {
    width: 100%;
    padding: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 15px;
}

.pay-button:hover {
    background-color: #45a049;
}

.pay-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* ============================================
   TOTAL DO PEDIDO
   ============================================ */

.order-total {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    text-align: center;
    font-size: 20px;
    color: #333;
}

.order-total strong {
    color: #4CAF50;
}

/* ============================================
   POPUP DE ERRO DO CARTÃO
   ============================================ */

.error-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Fundo escuro semi-transparente */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* Fica acima de tudo */
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.error-popup {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.error-popup-header {
    padding: 25px 25px 15px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.error-popup-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.error-popup-title {
    color: #c62828;
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}

.error-popup-body {
    padding: 25px;
    text-align: center;
}

.error-popup-message {
    color: #333;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
}

.error-popup-footer {
    padding: 15px 25px 25px;
    text-align: center;
}

.error-popup-button {
    width: 100%;
    padding: 14px 24px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.error-popup-button:hover {
    background-color: #45a049;
}

.error-popup-button:active {
    background-color: #3d8b40;
}

/* ============================================
   RESPONSIVIDADE (Telas menores)
   ============================================ */

@media (max-width: 640px) {
    .checkout-card {
        padding: 20px; /* Menos padding em telas pequenas */
    }
    
    .section-title {
        font-size: 18px; /* Título um pouco menor */
    }
    
    .form-row {
        grid-template-columns: 1fr; /* Coluna única em telas pequenas */
    }
    
    .upsell-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    /* Produto em coluna única em telas pequenas */
    .product-display {
        flex-direction: column;
        text-align: center;
    }
    
    .product-image-container {
        width: 100%;
        max-width: 200px;
        height: auto;
        margin: 0 auto;
    }
    
    .product-image {
        height: auto;
    }
    
    /* Ajustes para código PIX em mobile */
    .pix-code-wrapper {
        flex-direction: column; /* Empilha verticalmente em mobile */
        gap: 10px;
    }
    
    .pix-code-wrapper input {
        width: 100%;
        font-size: 13px; /* Fonte menor para caber melhor */
        padding: 10px 12px; /* Padding reduzido */
    }
    
    .copy-btn {
        width: 100%; /* Botão ocupa toda largura em mobile */
        padding: 12px;
        font-size: 14px;
    }
    
    /* Garante que o container não ultrapasse a largura */
    .pix-code-container {
        width: 100%;
        max-width: 100%;
        overflow: hidden; /* Evita overflow */
    }
}

/* Ajustes extras para telas muito pequenas (menos de 400px) */
@media (max-width: 400px) {
    .pix-code-wrapper input {
        font-size: 12px; /* Fonte ainda menor em telas muito pequenas */
        padding: 10px;
    }
    
    .copy-btn {
        padding: 10px;
        font-size: 13px;
    }
    
    .pix-code-container {
        padding: 0; /* Remove padding extra se necessário */
    }
}
