/* ============================================
   XRAY — Apple-Inspired Login
   Aesthetic: Refined minimalism, frosted glass,
   SF Pro typography, warm neutral palette
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&display=swap');

:root {
    --apple-bg: #ffffff;
    --apple-surface: rgba(255, 255, 255, 0.85);
    --apple-surface-hover: rgba(245, 245, 247, 0.9);
    --apple-border: rgba(0, 0, 0, 0.06);
    --apple-border-focus: rgba(0, 0, 0, 0.4);
    --apple-text-primary: #1d1d1f;
    --apple-text-secondary: #6e6e73;
    --apple-text-tertiary: #aeaeb2;
    --apple-accent: #1d1d1f;
    --apple-accent-hover: #333336;
    --apple-error: #FF3B30;
    --apple-error-bg: rgba(255, 59, 48, 0.08);
    --apple-warning: #FF9500;
    --apple-success: #34C759;
    --apple-input-bg: #f5f5f7;
    --apple-input-bg-focus: #efefef;
    --apple-blur: 80px;
    --apple-radius: 12px;
    --apple-radius-lg: 20px;
    --apple-transition: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --apple-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--apple-bg);
    position: relative;
    overflow: hidden;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ambient light orbs — subtle warm/cool tones like macOS wallpapers */
.login-ambient {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

.login-ambient .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
    animation: orbFloat 20s ease-in-out infinite alternate;
}

.login-ambient .orb:nth-child(1) {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #e0e0e0 0%, transparent 70%);
    top: -15%;
    left: -10%;
    animation-duration: 22s;
}

.login-ambient .orb:nth-child(2) {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #d5d5d8 0%, transparent 70%);
    bottom: -20%;
    right: -10%;
    animation-duration: 18s;
    animation-delay: -5s;
}

.login-ambient .orb:nth-child(3) {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #e8e8ed 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 25s;
    animation-delay: -10s;
    opacity: 0.4;
}

@keyframes orbFloat {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 15px) scale(0.95); }
    100% { transform: translate(10px, -10px) scale(1.02); }
}

/* ---- Card ---- */
.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    margin: 1.5rem;
    background: var(--apple-surface);
    backdrop-filter: blur(var(--apple-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--apple-blur)) saturate(180%);
    border: 1px solid var(--apple-border);
    border-radius: var(--apple-radius-lg);
    padding: 2.75rem 2.25rem 2.25rem;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.04) inset,
                0 24px 80px -12px rgba(0, 0, 0, 0.08),
                0 0 1px rgba(0, 0, 0, 0.06);
    animation: cardReveal 0.7s var(--apple-transition) both;
}

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(16px);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

/* ---- Brand ---- */
.login-brand {
    text-align: center;
    margin-bottom: 2.25rem;
    animation: brandReveal 0.8s var(--apple-transition) 0.15s both;
}

@keyframes brandReveal {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-brand-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(145deg, #1d1d1f, #3a3a3c);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15),
                0 0 0 0.5px rgba(255, 255, 255, 0.06) inset;
    transition: transform 0.4s var(--apple-spring);
}

.login-brand-icon:hover {
    transform: scale(1.08) rotate(-2deg);
}

.login-brand-icon i {
    font-size: 1.4rem;
    color: #fff;
}

.login-brand h1 {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--apple-text-primary);
    margin-bottom: 0.25rem;
    letter-spacing: -0.4px;
}

