/**
 * Estilos frontend - Expresso Abandono Checkout
 * CSS vanilla sem frameworks
 */

/* Indicadores de abandono (ocultos por padrão) */
.expresso-abandono-indicator {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    max-width: 300px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.expresso-abandono-indicator.active {
    display: block;
}

.expresso-abandono-indicator .indicator-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.expresso-abandono-indicator .indicator-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.expresso-abandono-indicator .indicator-message {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

.expresso-abandono-indicator .indicator-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.expresso-abandono-indicator .indicator-close:hover {
    color: #333;
}

/* Overlay de abandono */
.expresso-abandono-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
}

.expresso-abandono-overlay.active {
    display: flex;
}

.expresso-abandono-modal {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    margin: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: modalZoomIn 0.3s ease-out;
}

@keyframes modalZoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.expresso-abandono-modal .modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.expresso-abandono-modal .modal-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.expresso-abandono-modal .modal-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.expresso-abandono-modal .modal-subtitle {
    font-size: 16px;
    color: #666;
    line-height: 1.5;
}

.expresso-abandono-modal .modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.expresso-abandono-modal .modal-button {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.expresso-abandono-modal .modal-button.primary {
    background: #0073aa;
    color: #fff;
}

.expresso-abandono-modal .modal-button.primary:hover {
    background: #005a87;
}

.expresso-abandono-modal .modal-button.secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}

.expresso-abandono-modal .modal-button.secondary:hover {
    background: #e9ecef;
}

/* Indicadores de progresso */
.expresso-abandono-progress {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    display: none;
    max-width: 350px;
}

.expresso-abandono-progress.active {
    display: block;
}

.expresso-abandono-progress .progress-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.expresso-abandono-progress .progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.expresso-abandono-progress .progress-fill {
    height: 100%;
    background: #0073aa;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.expresso-abandono-progress .progress-text {
    font-size: 12px;
    color: #666;
    display: flex;
    justify-content: space-between;
}

/* Notificações toast */
.expresso-abandono-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 99999;
    display: none;
    animation: toastSlideDown 0.3s ease-out;
}

@keyframes toastSlideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.expresso-abandono-toast.active {
    display: block;
}

.expresso-abandono-toast.success {
    background: #28a745;
}

.expresso-abandono-toast.error {
    background: #dc3545;
}

.expresso-abandono-toast.warning {
    background: #ffc107;
    color: #333;
}

/* Destacar campos preenchidos */
.expresso-abandono-field-highlight {
    position: relative;
}

.expresso-abandono-field-highlight::after {
    content: '✓';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #28a745;
    font-weight: bold;
    font-size: 16px;
    pointer-events: none;
}

/* Efeito de salvamento automático */
.expresso-abandono-saving {
    position: relative;
}

.expresso-abandono-saving::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,115,170,0.1);
    border: 2px solid #0073aa;
    border-radius: 4px;
    pointer-events: none;
    animation: savingPulse 1s infinite;
}

@keyframes savingPulse {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.7;
    }
}

/* Contador de abandono */
.expresso-abandono-countdown {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #fff;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    display: none;
    max-width: 250px;
}

.expresso-abandono-countdown.active {
    display: block;
}

.expresso-abandono-countdown .countdown-icon {
    font-size: 20px;
    margin-bottom: 8px;
}

.expresso-abandono-countdown .countdown-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.expresso-abandono-countdown .countdown-timer {
    font-size: 18px;
    font-weight: bold;
    color: #ffc107;
    margin-bottom: 8px;
}

.expresso-abandono-countdown .countdown-message {
    font-size: 12px;
    color: #666;
    line-height: 1.3;
}

/* Animação de loading */
.expresso-abandono-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Estados de campo */
.expresso-abandono-field-required {
    border-left: 4px solid #dc3545 !important;
}

.expresso-abandono-field-completed {
    border-left: 4px solid #28a745 !important;
}

.expresso-abandono-field-optional {
    border-left: 4px solid #6c757d !important;
}

