/* ========================================
   TeleVIP Auth - Mobile First Design
   ======================================== */

/* Reset e Base */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Variáveis CSS para fácil customização */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --text-dark: #333;
    --text-muted: #6c757d;
    --border-color: #e0e0e0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    /* Altura segura para iOS */
    --safe-area-inset-top: env(safe-area-inset-top);
    --safe-area-inset-bottom: env(safe-area-inset-bottom);
}

/* Garantir que o body e html tenham altura total */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Container Principal - Mobile First */
.auth-container {
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS fix */
    min-height: 100%; /* Fallback */
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    background-attachment: fixed; /* Fixa o background */
    background-size: cover;
    background-position: center;
    padding: 16px;
    padding-top: calc(16px + var(--safe-area-inset-top));
    padding-bottom: calc(16px + var(--safe-area-inset-bottom));
    position: relative;
    overflow: hidden;
}

/* Card Principal - Mobile First */
.auth-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    padding: 24px 20px;
    position: relative;
    z-index: 10;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scroll iOS */
}

/* Header */
.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 50%;
    color: white;
    font-size: 28px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 24px;
    margin-bottom: 8px;
    line-height: 1.2;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}

/* Step Indicator - Mobile Optimized */
.step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.step.active {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.step.completed {
    background: var(--success-color);
    color: white;
}

.step:not(.active):not(.completed) {
    background: #f0f0f0;
    color: #999;
}

.step-connector {
    flex: 1;
    height: 2px;
    background: #e0e0e0;
    max-width: 40px;
}

.step-connector.completed {
    background: var(--success-color);
}

/* Form Styles - Mobile Optimized */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Input com ícone */
.input-group {
    position: relative;
    margin-bottom: 0;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #718096;
    font-size: 18px;
    pointer-events: none;
    z-index: 1;
}

.form-control {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    background: #fafafa;
    -webkit-appearance: none;
}

.form-control.with-icon {
    padding-left: 48px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

.form-control:focus ~ .input-icon {
    color: var(--primary-color);
}

/* Placeholder styling */
.form-control::placeholder {
    color: #a0aec0;
    opacity: 1;
}

.form-control:focus::placeholder {
    opacity: 0.7;
}

/* Remove labels flutuantes */
.form-floating {
    display: none;
}

/* Password Toggle - Touch Friendly */
.password-field {
    position: relative;
}

.password-field .password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #718096;
    cursor: pointer;
    padding: 8px;
    font-size: 18px;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
}

.password-field .password-toggle:hover {
    color: var(--primary-color);
}

.password-field .form-control {
    padding-right: 48px;
}

/* Form text helper */
.form-text {
    font-size: 13px;
    color: #718096;
    margin-top: 4px;
    margin-left: 48px;
    display: block;
}

/* Botões - Mobile Optimized */
.btn {
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    margin-top: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: white;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f8f9fa;
}

.btn-secondary:active {
    background: #e9ecef;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    padding: 0 16px;
}

/* Checkbox - Touch Friendly */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 12px 0;
}

.form-check-input {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.form-check-input:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-label {
    font-size: 14px;
    color: var(--text-dark);
    cursor: pointer;
    user-select: none;
    line-height: 1.4;
}

/* Links */
.auth-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-link:active {
    opacity: 0.8;
}

/* Footer */
.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-muted);
}

/* Alerts - Mobile Friendly */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error,
.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert .btn-close {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    margin-left: auto;
    padding: 0;
}

.alert .btn-close:hover {
    opacity: 1;
}

/* Loading State */
.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.8s linear infinite;
}

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

/* Strength Indicator */
.password-strength {
    margin-top: -8px;
    margin-bottom: 8px;
}

.strength-bar {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.strength-progress {
    height: 100%;
    width: 0;
    background: var(--danger-color);
    transition: all 0.3s ease;
}

.strength-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* Botão Voltar */
.btn-back {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    transition: all 0.3s ease;
    z-index: 100;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateX(-5px);
}

.btn-back i {
    font-size: 18px;
}

/* Mobile adjustments for back button */
@media (max-width: 768px) {
    .btn-back {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .btn-back span {
        display: none; /* Mostra só o ícone no mobile */
    }
}

/* Decorações de fundo */
.auth-decoration {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.1;
}

.shape-1 {
    width: 200px;
    height: 200px;
    background: white;
    top: -100px;
    right: -100px;
}

.shape-2 {
    width: 150px;
    height: 150px;
    background: white;
    bottom: -75px;
    left: -75px;
}

.shape-3 {
    width: 100px;
    height: 100px;
    background: white;
    top: 50%;
    left: 10%;
}

/* Scrollbar customizada */
.auth-card::-webkit-scrollbar {
    width: 4px;
}

.auth-card::-webkit-scrollbar-track {
    background: transparent;
}

.auth-card::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Erro de validação */
.form-control.is-invalid {
    border-color: var(--danger-color);
}

.form-control.is-valid {
    border-color: var(--success-color);
}

.invalid-feedback {
    color: var(--danger-color);
    font-size: 12px;
    margin-top: 4px;
    margin-left: 48px;
}

.valid-feedback {
    color: var(--success-color);
    font-size: 12px;
    margin-top: 4px;
    margin-left: 48px;
}

/* Utilitários */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-dark { color: var(--text-dark); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.fw-bold { font-weight: 700; }
.small { font-size: 14px; }
.w-100 { width: 100%; }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.gap-8 { gap: 8px; }

/* ========================================
   Tablet (768px+)
   ======================================== */
@media (min-width: 768px) {
    .auth-container {
        padding: 24px;
    }
    
    .auth-card {
        padding: 40px;
        max-width: 440px;
    }
    
    .gradient-text {
        font-size: 28px;
    }
    
    .step {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .form-control {
        padding: 18px;
    }
    
    .form-control.with-icon {
        padding-left: 52px;
    }
    
    .btn {
        padding: 18px 32px;
        font-size: 17px;
    }
}

/* ========================================
   Desktop (1024px+)
   ======================================== */
@media (min-width: 1024px) {
    .auth-card {
        padding: 48px;
        max-width: 480px;
    }
    
    .gradient-text {
        font-size: 32px;
    }
    
    .shape-1 {
        width: 300px;
        height: 300px;
        top: -150px;
        right: -150px;
    }
    
    .shape-2 {
        width: 200px;
        height: 200px;
        bottom: -100px;
        left: -100px;
    }
    
    .shape-3 {
        width: 150px;
        height: 150px;
        top: 50%;
        left: 10%;
    }
}

/* ========================================
   Acessibilidade e Performance
   ======================================== */

/* Remove animações se preferir movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible para acessibilidade */
.form-control:focus-visible,
.btn:focus-visible,
.auth-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}