.login-brand p {
    color: var(--apple-text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
    margin: 0;
    letter-spacing: -0.1px;
}

/* ---- Server Error Alert ---- */
.login-alert {
    background: var(--apple-error-bg);
    border: 1px solid rgba(255, 59, 48, 0.15);
    border-radius: var(--apple-radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    animation: alertAppear 0.4s var(--apple-spring);
}

@keyframes alertAppear {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-alert i {
    color: var(--apple-error);
    font-size: 0.95rem;
    margin-top: 1px;
    flex-shrink: 0;
}

.login-alert span {
    color: #FF3B30;
    font-size: 0.8125rem;
    line-height: 1.45;
    font-weight: 500;
}

/* ---- Form Group ---- */
.login-form-group {
    margin-bottom: 1.25rem;
    animation: fieldReveal 0.6s var(--apple-transition) both;
}

.login-form-group:nth-child(1) { animation-delay: 0.25s; }
.login-form-group:nth-child(2) { animation-delay: 0.35s; }

@keyframes fieldReveal {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-form-group label {
    display: block;
    color: var(--apple-text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.45rem;
    letter-spacing: -0.08px;
    transition: color 0.3s ease;
}

.login-form-group:focus-within label {
    color: var(--apple-text-primary);
}

/* ---- Input ---- */
.login-input-wrapper {
    position: relative;
}

.login-input-wrapper i.field-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--apple-text-tertiary);
    font-size: 0.85rem;
    transition: color 0.3s ease;
    z-index: 2;
    pointer-events: none;
}

.login-input-wrapper input {
    width: 100%;
    padding: 0.75rem 0.875rem 0.75rem 2.5rem;
    background: var(--apple-input-bg);
    border: 1.5px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    color: var(--apple-text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 400;
    letter-spacing: -0.1px;
    transition: all 0.25s var(--apple-transition);
    outline: none;
    -webkit-appearance: none;
}

.login-input-wrapper input::placeholder {
    color: var(--apple-text-tertiary);
    font-weight: 400;
}

.login-input-wrapper input:hover {
    background: var(--apple-input-bg-focus);
}

.login-input-wrapper input:focus {
    background: #ffffff;
    border-color: var(--apple-border-focus);
    box-shadow: 0 0 0 3.5px rgba(0, 0, 0, 0.06);
}

.login-input-wrapper input:focus ~ i.field-icon {
    color: var(--apple-text-primary);
}

/* ---- Password Toggle ---- */
.login-password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--apple-text-tertiary);
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    transition: color 0.2s ease;
    z-index: 2;
    border-radius: 6px;
}

.login-password-toggle:hover {
    color: var(--apple-text-secondary);
}

/* ---- Validation: Error State ---- */
.login-input-wrapper input.input-error {
    border-color: rgba(255, 59, 48, 0.5);
    box-shadow: 0 0 0 3.5px rgba(255, 59, 48, 0.08);
    animation: inputShake 0.35s ease;
}

.login-input-wrapper input.input-error ~ i.field-icon {
    color: var(--apple-error);
}

@keyframes inputShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}

.login-field-error {
    display: block;
    color: var(--apple-error);
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.35rem;
    padding-left: 0.125rem;
    min-height: 0;
    animation: errorFade 0.25s ease;
}

@keyframes errorFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Caps Lock Warning ---- */
.capslock-warning {
    display: none;
    align-items: center;
    gap: 0.35rem;
    color: var(--apple-warning);
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.35rem;
    padding-left: 0.125rem;
    animation: errorFade 0.25s ease;
}

.capslock-warning i {
    font-size: 0.7rem;
}

.capslock-warning.show {
    display: flex;
}

/* ---- Remember Me ---- */
.login-remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
    animation: fieldReveal 0.6s var(--apple-transition) 0.45s both;
}

.login-remember input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    background: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s ease;
}

.login-remember input[type="checkbox"]:checked {
    background: #1d1d1f;
    border-color: #1d1d1f;
}

.login-remember input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5.5px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 1.8px 1.8px 0;
    transform: rotate(45deg);
}

.login-remember input[type="checkbox"]:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.login-remember label {
    color: var(--apple-text-secondary);
    font-size: 0.8125rem;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
    margin: 0;
    letter-spacing: -0.08px;
}

/* ---- Submit Button ---- */
.login-btn {
    width: 100%;
    padding: 0.8rem 1.25rem;
    background: var(--apple-accent);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: -0.1px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    animation: fieldReveal 0.6s var(--apple-transition) 0.55s both;
}

.login-btn:hover {
    background: var(--apple-accent-hover);
    transform: scale(1.01);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.login-btn:active {
    transform: scale(0.985);
    box-shadow: none;
}

.login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading state */
.login-btn .btn-text,
.login-btn .btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.login-btn .btn-loading {
    display: none;
}

.login-btn.is-loading .btn-text {
    display: none;
}

.login-btn.is-loading .btn-loading {
    display: flex;
}

.login-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Divider ---- */
.login-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    animation: fieldReveal 0.6s var(--apple-transition) 0.6s both;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--apple-border);
}

.login-divider span {
    color: var(--apple-text-tertiary);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Footer ---- */
.login-footer {
    text-align: center;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--apple-border);
    animation: fieldReveal 0.6s var(--apple-transition) 0.65s both;
}

.login-footer p {
    color: var(--apple-text-tertiary);
    font-size: 0.6875rem;
    font-weight: 400;
    margin: 0;
    letter-spacing: 0.2px;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .login-card {
        padding: 2rem 1.5rem 1.75rem;
        margin: 1rem;
        border-radius: 16px;
    }

    .login-brand-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }

    .login-brand-icon i {
        font-size: 1.2rem;
    }

    .login-brand h1 {
        font-size: 1.4rem;
    }

    .login-ambient .orb {
        filter: blur(80px);
        opacity: 0.35;
    }
}

/* ---- Logo Branding ---- */
.login-logo-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.75rem;
    background: linear-gradient(145deg, #1d1d1f, #2c2c2e);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16),
                0 0 0 0.5px rgba(255, 255, 255, 0.08) inset;
    margin: 0 auto 1.25rem;
    transition: transform 0.4s var(--apple-spring);
}

.login-logo-wrapper:hover {
    transform: scale(1.04) rotate(-0.5deg);
}

.login-logo {
    height: 38px;
    width: auto;
    display: block;
}

/* ---- Back Button ---- */
.login-btn-back {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1.25rem;
    background: transparent;
    border: 1.5px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    color: var(--apple-text-secondary);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: -0.1px;
    transition: all 0.2s ease;
    margin-top: 0.75rem;
    box-sizing: border-box;
    animation: fieldReveal 0.6s var(--apple-transition) 0.6s both;
}

.login-btn-back:hover {
    background: rgba(0, 0, 0, 0.03);
    color: var(--apple-text-primary);
    border-color: var(--apple-text-primary);
    transform: scale(1.01);
}

.login-btn-back:active {
    transform: scale(0.985);
}

/* ---- Accessibility: prefers-reduced-motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