/* Responsividade */
@media (max-width: 768px) {
    .expresso-abandono-indicator {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .expresso-abandono-modal {
        padding: 20px;
        margin: 10px;
    }
    
    .expresso-abandono-modal .modal-title {
        font-size: 20px;
    }
    
    .expresso-abandono-modal .modal-subtitle {
        font-size: 14px;
    }
    
    .expresso-abandono-modal .modal-actions {
        flex-direction: column;
    }
    
    .expresso-abandono-modal .modal-button {
        width: 100%;
    }
    
    .expresso-abandono-progress {
        left: 10px;
        right: 10px;
        bottom: 10px;
        max-width: none;
    }
    
    .expresso-abandono-countdown {
        right: 10px;
        bottom: 10px;
        max-width: 200px;
    }
}

/* Ocultar elementos por padrão */
.expresso-abandono-hidden {
    display: none !important;
}

/* Modo debug - só aparece se WP_DEBUG e plugin debug ativos */
body.wp-debug.expresso-abandono-debug .expresso-abandono-indicator,
body.wp-debug.expresso-abandono-debug .expresso-abandono-progress,
body.wp-debug.expresso-abandono-debug .expresso-abandono-countdown {
    border: 2px dashed #ff0000;
}

body.wp-debug.expresso-abandono-debug .expresso-abandono-indicator::before,
body.wp-debug.expresso-abandono-debug .expresso-abandono-progress::before,
body.wp-debug.expresso-abandono-debug .expresso-abandono-countdown::before {
    content: 'DEBUG MODE';
    position: absolute;
    top: -20px;
    left: 0;
    background: #ff0000;
    color: #fff;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 2px;
}

/* Compatibilidade com temas */
.expresso-abandono-indicator *,
.expresso-abandono-modal *,
.expresso-abandono-progress *,
.expresso-abandono-countdown * {
    box-sizing: border-box;
}

/* Prevenção de conflitos */
.expresso-abandono-indicator,
.expresso-abandono-modal,
.expresso-abandono-progress,
.expresso-abandono-countdown {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.4;
}

/* Acessibilidade */
.expresso-abandono-indicator:focus,
.expresso-abandono-modal:focus,
.expresso-abandono-progress:focus,
.expresso-abandono-countdown:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.expresso-abandono-modal .modal-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Modo alto contraste */
@media (prefers-contrast: high) {
    .expresso-abandono-indicator,
    .expresso-abandono-modal,
    .expresso-abandono-progress,
    .expresso-abandono-countdown {
        border: 2px solid #000;
    }
    
    .expresso-abandono-modal .modal-button.primary {
        background: #000;
        color: #fff;
    }
    
    .expresso-abandono-modal .modal-button.secondary {
        background: #fff;
        color: #000;
        border: 2px solid #000;
    }
}

/* Modo escuro */
@media (prefers-color-scheme: dark) {
    .expresso-abandono-indicator,
    .expresso-abandono-modal,
    .expresso-abandono-progress,
    .expresso-abandono-countdown {
        background: #333;
        color: #fff;
        border-color: #555;
    }
    
    .expresso-abandono-modal .modal-button.secondary {
        background: #555;
        color: #fff;
        border-color: #777;
    }
}

/* Detecção de autocomplete do browser */
input:-webkit-autofill,
select:-webkit-autofill,
textarea:-webkit-autofill {
    animation-name: onAutoFillStart;
    animation-duration: 0.001s;
}

input:not(:-webkit-autofill),
select:not(:-webkit-autofill), 
textarea:not(:-webkit-autofill) {
    animation-name: onAutoFillCancel;
    animation-duration: 0.001s;
}

@keyframes onAutoFillStart {
    from { /*empty*/ }
    to { /*empty*/ }
}

@keyframes onAutoFillCancel {
    from { /*empty*/ }
    to { /*empty*/ }
}

/* Reduzir movimento para usuários sensíveis */
@media (prefers-reduced-motion: reduce) {
    .expresso-abandono-indicator,
    .expresso-abandono-modal,
    .expresso-abandono-progress,
    .expresso-abandono-countdown {
        animation: none !important;
        transition: none !important;
    }
    
    .expresso-abandono-loading {
        animation: none !important;
        border: 2px solid #0073aa;
    }
    
    /* Manter apenas animações essenciais para funcionalidade */
    input:-webkit-autofill,
    select:-webkit-autofill,
    textarea:-webkit-autofill {
        animation-name: onAutoFillStart !important;
        animation-duration: 0.001s !important;
    }
}