/**
 * DriveWeb Smart Popup - Frontend Styles
 * @version 7.4.0
 */

/* ============================================
   POPUP CONTAINER E OVERLAY
   ============================================ */
#dwsp-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    animation: dwspFadeIn 0.3s ease-in-out;
}

#dwsp-popup.dwsp-visible {
    display: flex;
}

.dwsp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1;
    animation: dwspFadeIn 0.3s ease-in-out;
}

/* ============================================
   POPUP CONTENT
   ============================================ */
.dwsp-content {
    position: relative;
    z-index: 2;
    max-width: 520px;
    width: 95%;
    margin: 1rem;
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    animation: dwspSlideUp 0.4s ease-out;
    max-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
}

.dwsp-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
}

/* ============================================
   POPUP HEADER
   ============================================ */
.dwsp-header {
    background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
    color: #ffffff;
    padding: 2rem;
    text-align: center;
    position: relative;
}

.dwsp-header-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin: 0 0 0.5rem 0;
    text-transform: uppercase;
}

.dwsp-header-subtitle {
    font-size: 0.875rem;
    opacity: 0.95;
    margin: 0;
}

/* Botão Fechar */
.dwsp-close {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
}

@media (hover: hover) {
    .dwsp-close:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: rotate(90deg);
    }
}

/* ============================================
   POPUP BODY
   ============================================ */
.dwsp-body {
    padding: 2rem;
}

.dwsp-description {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 1.5rem 0;
    line-height: 1.6;
}

.dwsp-highlight {
    background: #f1f5f9;
    border-left: 4px solid #0d6efd;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    color: #475569;
    margin: 0 0 1.5rem 0;
    line-height: 1.6;
}

.dwsp-prompt {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #334155;
    margin: 0 0 1rem 0;
}

/* ============================================
   FORMULÁRIO
   ============================================ */
.dwsp-form {
    margin: 0 0 1.5rem 0;
}

.dwsp-input-group {
    margin-bottom: 1rem;
}

.dwsp-input {
    width: 100%;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 50px;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

.dwsp-input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.dwsp-input::placeholder {
    color: #94a3b8;
}

.dwsp-submit {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(90deg, #6610f2 0%, #0d6efd 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 15px -3px rgba(13, 110, 253, 0.3);
}

.dwsp-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(13, 110, 253, 0.4);
}

@media (hover: none) {
    .dwsp-submit:hover:not(:disabled) {
        transform: none;
        box-shadow: 0 10px 15px -3px rgba(13, 110, 253, 0.3);
    }
}

.dwsp-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   LISTA DE BENEFÍCIOS
   ============================================ */
.dwsp-benefits {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dwsp-benefit {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.6;
}

.dwsp-benefit:last-child {
    margin-bottom: 0;
}

.dwsp-benefit-icon {
    color: #0d6efd;
    font-size: 1.1rem;
    font-weight: bold;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ============================================
   POPUP FOOTER
   ============================================ */
.dwsp-footer {
    background: #f8fafc;
    padding: 1.5rem 2rem;
    border-top: 1px solid #e2e8f0;
}

.dwsp-checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.dwsp-checkbox {
    margin-top: 2px;
    cursor: pointer;
}

.dwsp-checkbox-label {
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.5;
    cursor: pointer;
}

.dwsp-credits {
    text-align: center;
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0;
}

.dwsp-credits a {
    color: #0d6efd;
    text-decoration: none;
    transition: color 0.2s ease;
}

.dwsp-credits a:hover {
    color: #6610f2;
    text-decoration: underline;
}

/* ============================================
   MENSAGENS DE FEEDBACK
   ============================================ */
.dwsp-message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.875rem;
    animation: dwspSlideDown 0.3s ease-out;
}

.dwsp-message-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #dc2626;
}

.dwsp-message-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

/* ============================================
   ANIMAÇÕES
   ============================================ */
@keyframes dwspFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    .dwsp-content {
        max-width: 480px;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .dwsp-content {
        max-width: 100%;
        width: calc(100% - 2rem);
        margin: 1rem;
        border-radius: 16px;
    }
    
    .dwsp-header {
        padding: 1.25rem 1rem;
        padding-right: 3.5rem; /* espaço para botão fechar */
    }
    
    .dwsp-header-title {
        font-size: 0.875rem;
    }
    
    .dwsp-header-subtitle {
        font-size: 0.8125rem;
    }
    
    .dwsp-body {
        padding: 1.25rem 1rem;
    }
    
    .dwsp-description {
        font-size: 1rem;
    }
    
    .dwsp-footer {
        padding: 1rem;
    }
    
    .dwsp-submit {
        padding: 0.875rem 1.5rem;
        font-size: 0.9375rem;
    }
}

/* Landscape mobile / ecrãs muito baixos */
@media (max-height: 600px) {
    .dwsp-content {
        max-height: calc(100dvh - 1rem);
        margin: 0.5rem auto;
    }

    .dwsp-header {
        padding: 0.875rem 1rem;
        padding-right: 3.5rem;
    }

    .dwsp-body {
        padding: 1rem;
    }

    .dwsp-footer {
        padding: 0.75rem 1rem;
    }
}

/* Safe area para iPhones com notch / Dynamic Island */
@supports (padding: max(0px)) {
    .dwsp-content {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    @media (max-width: 576px) {
        #dwsp-popup {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* ============================================
   ACESSIBILIDADE
   ============================================ */
.dwsp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visível para acessibilidade */
.dwsp-input:focus-visible,
.dwsp-submit:focus-visible,
.dwsp-close:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}
