/* Estilos do Popup de Login */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.login-popup {
    background: #fff;
    padding: 40px;
    border-radius: 14px;
    border: 1px solid var(--card-border, #dde4f5);
    box-shadow: 0 8px 24px rgba(28, 43, 77, 0.05);
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    width: 80px;
    height: auto;
    margin-bottom: 15px;
}

.login-header h2 {
    color: #1f2a44;
    margin-bottom: 8px;
    font-size: 24px;
}

.login-header p {
    color: #536188;
    font-size: 14px;
    margin: 0;
}

.login-form-group {
    margin-bottom: 20px;
}

.login-form-group label {
    display: block;
    margin-bottom: 8px;
    color: #536188;
    font-weight: 500;
    font-size: 14px;
}

.login-form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--card-border, #dde4f5);
    border-radius: var(--radius-control, 10px);
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.login-form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--card-border, #dde4f5);
    border-radius: var(--radius-control, 10px);
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    background: #fff;
    color: #1f2a44;
}

.login-form-group input:focus {
    outline: none;
    border-color: #007c6f;
}

.login-form-group select:focus {
    outline: none;
    border-color: #007c6f;
}

.register-progress {
    margin-bottom: 18px;
}

.register-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: #536188;
}

.register-progress-track {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: #e8edf8;
    overflow: hidden;
}

.register-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #007c6f 0%, #00afa0 100%);
    transition: width 0.25s ease;
}

.register-step-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.register-step-actions .register-prev-btn {
    text-decoration: none;
    margin: 0;
    padding: 10px 4px;
}

.register-step-actions .register-next-btn,
.register-step-actions .register-submit-btn {
    margin-bottom: 0;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #007c6f 0%, #00afa0 100%);
    color: white;
    border: none;
    border-radius: var(--radius-control, 10px);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
    margin-bottom: 20px;
}

.login-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-error {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    display: none;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(231, 76, 60, 0.25);
}

.login-success {
    background: #efe;
    color: #363;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    display: none;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(0, 175, 160, 0.25);
}

