/* ========================================
   AUTHENTICATION STYLES - Complete CSS
   ======================================== */

/* CSS Variables */
:root {
    --color-bg: light-dark(#f8fafc, #0f1419);
    --color-card-bg: light-dark(#ffffff, #1a1d23);
    --color-text: light-dark(#1e293b, #e2e8f0);
    --color-text-secondary: light-dark(#64748b, #94a3b8);
    --color-primary: light-dark(#0052cc, #3b82f6);
    --color-primary-hover: light-dark(#003d99, #2563eb);
    --color-secondary: light-dark(#ff6b00, #f97316);
    --color-secondary-hover: light-dark(#e55a00, #ea580c);
    --color-accent: light-dark(#06b6d4, #0891b2);
    --color-success: light-dark(#16a34a, #22c55e);
    --color-error: light-dark(#dc2626, #ef4444);
    --color-warning: light-dark(#f59e0b, #fbbf24);
    --color-border: light-dark(#e2e8f0, #374151);
    --color-shadow: light-dark(0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 10px 15px -3px rgba(0, 0, 0, 0.3));
    --color-shadow-lg: light-dark(0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 25px 50px -12px rgba(0, 0, 0, 0.4));
    --color-gradient-primary: linear-gradient(135deg, #0052cc 0%, #003d99 100%);
    --color-gradient-secondary: linear-gradient(135deg, #ff6b00 0%, #e55a00 100%);
    --border-radius: 16px;
    --border-radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark:root {
    --color-gradient-primary: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    --color-gradient-secondary: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

/* ========================================
   AUTH WRAPPER & CONTAINER
   ======================================== */

.auth-wrapper {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.auth-container {
    background: var(--color-card-bg);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2.5rem;
    box-shadow: var(--color-shadow-lg);
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.6s ease-out;
    transition: var(--transition);
}

.auth-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--color-gradient-primary);
}

.auth-container h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

/* ========================================
   HEADER
   ======================================== */

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .auth-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem auto;
    font-size: 1.75rem;
    color: white;
    background: var(--color-gradient-primary);
    box-shadow: var(--color-shadow);
    transition: var(--transition);
}

.auth-header .auth-icon:hover {
    transform: scale(1.05) rotate(5deg);
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--color-text-secondary);
    font-size: 1rem;
    line-height: 1.5;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.form-label i {
    font-size: 0.9rem;
    color: var(--color-primary);
}

.form-input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    padding: 1rem 3rem 1rem 3rem;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--color-card-bg);
    color: var(--color-text);
    font-family: inherit;
}

.form-input::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.6;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.form-input:hover:not(:focus) {
    border-color: var(--color-primary);
    opacity: 0.8;
}

.form-input.error {
    border-color: var(--color-error);
    animation: shake 0.5s;
}

.form-input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    pointer-events: none;
    transition: var(--transition);
}

.form-input:focus + .form-input-icon,
.form-input-wrapper:focus-within .form-input-icon {
    color: var(--color-primary);
}

/* Password Toggle */
.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.password-toggle:hover {
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
}

.password-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

/* Form Hint */
.form-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
}

.form-hint i {
    font-size: 0.9rem;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    width: 100%;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: var(--transition);
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--color-gradient-primary);
    color: white;
    box-shadow: var(--color-shadow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--color-shadow-lg);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    transform: translateY(-1px);
}

/* Loading State */
.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

/* ========================================
   LINKS & NAVIGATION
   ======================================== */

.auth-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.auth-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.95rem;
    position: relative;
}

.auth-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-primary);
    transition: width 0.3s ease;
}

.auth-link:hover {
    color: var(--color-secondary);
}

.auth-link:hover::after {
    width: 100%;
    background: var(--color-secondary);
}

/* Remember Me */
.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.remember-me span {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

/* ========================================
   DIVIDER
   ======================================== */

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2rem 0;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

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

.auth-divider span {
    padding: 0 1rem;
    font-weight: 500;
}

/* ========================================
   REGISTER PROMPT
   ======================================== */

.register-prompt {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

.register-prompt p {
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

/* ========================================
   ALERTS & MESSAGES
   ======================================== */

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideInDown 0.4s ease-out;
    font-size: 0.95rem;
}

.alert i {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-error {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: var(--color-error);
}

.alert-success {
    background: rgba(22, 163, 74, 0.1);
    border: 1px solid rgba(22, 163, 74, 0.3);
    color: var(--color-success);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--color-accent);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--color-warning);
}

/* ========================================
   PASSWORD STRENGTH METER
   ======================================== */

.strength-meter {
    height: 6px;
    width: 100%;
    background: var(--color-border);
    margin-top: 8px;
    border-radius: 3px;
    overflow: hidden;
}

.strength-meter-fill {
    height: 100%;
    width: 0;
    transition: width 0.3s ease-in-out, background 0.3s ease-in-out;
}

.strength-weak {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.strength-medium {
    background: linear-gradient(90deg, #f39c12, #e67e22);
}

.strength-strong {
    background: linear-gradient(90deg, #27ae60, #229954);
}

/* Password Match Indicator */
.password-match {
    font-size: 0.875rem;
    margin-top: 6px;
    color: var(--color-error);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.password-match.valid {
    color: var(--color-success);
}

.password-match i {
    font-size: 0.9rem;
}


/* Password Requirements 
.password-requirements-container {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.password-requirements {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.password-requirements:first-child {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.password-requirements ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.password-requirements li {
    padding-left: 1.5rem;
    position: relative;
    margin-bottom: 0.5rem;
}

.password-requirements li::before {
    content: '•';
    position: absolute;
    left: 0.5rem;
    color: var(--color-primary);
}

.password-requirements li.valid {
    color: var(--color-success);
}

.password-requirements li.valid::before {
    content: '✓';
    color: var(--color-success);
    font-weight: bold;
}

/* ========================================
   2FA CODE INPUT
   ======================================== */

.code-input-group {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin: 2rem 0;
}

.code-digit {
    width: 3rem;
    height: 3.5rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-card-bg);
    color: var(--color-text);
    transition: var(--transition);
}

.code-digit:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: scale(1.05);
}

/* ========================================
   AUTH FOOTER
   ======================================== */

.auth-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.help-text {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.help-text i {
    margin-top: 2px;
    flex-shrink: 0;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.hidden {
    display: none !important;
}

.mb-2 {
    margin-bottom: 1rem;
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

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

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 640px) {
    .auth-wrapper {
        padding: 1rem 0.5rem;
    }

    .auth-container {
        padding: 2rem 1.5rem;
    }

    .auth-header h1 {
        font-size: 1.75rem;
    }

    .auth-header .auth-icon {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    .auth-links {
        flex-direction: column;
        align-items: flex-start;
    }

    .code-digit {
        width: 2.5rem;
        height: 3rem;
        font-size: 1.25rem;
    }

    .btn {
        padding: 0.875rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .form-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.btn:focus,
.form-input:focus,
.auth-link:focus,
.password-toggle:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --color-border: light-dark(#000000, #ffffff);
        --color-text: light-dark(#000000, #ffffff);
    }
    
    .form-input,
    .btn {
        border-width: 3px;
    }
}

/* Password strength meter */
.strength-meter {
  height: 6px;
  width: 100%;
  background: var(--input-bg);
  margin-top: 0.5rem;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.strength-meter-fill {
  height: 100%;
  width: 0;
  transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
  border-radius: 3px;
}

.strength-weak { background: linear-gradient(90deg, #ef4444, #dc2626); }
.strength-medium { background: linear-gradient(90deg, #f59e0b, #d97706); }
.strength-strong { background: linear-gradient(90deg, #10b981, #059669); }

/* Password requirements */
.password-requirements-container {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
}

.password-requirements {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.password-requirements li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  transition: color 0.2s ease;
  padding: 0.25rem;
}

.password-requirements li::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.875rem;
}

.password-requirements li.valid {
  color: #10b981;
}

.password-requirements li.valid::before {
  content: "\f058"; /* fa-circle-check */
}

.password-requirements li.invalid {
  color: var(--text-secondary);
}

.password-requirements li.invalid::before {
  content: "\f111"; /* fa-circle */
  opacity: 0.3;
}

/* Password match message */
.password-match {
  font-size: 0.9rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--error-color);
  transition: color 0.2s ease;
}

.password-match.valid {
  color: #10b981;
}

.password-match i {
  font-size: 1rem;
}

/* Missing requirements message */
#pwd-now-missing {
  font-size: 0.9rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  line-height: 1.6;
}

#pwd-now-missing.valid {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
}

#pwd-now-missing.invalid {
  color: var(--text-secondary);
}

/* Generate password button */
.generate-password-btn {
  width: 100%;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}