/* Authentication Pages Styles - Only auth-specific classes remain */
.auth-page {
    background: var(--primary);
    min-height: 100vh;
    display: flex;
    align-items: center; /* Desktop: Always centered */
    justify-content: center;
    padding: 20px 0; /* Vertical buffer for short screens */
    position: relative;
    box-sizing: border-box;
}

/* Keyboard Avoidance: Push to top ONLY on mobile */
@media screen and (max-width: 767px) {
    .auth-page {
        align-items: flex-start !important;
        padding-top: 2vh !important;
    }
}

.auth-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(214,158,46,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
    pointer-events: none;
}

.auth-container {
    width: 100%;
    max-width: 450px;
    position: relative;
    z-index: 1;
}

.auth-card {
    background: var(--text-light);
    border-radius: 16px;
    box-shadow: 0 20px 40px var(--shadow-medium);
    padding: 40px;
    margin: 0 auto;
    border: 3px solid var(--accent);
    position: relative;
    max-height: 90vh; /* Prevents card from exceeding viewport */
    overflow-y: auto; /* Guarantees scrollability if content exceeds max-height */
    display: flex;
    flex-direction: column;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--primary);
    font-weight: 700;
}

.auth-header p {
    color: var(--text-secondary);
    margin: 0;
    font-weight: 500;
}

.auth-form {
    margin-bottom: 30px;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    background: var(--secondary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--shadow-light);
    background: var(--text-light);
}

/* Password Input Container */
.password-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-container input {
    padding-right: 50px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.password-toggle:hover {
    background: var(--border-color);
}

.password-toggle:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Form Error Styles */
.form-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 4px;
    font-weight: 500;
    min-height: 20px;
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-group.has-error label {
    color: #dc3545;
}

/* Loading States */
.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
}

.auth-footer p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.auth-footer a {
    color: var(--accent);
    text-decoration: underline;
    font-weight: 500;
}

.auth-footer a:hover {
    color: var(--primary);
}

.auth-footer a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.form-group.has-success input,
.form-group.has-success select,
.form-group.has-success textarea {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.form-help {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.password-strength {
    margin-top: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.password-strength.weak {
    color: #dc3545;
}

.password-strength.fair {
    color: #ffc107;
}

.password-strength.good {
    color: #17a2b8;
}

.password-strength.strong {
    color: #28a745;
}

.password-match {
    margin-top: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.password-match.match {
    color: #28a745;
}

.password-match.no-match {
    color: #dc3545;
}

@media (max-width: 480px) {
    .auth-card {
        padding: 24px 20px !important;
        max-height: 85vh; /* Tighter safety for mobile */
        overflow-y: auto !important; /* Enable internal scroll */
    }
    .form-row {
        flex-direction: column;
        gap: 8px;
    }
    .form-row .form-group {
        margin-bottom: 10px;
    }
    .auth-header {
        margin-bottom: 15px !important;
    }
    .auth-header h1 {
        font-size: 1.5rem;
        margin-bottom: 4px;
    }
    .auth-header p {
        font-size: 0.9rem;
    }
    .password-toggle {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
    }
    /* SSO & Divider Tightening */
    .g_id_signin, #googleSignInBtn {
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    div[style*="font-size: 1.2rem"] {
        margin: 0.5rem 0 !important;
        font-size: 1rem !important;
    }
}

/* Mobile form input optimization - prevent iOS zoom */
@media screen and (max-width: 768px) {
    .form-group input,
    .form-group select,
    .form-group textarea,
    input[type="text"], 
    input[type="password"], 
    input[type="email"] {
        font-size: 16px !important; /* STRICTLY 16px to prevent iOS auto-zoom */
        padding: 12px 14px !important;
        min-height: 44px !important;
    }
}