/**
 * TUH Promotions - Frontend Styles
 *
 * Estrutura:
 *   1. Container base (compartilhado por todos os tipos)
 *   2. Overlay
 *   3. Tipos de promocao (popup, fullscreen, sidebar-card, floating-bar, inline, custom)
 *   4. Posicao do container (data-position)
 *   5. Botao fechar
 *   6. Conteudo do usuario (.tuh-promo-body)
 *   7. Bloco de cupom (renderizado pelo sistema em todos os tipos)
 *   8. Formulario de lead (renderizado pelo sistema em todos os tipos)
 *   9. Animacoes de entrada
 *  10. Device visibility + Responsive + Acessibilidade
 *
 * @package TUH\Core\Features\Promotions
 * @since 3.6.0
 */


/* ==========================================================================
   1. CONTAINER BASE — compartilhado por TODOS os tipos
   ========================================================================== */

.tuh-promo {
    display: none;
    position: fixed;
    z-index: var(--tuh-promo-z-container, 99990);
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
}

.tuh-promo *,
.tuh-promo *::before,
.tuh-promo *::after {
    box-sizing: border-box;
}

/* JS adiciona esta classe para mostrar */
.tuh-promo-visible {
    display: block;
}


/* ==========================================================================
   2. OVERLAY — fundo escuro atras da promo
   ========================================================================== */

.tuh-promo-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--tuh-promo-z-overlay, 99989);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: tuh-fadeIn 0.3s ease-out both;
}


/* ==========================================================================
   3. TIPOS DE PROMOCAO
   ========================================================================== */

/* --- Popup: caixa centralizada --- */
.tuh-promo-popup {
    inset: 0;
    margin: auto;
    width: 800px;
    max-width: 92vw;
    max-height: 86vh;
    height: fit-content;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    padding: 32px;
    overflow: auto;
}

