/* ===================================
   VIPFLIX - CORREÇÃO UNIVERSAL
   Funciona em TODOS os dispositivos
   =================================== */

/* ===================================
   RESET UNIVERSAL
   =================================== */
*, *::before, *::after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* ===================================
   FIX DE PROPORÇÕES - TODOS DISPOSITIVOS
   =================================== */

/* Garantir que nada ultrapasse a tela */
img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* Containers não ultrapassam viewport */
.epic-header,
.apps-section,
.how-it-works-banner,
.carousel-section,
.footer,
section,
header,
footer,
main,
div {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ===================================
   FIX DE INPUTS - PREVINE ZOOM NO iOS
   =================================== */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="url"],
select,
textarea {
    font-size: 16px !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 12px;
    padding: 14px 16px;
    width: 100%;
    min-height: 48px;
    touch-action: manipulation;
}

/* ===================================
   FIX DE BOTÕES - TAMANHO MÍNIMO PARA TOUCH
   =================================== */
button,
.btn,
.btn-primary,
.btn-select,
.btn-submit,
.btn-copy,
[role="button"],
a.btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ===================================
   FIX DE MODAL - FUNCIONA EM TODOS
   =================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    overflow: hidden;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1;
}

.modal-content {
    position: relative;
    z-index: 2;
    width: calc(100% - 20px);
    max-width: 500px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    margin: 10px;
    padding: 24px 20px;
    background: #1A1A2E;
    border-radius: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

/* ===================================
   FIX DE CREDENCIAIS - QUEBRA TEXTO
   =================================== */
.result-credentials,
.credential-item,
.credential-value,
#result-details {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.credential-value code,
code {
    word-break: break-all;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    display: block;
    max-width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
}

/* ===================================
   FIX PARA TELAS PEQUENAS (< 375px)
   =================================== */
@media screen and (max-width: 374px) {
    html {
        font-size: 14px;
    }
    
    .modal-content {
        padding: 16px 12px;
        margin: 8px;
        width: calc(100% - 16px);
    }
    
    .epic-logo-image {
        max-width: 180px;
    }
    
    .section-title {
        font-size: 1.3rem;
    }
    
    .app-card-inner {
        padding: 12px;
    }
    
    .btn-select {
        padding: 12px;
        font-size: 14px;
    }
}

/* ===================================
   FIX PARA TELAS MÉDIAS (375px - 480px)
   =================================== */
@media screen and (min-width: 375px) and (max-width: 480px) {
    .modal-content {
        padding: 20px 16px;
        width: calc(100% - 24px);
    }
    
    .epic-logo-image {
        max-width: 220px;
    }
}

/* ===================================
   FIX PARA iPHONE X+ (SAFE AREA)
   =================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .modal-content {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
    
    .footer {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* ===================================
   FIX PARA LANDSCAPE MOBILE
   =================================== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .epic-header {
        padding: 10px 15px;
    }
    
    .epic-logo-image {
        max-width: 120px;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
        padding: 16px;
    }
    
    .apps-section {
        padding: 1rem;
    }
}

/* ===================================
   FIX PARA TABLETS (768px - 1024px)
   =================================== */
@media screen and (min-width: 768px) {
    .apps-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    
    .modal-content {
        max-width: 550px;
        padding: 32px;
    }
    
    .epic-logo-image {
        max-width: 350px;
    }
}

/* ===================================
   FIX PARA DESKTOP (> 1024px)
   =================================== */
@media screen and (min-width: 1024px) {
    .apps-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .modal-content {
        max-width: 600px;
    }
}

/* ===================================
   FIX PARA LOADING E ERROS
   =================================== */
.loading-message,
.error-message {
    text-align: center;
    padding: 40px 20px;
    width: 100%;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message h3 {
    color: #EF4444;
    margin-bottom: 12px;
}

.error-message p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 20px;
}

/* ===================================
   FIX PARA CARDS DE APP
   =================================== */
.app-card {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.app-card-inner {
    width: 100%;
}

.app-image {
    width: 100%;
    height: auto;
    min-height: 150px;
    max-height: 200px;
}

.app-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===================================
   FIX PARA PREVIEW NO MODAL
   =================================== */
.selected-app-preview {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.selected-app-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 12px;
    margin-bottom: 16px;
}

.selected-app-info img {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.selected-app-details {
    flex: 1;
    min-width: 0;
}

.selected-app-details h4 {
    font-size: 16px;
    margin-bottom: 6px;
    color: white;
}

.selected-devices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.selected-devices .device-badge {
    font-size: 11px;
    padding: 4px 8px;
}

/* ===================================
   FIX PARA RESULTADO
   =================================== */
.result-app-info {
    text-align: center;
    margin-bottom: 20px;
}

.result-app-image {
    width: 80px;
    height: 80px;
    margin: 0 auto 12px;
    border-radius: 16px;
    overflow: hidden;
}

.result-app-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-app-name {
    font-size: 20px;
    margin-bottom: 12px;
    color: white;
}

.result-devices {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.result-credentials {
    margin: 20px 0;
}

.credential-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

.credential-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #A0AEC0;
    margin-bottom: 8px;
    font-weight: 600;
}

.credential-label i {
    color: #8B5CF6;
}

.credential-value {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.credential-value code {
    flex: 1;
    margin: 0;
}

.btn-copy {
    flex-shrink: 0;
    width: 44px;
    height: auto;
    min-height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    color: #8B5CF6;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:active {
    transform: scale(0.95);
    background: rgba(139, 92, 246, 0.4);
}

/* ===================================
   FIX PARA VALIDADE E ALERTA
   =================================== */
.result-validity {
    text-align: center;
    padding: 12px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    margin: 16px 0;
}

.validity-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #10B981;
}

.result-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    margin: 16px 0;
}

.result-alert i {
    color: #F59E0B;
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.result-alert p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

/* ===================================
   FIX PARA BOTÕES DE AÇÃO
   =================================== */
.btn-copy-all,
.result-actions {
    margin: 16px 0;
}

.btn-copy-all {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
}

.result-actions {
    display: flex;
    gap: 12px;
}

.result-actions .btn-whatsapp,
.result-actions .btn-share {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.btn-whatsapp {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
}

.btn-share {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

/* ===================================
   FIX PARA PAGAMENTO
   =================================== */
.result-payment {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    margin: 20px 0;
}

.payment-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 18px;
    color: #F59E0B;
    margin-bottom: 8px;
}

.payment-description {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin-bottom: 16px;
}

.btn-payment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #F59E0B 0%, #EF4444 100%);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

/* ===================================
   FIX PARA DOWNLOAD
   =================================== */
.download-app-section {
    text-align: center;
    margin: 16px 0;
}

.btn-download-app {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-download-app:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.15);
}

/* ===================================
   FIX PARA CREDENCIAIS OPCIONAIS
   =================================== */
.optional-credentials-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 8px;
    margin: 16px 0 12px;
    font-size: 13px;
    color: #A78BFA;
}

.credential-item.optional {
    opacity: 0.8;
    border-style: dashed;
}

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

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

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

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

/* ===================================
   REMOVE ANIMAÇÕES SE PREFERIR
   =================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
