/**
 * MOON KIDS STORE - ESTILOS PARA SISTEMA DE FRETE
 * Corrige problemas visuais do ícone e melhora a apresentação
 */

/* Correção específica para ícones de frete */
.frete-opcao {
    border: 2px solid #e8f4f5;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    position: relative;
    overflow: hidden;
}

.frete-opcao:hover {
    border-color: #6ac5ca;
    box-shadow: 0 4px 15px rgba(106, 197, 202, 0.15);
    transform: translateY(-2px);
}

.frete-opcao.selecionada {
    border-color: #6ac5ca;
    background: linear-gradient(135deg, #f8fdfe 0%, #e8f4f5 100%);
    box-shadow: 0 6px 20px rgba(106, 197, 202, 0.2);
}

.frete-opcao-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

/* CORREÇÃO DO ÍCONE - POSICIONAMENTO PERFEITO */
.frete-icone {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 10px !important;
    margin-right: 14px !important;
    flex-shrink: 0 !important;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    position: relative;
    overflow: visible;
}

.frete-icone i {
    color: white !important;
    font-size: 18px !important;
    line-height: 1 !important;
    display: block !important;
    text-align: center !important;
    position: relative;
    z-index: 2;
    margin: 0 !important;
    padding: 0 !important;
}

/* Correção específica para ícone de loja (retirada) */
.frete-icone i.fa-store {
    font-size: 16px !important;
    margin-top: -1px !important;
}

/* Correção para ícone de envio */
.frete-icone i.fa-shipping-fast,
.frete-icone i.fa-truck {
    font-size: 17px !important;
}

.frete-info {
    flex: 1;
    min-width: 0;
}

.frete-info h6 {
    font-weight: 600;
    color: #2b3d4f;
    margin: 0 0 4px 0;
    font-size: 1.05em;
}

.frete-preco {
    font-size: 1.1em;
    font-weight: 700;
    color: #6ac5ca;
    margin-bottom: 2px;
}

.frete-opcao .frete-preco:contains("Grátis") {
    color: #28a745 !important;
}

.frete-prazo {
    display: flex;
    align-items: center;
    color: #607489;
    font-size: 0.9em;
    margin-bottom: 6px;
}

.frete-prazo i {
    margin-right: 6px;
    color: #6ac5ca;
    width: 12px;
    text-align: center;
}

.frete-descricao {
    color: #607489;
    font-size: 0.88em;
    margin-bottom: 4px;
    line-height: 1.3;
}

.frete-detalhes {
    color: #8a9ba8;
    font-size: 0.82em;
    font-style: italic;
    background: #f8fbfd;
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 8px;
    border-left: 3px solid #d1f0f1;
}

/* Informação da cidade e peso */
.alert-info {
    background: linear-gradient(135deg, #e8f4f5 0%, #f0f8f9 100%);
    border: 1px solid #b8e6ea;
    border-left: 4px solid #6ac5ca;
    color: #2b3d4f;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9em;
}

.alert-info i {
    color: #6ac5ca;
}

.alert-info strong {
    color: #2b3d4f;
}

.alert-info small {
    color: #607489;
    display: block;
    margin-top: 2px;
}

/* Estados de loading */
.frete-loading {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8fbfd;
    border-radius: 8px;
    border: 2px dashed #d1f0f1;
    color: #607489;
    font-size: 0.9em;
}

.frete-loading i {
    margin-right: 10px;
    color: #6ac5ca;
    animation: spin 1s linear infinite;
}

.frete-erro {
    display: none;
    align-items: center;
    padding: 12px 16px;
    background: #ffeaea;
    border: 1px solid #ffb3b3;
    border-left: 4px solid #dc3545;
    border-radius: 8px;
    color: #721c24;
    font-size: 0.9em;
}

.frete-erro i {
    margin-right: 8px;
    color: #dc3545;
}

/* Animações */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes slideDown {
    from { 
        opacity: 0; 
        transform: translateY(-10px); 
        max-height: 0;
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
        max-height: 500px;
    }
}

.frete-opcoes.ativo {
    animation: slideDown 0.4s ease-out;
}

/* Responsividade */
@media (max-width: 768px) {
    .frete-opcao {
        padding: 14px;
    }
    
    .frete-icone {
        width: 40px !important;
        height: 40px !important;
        margin-right: 12px !important;
    }
    
    .frete-icone i {
        font-size: 16px !important;
    }
    
    .frete-info h6 {
        font-size: 1em;
    }
    
    .frete-preco {
        font-size: 1.05em;
    }
    
    .frete-detalhes {
        padding: 5px 8px;
        font-size: 0.8em;
    }
}

/* Estados especiais */
.frete-opcao[data-tipo="retirada"] .frete-icone {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}
/* Estados especiais - continuação */
.frete-opcao[data-tipo="retirada"] .frete-icone {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.frete-opcao[data-tipo="sedex"] .frete-icone {
    background: linear-gradient(135deg, #6ac5ca 0%, #4ba3a8 100%) !important;
}

/* Correção para texto "Grátis" */
.frete-preco:has-text("Grátis") {
    color: #28a745 !important;
    font-weight: 800;
}

/* Fallback para navegadores que não suportam :has */
.frete-opcao:contains("Grátis") .frete-preco {
    color: #28a745 !important;
}

/* Linha do frete no resumo */
.resumo-linha.frete.gratis {
    background: linear-gradient(135deg, #f0fff4 0%, #e8f5e8 100%);
    border-left: 3px solid #28a745;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 4px 0;
}

.resumo-linha.frete.gratis #frete-valor-display {
    color: #28a745 !important;
    font-weight: 700;
}

/* Animação para atualização de totais */
.resumo-linha.atualizado {
    animation: highlight 0.5s ease;
}

@keyframes highlight {
    0% { background: #fff; }
    50% { background: #f0f8f9; transform: scale(1.02); }
    100% { background: #fff; transform: scale(1); }
}

/* Melhorias no resumo do pedido */
.resumo-secao {
    background: #fafcfd;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e8f4f5;
}

.resumo-linha {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f8f9;
    transition: all 0.3s ease;
}

.resumo-linha:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.resumo-linha.total {
    border-top: 2px solid #e8f4f5;
    padding-top: 12px;
    margin-top: 8px;
    font-size: 1.1em;
}

.resumo-linha i {
    color: #6ac5ca;
    margin-right: 6px;
    width: 14px;
    text-align: center;
}

/* Economia no frete */
.resumo-desconto {
    background: linear-gradient(135deg, #f0fff4 0%, #e8f5e8 100%);
    border: 1px solid #c3e6cb;
    border-left: 4px solid #28a745;
    padding: 10px 14px;
    border-radius: 6px;
    color: #155724;
    font-size: 0.9em;
    margin-top: 8px;
}

.resumo-desconto i {
    color: #28a745;
    margin-right: 8px;
}

/* Calculadora de frete */
.frete-calculadora {
    background: #f8fbfd;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e8f4f5;
}

.frete-input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.frete-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e8f4f5;
    border-radius: 6px;
    font-size: 0.95em;
    transition: all 0.3s ease;
    background: white;
}

.frete-input:focus {
    outline: none;
    border-color: #6ac5ca;
    box-shadow: 0 0 0 3px rgba(106, 197, 202, 0.1);
}

.frete-input.is-valid {
    border-color: #28a745;
    background: #f8fff9;
}

.frete-input.is-invalid {
    border-color: #dc3545;
    background: #fff8f8;
}

.btn-calcular-frete {
    padding: 10px 16px;
    background: linear-gradient(135deg, #6ac5ca 0%, #4ba3a8 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 100px;
}

.btn-calcular-frete:hover:not(:disabled) {
    background: linear-gradient(135deg, #4ba3a8 0%, #3a8a8f 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(106, 197, 202, 0.3);
}

.btn-calcular-frete:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Feedback de validação */
.form-feedback {
    font-size: 0.85em;
    margin-top: 4px;
    padding: 0 2px;
}

.form-feedback.valid {
    color: #28a745;
}

.form-feedback.invalid {
    color: #dc3545;
}

.form-feedback i {
    margin-right: 4px;
    width: 12px;
    text-align: center;
}

/* Correções específicas para mobile */
@media (max-width: 576px) {
    .frete-input-group {
        flex-direction: column;
    }
    
    .btn-calcular-frete {
        width: 100%;
        min-width: auto;
    }
    
    .frete-calculadora {
        padding: 12px;
    }
    
    .alert-info {
        padding: 10px 12px;
        font-size: 0.85em;
    }
    
    .frete-detalhes {
        font-size: 0.75em;
        padding: 4px 6px;
    }
}

/* Correção para Safari - forçar altura do ícone */
@supports (-webkit-appearance: none) {
    .frete-icone {
        -webkit-box-align: center;
        -webkit-box-pack: center;
    }
    
    .frete-icone i {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Correção para Firefox - altura linha */
@-moz-document url-prefix() {
    .frete-icone i {
        line-height: 44px !important;
    }
}

/* Estados de hover melhorados */
.frete-opcao:not(.selecionada):hover .frete-icone {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.frete-opcao.selecionada .frete-icone {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* Transições suaves */
.frete-icone,
.frete-opcao {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Efeito de pulso para opção selecionada */
@keyframes pulse {
    0% { box-shadow: 0 6px 20px rgba(106, 197, 202, 0.2); }
    50% { box-shadow: 0 8px 25px rgba(106, 197, 202, 0.3); }
    100% { box-shadow: 0 6px 20px rgba(106, 197, 202, 0.2); }
}

.frete-opcao.selecionada {
    animation: pulse 2s ease-in-out infinite;
}

/* Melhorar contraste para acessibilidade */
@media (prefers-contrast: high) {
    .frete-opcao {
        border-width: 3px;
    }
    
    .frete-icone {
        box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    }
    
    .frete-descricao,
    .frete-detalhes {
        color: #4a5568;
    }
}

/* Reduzir movimento para usuários sensíveis */
@media (prefers-reduced-motion: reduce) {
    .frete-opcao,
    .frete-icone,
    .btn-calcular-frete {
        transition: none;
        animation: none;
        transform: none !important;
    }
    
    .frete-opcoes.ativo {
        animation: none;
    }
}

/* Debug - remover em produção */
.debug-peso {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    z-index: 9999;
    display: none;
}

/* Mostrar debug em desenvolvimento */
body[data-env="dev"] .debug-peso {
    display: block;
}