/* --- Fullscreen: ocupa a tela inteira --- */
.tuh-promo-fullscreen {
    inset: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    overflow-y: auto;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.tuh-promo-fullscreen.tuh-promo-visible {
    display: flex;
}

/* --- Sidebar Card: cartao lateral --- */
.tuh-promo-sidebar-card {
    right: 20px;
    bottom: 20%;
    width: 320px;
    max-width: 90vw;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 24px;
}

.tuh-promo-sidebar-card[data-position="bottom-left"],
.tuh-promo-sidebar-card[data-position="left"] {
    right: auto;
    left: 20px;
}

/* --- Floating Bar: barra fixa topo/rodape --- */
.tuh-promo-floating-bar {
    left: 0;
    right: 0;
    width: 100%;
    background: #fff;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
    padding: 16px 24px;
    display: none;
    align-items: center;
    justify-content: center;
}

.tuh-promo-floating-bar.tuh-promo-visible {
    display: flex;
}

.tuh-promo-floating-bar[data-position="top"] {
    top: 0;
    bottom: auto;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.tuh-promo-floating-bar[data-position="bottom"],
.tuh-promo-floating-bar:not([data-position="top"]) {
    bottom: 0;
    top: auto;
}

/* --- Inline: dentro do fluxo da pagina --- */
.tuh-promo-inline {
    position: relative;
    z-index: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 24px;
    margin: 20px 0;
}

.tuh-promo-inline.tuh-promo-visible {
    display: block;
}

/* --- Custom: voce controla o visual via CSS personalizado ---
 *
 * O container .tuh-promo-custom nao tem estilos visuais (sem background,
 * padding, border-radius, etc). Voce define tudo pelo CSS da promo.
 *
 * O sistema AINDA renderiza automaticamente dentro do container:
 *   - Botao fechar (.tuh-promo-close) se ativado
 *   - Bloco de cupom (.tuh-promo-coupon) se ativado
 *   - Formulario de lead (.tuh-promo-lead-form) se ativado
 *
 * Esses elementos usam os estilos padrao abaixo. Para personaliza-los
 * no contexto custom, use seletores como:
 *   .tuh-promo-custom .tuh-promo-coupon { ... }
 *   .tuh-promo-custom .tuh-promo-lead-form { ... }
 */
.tuh-promo-custom {
    /* Sem estilos visuais — usuario controla via CSS da promo */
}

/* --- Tagged: usuario posiciona blocos via template tags ({{fechar}}, {{cupom}}, etc).
 * Strip visual do container — usuario controla tudo via seu CSS.
 * O container mantem APENAS posicionamento (fixed, inset, z-index, max dims).
 */
.tuh-promo.tuh-promo-tagged {
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

.tuh-promo-popup.tuh-promo-tagged {
    width: fit-content;
    min-width: 280px;
}

.tuh-promo-sidebar-card.tuh-promo-tagged {
    width: fit-content;
    min-width: 240px;
}

.tuh-promo-floating-bar.tuh-promo-tagged {
    width: auto;
}

.tuh-promo-inline.tuh-promo-tagged {
    margin: 0;
}


/* ==========================================================================
   4. POSICAO DO CONTAINER (data-position)
   ========================================================================== */

.tuh-promo[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
    top: auto;
    left: auto;
    transform: none;
}

.tuh-promo[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
    top: auto;
    right: auto;
    transform: none;
}

.tuh-promo[data-position="top"] {
    top: 20px;
    left: 0;
    right: 0;
    margin: 0 auto;
    bottom: auto;
    height: fit-content;
}

.tuh-promo[data-position="bottom"] {
    bottom: 20px;
    left: 0;
    right: 0;
    margin: 0 auto;
    top: auto;
    height: fit-content;
}

.tuh-promo[data-position="right"] {
    right: 20px;
    top: 0;
    bottom: 0;
    margin: auto 0;
    left: auto;
    height: fit-content;
}

.tuh-promo[data-position="left"] {
    left: 20px;
    top: 0;
    bottom: 0;
    margin: auto 0;
    right: auto;
    height: fit-content;
}


/* ==========================================================================
   5. BOTAO FECHAR — renderizado pelo sistema (close_btn = true)
   ========================================================================== */

.tuh-promo-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    transition: background 0.2s, transform 0.2s;
    color: #666;
    padding: 0;
}

.tuh-promo-close:hover {
    background: rgba(0, 0, 0, 0.12);
    transform: scale(1.1);
    color: #333;
}


/* ==========================================================================
   6. CONTEUDO DO USUARIO (.tuh-promo-body)
   Presente nos tipos com estilo base (popup, fullscreen, etc).
   Tipo Custom NAO usa .tuh-promo-body — HTML vai direto no container.
   ========================================================================== */

.tuh-promo-body {
    position: relative;
    z-index: 1;
}

.tuh-promo-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}


/* ==========================================================================
   7. BLOCO DE CUPOM — renderizado pelo sistema (coupon_enabled = true)
   Funciona em TODOS os tipos, incluindo Custom.
   ========================================================================== */

.tuh-promo-coupon {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px dashed #e0e0e0;
    border-radius: 10px;
    padding: 14px 18px;
    margin-top: 16px;
    background: #fafafa;
}

.tuh-promo-coupon-code {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 1.5px;
    color: #333;
    flex: 1;
}

.tuh-promo-coupon-btn {
    background: #333;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
}

.tuh-promo-coupon-btn:hover {
    background: #555;
    transform: scale(1.02);
}

.tuh-promo-coupon-btn.copied {
    background: #10b981;
    color: #fff;
}


/* ==========================================================================
   8. FORMULARIO DE LEAD — renderizado pelo sistema (lead_enabled = true)
   Funciona em TODOS os tipos, incluindo Custom.
   ========================================================================== */

.tuh-promo-lead-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.tuh-promo-lead-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    background: #fff;
}

.tuh-promo-lead-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.tuh-promo-lead-input.error {
    border-color: #ef4444;
}

.tuh-promo-lead-submit {
    width: 100%;
    padding: 14px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    font-family: inherit;
}

.tuh-promo-lead-submit:hover {
    background: #4338ca;
    transform: translateY(-1px);
}

