/* ==========================================================================
   CS SERVIÇOS PWA — Login Page Styles
   Premium dark glassmorphism login with animations
   ========================================================================== */

/* ---------- Login Page Layout ---------- */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('../../bg-login.jpg') no-repeat center center fixed;
    background-size: cover;
}

.login-page .bg-animation {
    display: none;
}

.login-container {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    animation: fadeInUp 0.6s ease-out;
}

/* ---------- Login Card ---------- */
.login-card {
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem 2rem;
    position: relative;
    overflow: hidden;
}

/* ---------- Logo ---------- */
.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo img {
    width: 320px;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    animation: fadeIn 0.8s ease-out;
}

.login-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--cs-gold);
    margin-bottom: 0.25rem;
}

.login-logo p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ---------- Alert ---------- */
.login-alert {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    animation: fadeInShake 0.4s ease-out;
}

.login-alert.error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.login-alert span.material-symbols-rounded {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--error-red);
}

/* ---------- Login Form ---------- */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 400;
}

/* Input wrapper with icon */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 0.9rem 1rem 0.9rem 3rem;
    font-size: 1rem;
    font-family: var(--font);
    background: var(--navy-mid);
    border: 2px solid var(--navy-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.input-wrapper input:hover {
    border-color: var(--cs-blue-light);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--cs-cyan);
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.12);
}

.input-wrapper input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Input icon */
.input-icon {
    position: absolute;
    left: 1rem;
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: color 0.3s ease;
}

.input-wrapper input:focus~.input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--cs-cyan);
}

/* Password toggle button */
.password-toggle {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.password-toggle:hover {
    color: var(--cs-cyan);
}

/* ---------- Login Button ---------- */
.login-form .btn-primary {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.05rem;
    font-family: var(--font);
    font-weight: 600;
    background: linear-gradient(135deg, var(--cs-gold), var(--cs-yellow-dark));
    border: none;
    border-radius: var(--radius-md);
    color: var(--deep-navy-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.login-form .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(247, 224, 0, 0.3);
}

.login-form .btn-primary:active {
    transform: translateY(0);
}

.login-form .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-form .btn-primary svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.login-form .btn-primary:hover svg {
    transform: translateX(3px);
}

/* Spinner */
.spinner {
    display: none;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(13, 31, 51, 0.2);
    border-top-color: var(--deep-navy);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-primary.loading .spinner {
    display: block;
}

.btn-primary.loading .btn-text,
.btn-primary.loading svg {
    display: none;
}

/* ========================================
   SISTEMA DE VALIDAÇÃO VISUAL (matches gerar_orcamento)
   ======================================== */

/* Error state */
.login-form .form-group.has-error .input-wrapper input {
    border-color: var(--error-red) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.login-form .form-group.has-error .input-icon {
    color: var(--error-red);
}

/* Success state */
.login-form .form-group.has-success .input-wrapper input {
    border-color: var(--success-green) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.login-form .form-group.has-success .input-icon {
    color: var(--success-green);
}

/* Shake animation for inputs */
.login-form .shake {
    animation: shake 0.5s ease-in-out;
}

/* Validation icons (✓ and ✕) */
.login-form .validation-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

.login-form .validation-icon.success {
    color: var(--success-green);
}

.login-form .validation-icon.error {
    color: var(--error-red);
}

.login-form .validation-icon svg {
    width: 100%;
    height: 100%;
}

.login-form .form-group.has-success .validation-icon.success {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

.login-form .form-group.has-error .validation-icon.error {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* Adjust input padding to make room for validation icon */
.login-form .form-group.has-success .input-wrapper input,
.login-form .form-group.has-error .input-wrapper input {
    padding-right: 45px;
}

/* Password toggle repositioning when validation icon shows */
.login-form .form-group.has-success .password-toggle,
.login-form .form-group.has-error .password-toggle {
    right: 2.5rem;
}

/* Error message below input */
.login-form .error-message {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--error-red);
    animation: fadeInUp 0.3s ease-out;
}

.login-form .error-message svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--error-red);
}

/* Validation toast (floating bottom bar) */
.validation-toast {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1e3d5a, #152d45);
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 16px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90%;
}

.validation-toast.show {
    bottom: 30px;
}

.validation-toast svg {
    width: 24px;
    height: 24px;
    color: var(--error-red);
    flex-shrink: 0;
}

.validation-toast span {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
}

/* ---------- Login Footer ---------- */
.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--navy-light);
}

.login-footer a {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.3s ease;
}

.login-footer a:hover {
    color: var(--cs-gold);
}

/* ---------- Visitor Notice ---------- */
.visitor-notice {
    margin-top: 2rem;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--glass-border);
    border-radius: var(--radius-md);
    text-align: center;
}

.visitor-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--cs-gold);
    margin-bottom: 0.5rem;
}

.visitor-header span {
    font-size: 20px;
}

.visitor-header strong {
    font-size: 1rem;
}

.visitor-notice p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.visitor-credentials {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.credential-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.credential-item span {
    color: var(--text-secondary);
    min-width: 55px;
}

.credential-item code {
    background: rgba(212, 175, 55, 0.1);
    color: var(--cs-gold);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ---------- Version ---------- */
.login-version {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.5;
    text-align: center;
    margin-top: 1rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .login-page {
        padding: 1rem;
    }

    .login-card {
        padding: 2rem 1.5rem 1.5rem;
        border-radius: var(--radius-lg);
    }

    .login-logo img {
        width: 200px;
        height: auto;
    }

    .login-logo h1 {
        font-size: 1.2rem;
    }

    .input-wrapper input {
        padding: 0.85rem 1rem 0.85rem 2.75rem;
    }

    .login-form .btn-primary {
        padding: 0.9rem;
        font-size: 1rem;
    }
}

@media (max-width: 350px) {
    .login-card {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .login-logo img {
        width: 160px;
        height: auto;
    }

    .login-logo h1 {
        font-size: 1.1rem;
    }
}