/* Login Page - Apple Intelligence Guidelines (AIG) Styling */

/* ===========================
   RESET & BASE
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===========================
   APPLE AIG COLOR SYSTEM - DARK THEME (DEFAULT)
   =========================== */
:root {
    /* Refined dark backgrounds - Dark grey instead of pitch black */
    --aig-bg-primary: #1a1a1a;
    --aig-bg-secondary: #252525;
    --aig-bg-tertiary: #2f2f2f;
    --aig-bg-elevated: #383838;
    
  /* Sophisticated accent colors - Original purple/indigo (BRAND) */
  --aig-accent-primary: #6366F1;
  --aig-accent-secondary: #818CF8;
  --aig-accent-tertiary: #3B82F6;
    
    /* Refined text colors */
    --aig-text-primary: #FFFFFF;
    --aig-text-secondary: #EBEBF5;
    --aig-text-tertiary: #EBEBF599;
    --aig-text-quaternary: #EBEBF54D;
    
    /* Semantic colors */
    --aig-success: #30D158;
    --aig-error: #FF453A;
    --aig-warning: #FFD60A;
    
    /* Apple shadow system */
    --aig-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --aig-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 1px rgba(255, 255, 255, 0.05);
    --aig-shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.4), 0 0 1px rgba(255, 255, 255, 0.08);
    --aig-shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 2px rgba(255, 255, 255, 0.1);
    
    /* Glassmorphism */
    --aig-glass-bg: rgba(28, 28, 30, 0.72);
    --aig-glass-border: rgba(255, 255, 255, 0.08);
    
    /* Spring animations - Apple-style easing */
    --aig-spring: cubic-bezier(0.175, 0.885, 0.32, 1.1);
    --aig-ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
    --aig-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ===========================
   APPLE AIG COLOR SYSTEM - LIGHT THEME
   =========================== */
body[data-theme="light"] {
    /* Light backgrounds */
    --aig-bg-primary: #F5F5F7;
    --aig-bg-secondary: #FFFFFF;
    --aig-bg-tertiary: #FAFAFA;
    --aig-bg-elevated: #FFFFFF;
    
    /* Accent colors */
    --aig-accent-primary: #5E5CE6;
    --aig-accent-secondary: #7D7AFF;
    --aig-accent-tertiary: #4C4CDB;
    
    /* Light theme text */
    --aig-text-primary: #1D1D1F;
    --aig-text-secondary: #1D1D1F;
    --aig-text-tertiary: #86868B;
    --aig-text-quaternary: #C7C7CC;
    
    /* Semantic colors */
    --aig-success: #28CD41;
    --aig-warning: #FFB340;
    --aig-error: #FF3B30;
    
    /* Light shadows */
    --aig-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --aig-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.08);
    --aig-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.08);
    --aig-shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.16), 0 12px 24px rgba(0, 0, 0, 0.1);
    
    /* Light glassmorphism */
    --aig-glass-bg: rgba(255, 255, 255, 0.85);
    --aig-glass-border: rgba(0, 0, 0, 0.08);
}

/* ===========================
   BODY & BACKGROUND
   =========================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: var(--aig-bg-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   LOGIN CONTAINER
   =========================== */
.login-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 440px;
}

/* ===========================
   LOGIN CARD - GLASSMORPHISM
   =========================== */
.login-card {
    background: var(--aig-glass-bg);
    backdrop-filter: blur(60px) saturate(180%);
    -webkit-backdrop-filter: blur(60px) saturate(180%);
    border-radius: 28px;
    padding: 56px 48px;
    box-shadow: 
        var(--aig-shadow-xl),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    border: 1px solid var(--aig-glass-border);
    position: relative;
    overflow: hidden;
}

/* Subtle inner glow */
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(99, 102, 241, 0.5) 50%, 
        transparent
    );
    opacity: 0.6;
}

/* ===========================
   LOGIN HEADER
   =========================== */
.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    margin-bottom: 12px;
    background: linear-gradient(135deg, 
        var(--aig-accent-primary) 0%, 
        var(--aig-accent-secondary) 50%,
        var(--aig-accent-tertiary) 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 8s ease-in-out infinite;
    background-size: 200% 200%;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.login-header p {
    color: var(--aig-text-tertiary);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.5;
}

/* ===========================
   FORM FIELDS
   =========================== */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-field label {
    color: var(--aig-text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    padding-left: 4px;
}

.form-field input {
    width: 100%;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--aig-text-primary);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    transition: all 0.3s var(--aig-ease-out);
    outline: none;
}

.form-field input::placeholder {
    color: var(--aig-text-quaternary);
}

.form-field input:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
}