.tuh-promo-lead-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Feedback apos submit */
.tuh-promo-lead-feedback {
    text-align: center;
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

/* Sucesso (lead salvo) */
.tuh-promo-lead-feedback.success {
    background: #ecfdf5;
    color: #059669;
}

/* Erro (validacao, rede) */
.tuh-promo-lead-feedback.error {
    background: #fef2f2;
    color: #dc2626;
}

/* Confirmacao pendente (double opt-in: "verifique seu email") */
.tuh-promo-lead-feedback.confirm {
    color: #0c5460;
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    padding: 10px 14px;
    border-radius: 6px;
}


/* ==========================================================================
   8b. FORMULARIO DE PESQUISA (survey)
   ========================================================================== */

.tuh-promo-survey {
    padding: 8px 0;
}

.tuh-promo-survey-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px;
    color: #333;
    text-align: center;
}

/* Rating Stars */
.tuh-promo-survey-rating {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.tuh-promo-survey-rating-label {
    display: block;
    font-size: 13px;
    color: #666;
    text-align: center;
    margin-bottom: 8px;
}

.tuh-promo-survey-star {
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: #ddd;
    transition: color 0.15s, transform 0.15s;
}

.tuh-promo-survey-star:hover,
.tuh-promo-survey-star.active {
    color: #f59e0b;
}

.tuh-promo-survey-star:hover {
    transform: scale(1.15);
}

/* Comment */
.tuh-promo-survey-comment {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 12px;
}

.tuh-promo-survey-comment:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Submit */
.tuh-promo-survey-submit {
    width: 100%;
    padding: 14px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    font-family: inherit;
}

.tuh-promo-survey-submit:hover {
    background: #4338ca;
    transform: translateY(-1px);
}

.tuh-promo-survey-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Feedback */
.tuh-promo-survey-feedback {
    text-align: center;
    padding: 16px;
    font-size: 15px;
    font-weight: 500;
    color: #059669;
}

/* Survey Inputs & Selects (template tags: nome, email, telefone, estados, cidades) */
.tuh-promo-survey-input,
.tuh-promo-survey-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 12px;
    background: #fff;
    color: #333;
}

.tuh-promo-survey-input:focus,
.tuh-promo-survey-select:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.tuh-promo-survey-select {
    appearance: none;
    -webkit-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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}

.tuh-promo-survey-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

/* Privacy checkbox (template tag: privacidade) */
.tuh-promo-survey-privacy {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 12px;
    cursor: pointer;
}

.tuh-promo-survey-privacy input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}


/* ==========================================================================
   9. ANIMACOES DE ENTRADA
   ========================================================================== */

@keyframes tuh-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tuh-slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tuh-slideIn {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes tuh-bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes tuh-zoomIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes tuh-slideFromRight {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

.tuh-animate-fadeIn { animation: tuh-fadeIn 0.4s ease-out both; }
.tuh-animate-slideUp { animation: tuh-slideUp 0.4s ease-out both; }
.tuh-animate-slideIn { animation: tuh-slideIn 0.4s ease-out both; }
.tuh-animate-bounceIn { animation: tuh-bounceIn 0.6s ease-out both; }
.tuh-animate-zoomIn { animation: tuh-zoomIn 0.4s ease-out both; }
.tuh-animate-slideFromRight { animation: tuh-slideFromRight 0.4s ease-out both; }


/* ==========================================================================
   10. DEVICE VISIBILITY + RESPONSIVE + ACESSIBILIDADE
   ========================================================================== */

/* Device visibility */
@media (max-width: 768px) {
    .tuh-promo-desktop-only {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .tuh-promo-mobile-only {
        display: none !important;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .tuh-promo-popup {
        width: 95% !important;
        max-width: none !important;
        max-height: 90vh;
        padding: 24px;
        border-radius: 12px;
    }

    .tuh-promo-survey iframe {
        max-height: 68vh;
    }

    .tuh-promo-sidebar-card {
        width: 90% !important;
        right: 5%;
        left: 5%;
        bottom: 10%;
    }

    .tuh-promo-floating-bar {
        padding: 12px 16px;
    }

    .tuh-promo-coupon {
        flex-direction: column;
        text-align: center;
    }

    .tuh-promo-coupon-btn {
        width: 100%;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tuh-promo,
    .tuh-promo-overlay {
        animation: none !important;
        transition: none !important;
    }
}
