/**
 * 🚀 Melhorias do Checkout - Estilos
 * CSS adicional para funcionalidades otimizadas
 */

/* ========================================
   1. AUTO-COMPLETE CEP - LOADING STATE
   ======================================== */

.is-loading {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="%23007bff" stroke-width="3"><animate attributeName="stroke-dasharray" dur="1s" repeatCount="indefinite" values="1,200;90,200;1,200"/><animate attributeName="stroke-dashoffset" dur="1s" repeatCount="indefinite" values="0;-35;-125"/></circle></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px !important;
}

.highlight-field {
    animation: highlight-pulse 1s ease;
}

@keyframes highlight-pulse {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: #fff3cd;
    }
}

/* ========================================
   2. INDICADORES DE SEGURANÇA
   ======================================== */

.security-indicators {
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.security-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.security-badge i {
    font-size: 28px;
    flex-shrink: 0;
}

.security-badge small {
    line-height: 1.4;
    text-align: left;
}

@media (max-width: 768px) {
    .security-badge {
        padding: 8px 12px;
        gap: 6px;
    }
    
    .security-badge i {
        font-size: 20px;
    }
    
    .security-badge small {
        font-size: 0.7rem;
    }
}

/* ========================================
   3. PROGRESS BAR MELHORADA
   ======================================== */

.wizard-steps-enhanced {
    position: relative;
    padding: 20px 0;
    margin-bottom: 30px;
}

.wizard-progress-line {
    position: absolute;
    top: 35px;
    left: 10%;
    right: 10%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.wizard-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    transition: width 0.5s ease;
    border-radius: 2px;
}

.wizard-step-enhanced {
    text-align: center;
    position: relative;
}

.wizard-step-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    border: 4px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 28px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

.wizard-step-enhanced.active .wizard-step-icon {
    border-color: #007bff;
    background: #007bff;
    color: white;
    box-shadow: 0 8px 16px rgba(0, 123, 255, 0.3);
    transform: scale(1.15);
}

.wizard-step-enhanced.completed .wizard-step-icon {
    border-color: #28a745;
    background: #28a745;
    color: white;
    animation: check-pop 0.3s ease;
}

@keyframes check-pop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.wizard-step-label {
    font-size: 15px;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

.wizard-step-enhanced.active .wizard-step-label {
    color: #007bff;
}

.wizard-step-enhanced.completed .wizard-step-label {
    color: #28a745;
}

.wizard-step-description {
    font-size: 12px;
    color: #adb5bd;
}

/* ========================================
   4. PARCELAMENTO VISUAL
   ======================================== */

.installment-option {
    transition: all 0.2s ease;
    cursor: pointer;
    border: 2px solid #dee2e6 !important;
}

.installment-option:hover {
    background: #f8f9fa !important;
    border-color: #007bff !important;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.installment-option.selected {
    background: #007bff !important;
    color: white !important;
    border-color: #007bff !important;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.installment-option.selected * {
    color: white !important;
}

.installment-option.recommended {
    border-color: #28a745 !important;
    position: relative;
}

.installment-option.recommended::after {
    content: '⭐ Recomendado';
    position: absolute;
    top: -10px;
    right: -10px;
    background: #28a745;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

/* ========================================
   5. VALIDAÇÃO EM TEMPO REAL - FEEDBACK
   ======================================== */

.form-control.is-valid {
    border-color: #28a745;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

/* ========================================
   6. ANIMAÇÕES GERAIS
   ======================================== */

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

.slide-in-right {
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   7. BOTÕES OTIMIZADOS
   ======================================== */

.btn-checkout-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
}

.btn-checkout-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.btn-checkout-primary:active {
    transform: translateY(0);
}

/* ========================================
   8. LOADING STATES
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   9. RESUMO DE COMPRA STICKY - OTIMIZADO PARA TODAS AS TELAS
   ======================================== */

/* 
 * Configuração base: calcula a posição sticky considerando:
 * - Header principal: ~65px
 * - Navbar: ~40px 
 * - Alert topo: ~32px (quando presente)
 * - Margem de segurança: +10px
 */

/* Desktop - Com alert no topo */
.order-summary-sidebar {
    position: sticky !important;
    top: 145px !important; /* 32px (alert) + 65px (header) + 40px (navbar) + 8px (margem) */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desktop - Sem alert no topo */
body.no-alert .order-summary-sidebar {
    top: 113px !important; /* 65px (header) + 40px (navbar) + 8px (margem) */
}

/* ===== TABLET (769px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .order-summary-sidebar {
        top: 140px !important; /* Header + navbar + margem ajustados para tablet */
        max-width: 100% !important;
        padding: 14px 24px !important;
    }
    
    body.no-alert .order-summary-sidebar {
        top: 108px !important;
    }
    
    /* Card interno mais compacto em tablet */
    .order-summary-sidebar .card {
        border-radius: 10px !important;
    }
    
    .order-summary-sidebar .card-header {
        padding: 1rem !important;
    }
    
    .order-summary-sidebar .card-header h5 {
        font-size: 1.1rem !important;
    }
    
    .order-items-list {
        max-height: 250px !important;
    }
}

/* ===== MOBILE LANDSCAPE (481px - 768px) ===== */
@media (min-width: 481px) and (max-width: 768px) {
    .order-summary-sidebar {
        top: 180px !important; /* Header mobile + navbar + margem + busca */
        max-width: 100% !important;
        padding: 12px 16px !important;
    }
    
    body.no-alert .order-summary-sidebar {
        top: 148px !important;
    }
    
    /* Ajustes para tela menor */
    .order-summary-sidebar .card-header {
        padding: 0.875rem !important;
    }
    
    .order-summary-sidebar .card-header h5 {
        font-size: 1rem !important;
    }
    
    .order-items-list {
        max-height: 200px !important;
    }
    
    .order-item .item-name {
        font-size: 0.85rem !important;
    }
    
    .order-item .item-price {
        font-size: 0.875rem !important;
    }
}

/* ===== MOBILE PORTRAIT (até 480px) ===== */
@media (max-width: 480px) {
    .order-summary-sidebar {
        top: 175px !important; /* Header mobile compacto + navbar + margem */
        max-width: 100% !important;
        padding: 10px 12px !important;
    }
    
    body.no-alert .order-summary-sidebar {
        top: 143px !important;
    }
    
    /* Mobile: resumo bem compacto */
    .order-summary-sidebar .card {
        border-radius: 8px !important;
    }
    
    .order-summary-sidebar .card-header {
        padding: 0.75rem !important;
    }
    
    .order-summary-sidebar .card-header h5 {
        font-size: 0.95rem !important;
    }
    
    .order-summary-sidebar .card-body {
        padding: 0.875rem !important;
    }
    
    .order-items-list {
        max-height: 180px !important;
    }
    
    .order-item {
        padding: 6px 0 !important;
    }
    
    .order-item .item-name {
        font-size: 0.8rem !important;
    }
    
    .order-item .item-price {
        font-size: 0.825rem !important;
    }
}

/* ===== DESKTOP GRANDE (1400px+) ===== */
@media (min-width: 1400px) {
    .order-summary-sidebar {
        top: 145px !important;
        max-width: 400px !important; /* Limita largura máxima em telas grandes */
    }
    
    body.no-alert .order-summary-sidebar {
        top: 113px !important;
    }
}

/* ===== AJUSTES PARA SCROLL SUAVE ===== */
.order-summary-sidebar {
    will-change: transform;
    transform: translateZ(0); /* Hardware acceleration */
}

/* Evitar que o resumo ultrapasse a viewport */
@media (min-height: 800px) {
    .order-items-list {
        max-height: 400px !important;
    }
}

@media (max-height: 799px) and (min-width: 769px) {
    .order-items-list {
        max-height: 250px !important;
    }
}

@media (max-height: 600px) {
    .order-items-list {
        max-height: 150px !important;
    }
    
    .order-summary-sidebar {
        max-height: calc(100vh - 180px) !important;
        overflow-y: auto !important;
    }
}

/* ===== CORREÇÕES PARA IPHONE E SAFE AREA ===== */
@supports (padding: env(safe-area-inset-top)) {
    .order-summary-sidebar {
        top: calc(145px + env(safe-area-inset-top)) !important;
    }
    
    body.no-alert .order-summary-sidebar {
        top: calc(113px + env(safe-area-inset-top)) !important;
    }
    
    @media (max-width: 768px) {
        .order-summary-sidebar {
            top: calc(180px + env(safe-area-inset-top)) !important;
        }
        
        body.no-alert .order-summary-sidebar {
            top: calc(148px + env(safe-area-inset-top)) !important;
        }
    }
}