@keyframes slideInMessage {
    from { 
        opacity: 0;
        transform: translateY(-10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.login-loading {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    margin: 20px 0;
    color: #007c6f;
}

.login-spinner {
    width: 20px;
    height: 20px;
    background-image: url('../assets/142.6-cmh-icone.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

.login-actions {
    text-align: center;
    border-top: 1px solid var(--card-border, #dde4f5);
    padding-top: 20px;
    margin-top: 20px;
}

.login-toggle-btn {
    background: none;
    border: none;
    color: #007c6f;
    cursor: pointer;
    text-decoration: underline;
    font-size: 14px;
    margin: 5px 10px;
    padding: 5px;
}

.login-toggle-btn:hover {
    opacity: 0.8;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Estilos para containers de acesso restrito */
.not-auth-container {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border: 1px solid var(--card-border, #dde4f5);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(28, 43, 77, 0.05);
    margin: 20px 0;
}

.not-auth-message h3 {
    color: #1f2a44;
    margin-bottom: 15px;
    font-size: 24px;
}

.not-auth-message p {
    color: #536188;
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.5;
}

.not-auth-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary {
    background: linear-gradient(135deg, #007c6f 0%, #00afa0 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    background: white;
    color: #007c6f;
    border: 2px solid #007c6f;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #007c6f;
    color: white;
}

/* Responsividade */
@media (max-width: 480px) {
    .login-popup {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .login-header h2 {
        font-size: 20px;
    }
    
    .login-form-group input {
        font-size: 16px; /* Evita zoom no iOS */
    }
    
    .not-auth-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        max-width: 200px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   TEMA DARK — Login / Registro / Not-Auth
   ═══════════════════════════════════════════════════════════════ */

body.theme-dark .login-overlay {
    background: rgba(7, 10, 24, 0.85) !important;
}

body.theme-dark .login-popup {
    background: rgba(26, 22, 54, 0.97) !important;
    border: 1px solid rgba(193, 203, 255, 0.28) !important;
    box-shadow: 0 20px 60px rgba(3, 6, 16, 0.6) !important;
}

body.theme-dark .login-header h2 {
    color: #f0f3ff !important;
}

body.theme-dark .login-header p {
    color: #dce8ff !important;
}

body.theme-dark .login-form-group label {
    color: #dce8ff !important;
}

body.theme-dark .login-form-group input {
    background: rgba(255, 255, 255, 0.04) !important;
    color: #f0f3ff !important;
    border-color: rgba(182, 196, 255, 0.34) !important;
}

body.theme-dark .login-form-group input:focus {
    border-color: #7d5fff !important;
    box-shadow: 0 0 0 3px rgba(125, 95, 255, 0.22) !important;
}

body.theme-dark .login-form-group input::placeholder {
    color: rgba(220, 232, 255, 0.4) !important;
}

body.theme-dark .login-btn {
    background: linear-gradient(135deg, #7d5fff, #49b8ff) !important;
    color: #ffffff !important;
}

body.theme-dark .login-btn:disabled {
    opacity: 0.5;
}

body.theme-dark .login-error {
    background: rgba(255, 102, 151, 0.12) !important;
    color: #ff9ec0 !important;
    border-left-color: #ff6697 !important;
}

body.theme-dark .login-success {
    background: rgba(0, 175, 160, 0.12) !important;
    color: #6ee7b7 !important;
    border-left-color: #00afa0 !important;
}

body.theme-dark .login-loading {
    color: #dce8ff !important;
}

body.theme-dark .login-actions {
    border-top-color: rgba(193, 203, 255, 0.18) !important;
}

body.theme-dark .login-toggle-btn {
    color: #49b8ff !important;
}

body.theme-dark .login-toggle-btn:hover {
    color: #7d5fff !important;
}

body.theme-dark .not-auth-container {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(193, 203, 255, 0.18) !important;
}

body.theme-dark .not-auth-message h3 {
    color: #f0f3ff !important;
}

body.theme-dark .not-auth-message p {
    color: #dce8ff !important;
}

body.theme-dark .btn-secondary {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #e6eeff !important;
    border-color: rgba(198, 207, 255, 0.32) !important;
}

body.theme-dark .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

body.theme-dark #cpfSearchStatus {
    border-color: rgba(193, 203, 255, 0.18) !important;
}

body.theme-dark .login-form-group select {
    background: rgba(255, 255, 255, 0.04) !important;
    color: #f0f3ff !important;
    border-color: rgba(182, 196, 255, 0.34) !important;
}

body.theme-dark .login-form-group select option {
    background: #1a1636;
    color: #f0f3ff;
}

body.theme-dark .register-progress-header {
    color: #dce8ff !important;
}

body.theme-dark .register-progress-track {
    background: rgba(193, 203, 255, 0.18) !important;
}

/* Validação ERP — PIN de 4 dígitos */
.erp-info-box {
    background: #e8f5f3;
    color: #1f4d47;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
}

.erp-info-muted {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #536188;
}

.erp-pin-group {
    margin-bottom: 16px;
}

.erp-phone-display {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    padding: 14px 12px;
    border: 1px solid var(--card-border, #dde4f5);
    border-radius: 12px;
    background: #f9fbff;
    box-sizing: border-box;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.erp-phone-prefix {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2a44;
    letter-spacing: 0.05em;
    white-space: nowrap;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.erp-phone-pin-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

/* Sobrescreve input { width:100%; height:50px } do styles.css global */
.erp-phone-pin-row input.pin-digit {
    width: 38px;
    min-width: 38px;
    max-width: 38px;
    height: 42px;
    padding: 0;
    margin: 0;
    flex: 0 0 38px;
    display: block;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    border: 1.5px solid #b8c4dc;
    border-radius: 8px;
    color: #1f2a44;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.erp-phone-display.pin-input-row--shake {
    animation: pinShake 0.45s ease;
}

.erp-phone-pin-row input.pin-digit:focus {
    outline: none;
    border-color: #007c6f;
    box-shadow: 0 0 0 3px rgba(0, 124, 111, 0.12);
}

.erp-phone-pin-row input.pin-digit:disabled {
    opacity: 0.55;
    background: #eef2f8;
}

@keyframes pinShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.erp-attempts-hint {
    text-align: center;
    font-size: 13px;
    color: #b45309;
    margin: 0 0 12px;
}

.erp-support-hint {
    text-align: center;
    font-size: 13px;
    margin: 12px 0 0;
}

.erp-support-hint a {
    color: #007c6f;
    text-decoration: underline;
}

.otp-info-box {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.55;
    text-align: center;
}

.otp-phone-hint {
    text-align: center;
    font-size: 13px;
    color: #536188;
    margin: 0 0 16px;
}

.otp-code-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    font-weight: 700;
}

@media (max-width: 420px) {
    .erp-phone-display {
        padding: 12px 8px;
        gap: 4px;
    }

    .erp-phone-prefix {
        font-size: 1.05rem;
    }

    .erp-phone-pin-row input.pin-digit {
        width: 34px;
        min-width: 34px;
        max-width: 34px;
        height: 38px;
        flex-basis: 34px;
        font-size: 1.05rem;
    }
}