.form-field input:focus {
    border-color: var(--aig-accent-primary);
    background: rgba(255, 255, 255, 0.1);
  box-shadow: 
    0 0 0 4px rgba(99, 102, 241, 0.15),
    0 2px 8px rgba(99, 102, 241, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: scale(1.01);
}

/* ===========================
   LOGIN BUTTON - ENHANCED
   =========================== */
.btn-login {
    margin-top: 12px;
    padding: 16px 28px;
    border: none;
    border-radius: 16px;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
  background: linear-gradient(135deg, 
    var(--aig-accent-primary) 0%, 
    var(--aig-accent-secondary) 100%
  );
  color: #FFFFFF;
  box-shadow: 
    0 8px 24px rgba(99, 102, 241, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.3s var(--aig-spring);
    position: relative;
    overflow: hidden;
}

/* Shine effect */
.btn-login::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent
    );
    transition: left 0.6s var(--aig-ease-out);
}

.btn-login:hover {
    transform: translateY(-2px) scale(1.02);
  box-shadow: 
    0 16px 40px rgba(99, 102, 241, 0.45),
    0 0 60px rgba(99, 102, 241, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

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

.btn-login:active {
    transform: translateY(0) scale(0.98);
  box-shadow: 
    0 4px 16px rgba(99, 102, 241, 0.3),
    inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===========================
   ERROR MESSAGE
   =========================== */
.error-message {
    margin-top: 8px;
    padding: 14px 18px;
    background: rgba(255, 69, 58, 0.12);
    border: 1.5px solid rgba(255, 69, 58, 0.3);
    border-radius: 12px;
    color: var(--aig-error);
    font-size: 0.9375rem;
    font-weight: 500;
    text-align: center;
    letter-spacing: -0.01em;
    animation: errorShake 0.4s var(--aig-spring);
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* ===========================
   OAUTH DIVIDER
   =========================== */
.oauth-divider {
    text-align: center;
    margin: 32px 0 24px 0;
    position: relative;
}

.oauth-divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.12) 20%,
        rgba(255, 255, 255, 0.12) 80%,
        transparent
    );
}

.oauth-divider span {
    background: var(--aig-glass-bg);
    backdrop-filter: blur(20px);
    padding: 0 16px;
    position: relative;
    color: var(--aig-text-tertiary);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ===========================
   OAUTH BUTTONS - REFINED
   =========================== */
.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 12px;
}

.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 14px 24px;
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    color: var(--aig-text-primary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all 0.3s var(--aig-ease-out);
    position: relative;
    overflow: hidden;
}

/* Subtle gradient overlay on hover */
.btn-oauth::after {
    content: '';
    position: absolute;
    inset: 0;
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.05),
    rgba(129, 140, 248, 0.05)
  );
    opacity: 0;
    transition: opacity 0.3s var(--aig-ease-out);
}

.btn-oauth:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.3),
        0 0 1px rgba(255, 255, 255, 0.1);
}

.btn-oauth:hover::after {
    opacity: 1;
}

.btn-oauth:active {
    transform: translateY(0) scale(0.98);
}

.btn-oauth svg {
    flex-shrink: 0;
    z-index: 1;
}

/* Apple-specific styling */
.btn-apple {
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-apple:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(255, 255, 255, 0.1);
}

/* Microsoft-specific styling */
.btn-microsoft {
    border-color: rgba(0, 120, 212, 0.2);
}

.btn-microsoft:hover {
    background: rgba(0, 120, 212, 0.08);
    border-color: rgba(0, 120, 212, 0.35);
}

/* ===========================
   PUBLIC LINKS
   =========================== */
.public-links {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    gap: 14px;
    z-index: 3;
}

.public-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--aig-glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--aig-glass-border);
    border-radius: 20px;
    color: var(--aig-text-tertiary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all 0.3s var(--aig-ease-out);
    box-shadow: var(--aig-shadow-md);
}

.public-link:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--aig-accent-primary);
  transform: translateY(-3px);
  box-shadow: 
    0 12px 32px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(99, 102, 241, 0.15);
}

.public-link:active {
    transform: translateY(-1px) scale(0.97);
}

.public-link svg {
    flex-shrink: 0;
    transition: transform 0.3s var(--aig-spring);
}

.public-link:hover svg {
    transform: scale(1.1);
}

/* ===========================
   MOBILE RESPONSIVE
   =========================== */
@media (max-width: 480px) {
    body {
        padding: 16px;
    }
    
    .login-card {
        padding: 40px 32px;
        border-radius: 24px;
    }
    
    .login-header h1 {
        font-size: 1.875rem;
    }
    
    .login-header p {
        font-size: 0.9375rem;
    }
    
    .form-field input {
        padding: 14px 16px;
        font-size: 1rem;
    }
    
    .btn-login {
        padding: 15px 24px;
        font-size: 1rem;
    }
    
    .btn-oauth {
        font-size: 0.9375rem;
        padding: 13px 20px;
        gap: 12px;
    }
    
    .public-links {
        position: static;
        justify-content: center;
        margin-top: 32px;
        flex-wrap: wrap;
    }
    
    .public-link {
        font-size: 0.8125rem;
        padding: 8px 14px;
        border-radius: 18px;
    }
}

@media (max-width: 380px) {
    .login-card {
        padding: 32px 24px;
    }
    
    .login-header h1 {
        font-size: 1.625rem;
    }
    
    .oauth-buttons {
        gap: 12px;
    }
}

/* ===========================
   MESSAGE BOXES - ENHANCED
   =========================== */
.message-box {
    display: none;
    padding: 14px 18px;
    border-radius: 12px;
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all 0.3s var(--aig-spring);
    border: 1px solid transparent;
}

.message-box:not(:empty) {
    display: block;
}

.success-message {
    color: var(--aig-success, #30D158);
    background: rgba(48, 209, 88, 0.1);
    border-color: rgba(48, 209, 88, 0.2);
}

.error-message {
    color: var(--aig-error, #FF453A);
    background: rgba(255, 69, 58, 0.1);
    border-color: rgba(255, 69, 58, 0.2);
}

/* ===========================
   BACK LINK - ENHANCED
   =========================== */
.back-link-container {
    text-align: center;
    margin-top: 20px;
}

.back-link {
    color: var(--aig-accent-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all 0.3s var(--aig-spring);
    display: inline-block;
}

.back-link:hover {
    color: var(--aig-accent-hover);
    transform: translateY(-1px);
}

.back-link:active {
    transform: scale(0.98);
}

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

/* Focus visible for keyboard navigation */
.btn-login:focus-visible,
.btn-oauth:focus-visible,
.form-field input:focus-visible,
.public-link:focus-visible {
    outline: 2px solid var(--aig-accent-primary);
    outline-offset: 3px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .login-card {
        border-width: 2px;
        border-color: var(--aig-text-tertiary);
    }
    
    .form-field input,
    .btn-oauth {
        border-width: 2px;
    }
}

/* ===========================
   LIGHT THEME SPECIFIC ADJUSTMENTS
   =========================== */
body[data-theme="light"] .btn-login {
    color: #FFFFFF;
}

body[data-theme="light"] .form-field input {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.12);
}

body[data-theme="light"] .form-field input:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.18);
}

body[data-theme="light"] .form-field input:focus {
    background: rgba(255, 255, 255, 0.8);
}

body[data-theme="light"] .btn-oauth {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.12);
}

body[data-theme="light"] .btn-oauth:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.2);
}

/* Light theme - login/MFA card */
body[data-theme="light"] .login-card {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 4px 16px rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .login-card::before {
    background: linear-gradient(90deg, 
        transparent, 
        rgba(0, 0, 0, 0.06) 50%, 
        transparent
    );
}

body[data-theme="light"] .login-header h1 {
    color: #1D1D1F;
}

body[data-theme="light"] .login-header p {
    color: #86868B;
}

body[data-theme="light"] .method-button {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.12);
    color: #1D1D1F;
}

body[data-theme="light"] .method-button.active {
    background: #4B49C8;
    color: white;
}

/* MFA container specific - override inline styles */
body[data-theme="light"] .mfa-container {
    background: #FFFFFF !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 4px 16px rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .mfa-container::before {
    background: linear-gradient(90deg, 
        transparent, 
        rgba(0, 0, 0, 0.06) 50%, 
        transparent
    ) !important;
}

/* MFA text elements */
body[data-theme="light"] .mfa-container h1,
body[data-theme="light"] .mfa-container h2,
body[data-theme="light"] .mfa-container h3 {
    color: #1D1D1F !important;
}

body[data-theme="light"] .mfa-container p,
body[data-theme="light"] .mfa-container label {
    color: #86868B !important;
}

/* MFA input fields */
body[data-theme="light"] .totp-input,
body[data-theme="light"] .mfa-container input[type="text"] {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    color: #1D1D1F !important;
}

body[data-theme="light"] .totp-input:focus,
body[data-theme="light"] .mfa-container input[type="text"]:focus {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: #4B49C8 !important;
}

/* MFA verify button */
body[data-theme="light"] .verify-button {
    background: linear-gradient(135deg, #4B49C8 0%, #6461E0 100%) !important;
}

/* Smooth theme transitions */
body,
.login-card,
.btn-login,
.btn-oauth,
.form-field input,
.public-link {
    transition: background-color 0.3s var(--aig-ease-out), 
                color 0.3s var(--aig-ease-out),
                border-color 0.3s var(--aig-ease-out),
                box-shadow 0.3s var(--aig-ease-out);
}
