/* ========================================
   Modern Auth Pages Design System
   Matches main grid page aesthetic
   ======================================== */

/* Import modern font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ========================================
   CSS Variables - Design Tokens
   ======================================== */
:root {
    /* Colors - Matching Grid Page */
    --auth-bg-start: #1A1D2A;
    --auth-bg-end: #111522;
    --auth-card-bg: #232638;
    --auth-card-border: #2F3447;
    --auth-input-bg: #2A2E41;
    --auth-input-border: #3B4158;
    --auth-input-border-focus: #4B5468;
    --auth-text-primary: #E6E9EF;
    --auth-text-secondary: #8D93A5;
    --auth-text-muted: #6B7280;

    /* Primary Actions */
    --auth-primary: #3B82F6;
    --auth-primary-hover: #60A5FA;
    --auth-primary-focus: #93C5FD;
    --auth-primary-ring: rgba(147, 197, 253, 0.4);

    /* Destructive/Error */
    --auth-error: #EF4444;
    --auth-error-hover: #F87171;
    --auth-error-bg: rgba(239, 68, 68, 0.1);

    /* Success */
    --auth-success: #10B981;
    --auth-success-bg: rgba(16, 185, 129, 0.1);

    /* Links */
    --auth-link: #93C5FD;
    --auth-link-hover: #BFDBFE;

    /* Spacing Grid (8px base) */
    --auth-space-1: 0.5rem;    /* 8px */
    --auth-space-2: 1rem;      /* 16px */
    --auth-space-3: 1.5rem;    /* 24px */
    --auth-space-4: 2rem;      /* 32px */

    /* Border Radius */
    --auth-radius-sm: 6px;
    --auth-radius-md: 10px;
    --auth-radius-lg: 14px;

    /* Shadows */
    --auth-shadow-card: 0 6px 24px rgba(0, 0, 0, 0.35);
    --auth-shadow-input: 0 2px 8px rgba(0, 0, 0, 0.15);
    --auth-shadow-button: 0 4px 12px rgba(59, 130, 246, 0.25);

    /* Typography */
    --auth-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ========================================
   Auth Shell - Full-height centered layout
   ======================================== */
.auth-shell {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--auth-bg-start) 0%, var(--auth-bg-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--auth-space-3);
    font-family: var(--auth-font-family);
}

.auth-container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

/* ========================================
   Auth Grid - Two column layout
   ======================================== */
.auth-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--auth-space-3);
    width: 100%;
}

@media (min-width: 1024px) {
    .auth-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Single column variant for Forgot Password */
.auth-grid--single {
    grid-template-columns: 1fr;
    max-width: 480px;
    margin: 0 auto;
}

/* ========================================
   Auth Card - Matching grid page cards
   ======================================== */
.auth-card {
    background: var(--auth-card-bg);
    border: 1px solid var(--auth-card-border);
    border-radius: var(--auth-radius-lg);
    padding: 1.75rem;
    box-shadow: var(--auth-shadow-card);
    display: flex;
    flex-direction: column;
    gap: var(--auth-space-3);
    /* Prevent flash before animation */
    opacity: 0;
    animation: auth-slide-up 0.5s ease-out forwards;
}

.auth-card__header {
    display: flex;
    flex-direction: column;
    gap: var(--auth-space-1);
}

.auth-card__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--auth-text-primary);
    margin: 0;
    line-height: 1.3;
}

.auth-card__subtitle {
    font-size: 0.875rem;
    color: var(--auth-text-secondary);
    margin: 0;
    line-height: 1.5;
}

.auth-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--auth-space-2);
}

/* ========================================
   Auth Input - Form fields
   ======================================== */
.auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auth-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--auth-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.auth-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input {
    width: 100%;
    height: 44px;
    padding: 0 0.875rem;
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-input-border);
    border-radius: var(--auth-radius-md);
    color: var(--auth-text-primary);
    font-size: 0.9375rem;
    font-family: var(--auth-font-family);
    transition: all 0.2s ease;
    box-shadow: var(--auth-shadow-input);
}

.auth-input::placeholder {
    color: var(--auth-text-secondary);
}

.auth-input:hover {
    border-color: var(--auth-input-border-focus);
}

.auth-input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px var(--auth-primary-ring);
}

.auth-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Input with icon (password toggle) */
.auth-input--with-icon {
    padding-right: 2.75rem;
}

.auth-input-icon {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--auth-text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.auth-input-icon:hover {
    color: var(--auth-text-primary);
}

/* Error state */
.auth-input--error {
    border-color: var(--auth-error);
}

.auth-input--error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.auth-error-message {
    font-size: 0.75rem;
    color: var(--auth-error);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.auth-helper-text {
    font-size: 0.75rem;
    color: var(--auth-text-muted);
    margin: 0;
}

/* ========================================
   Auth Checkbox
   ======================================== */
.auth-checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.auth-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--auth-primary);
}

.auth-checkbox-label {
    font-size: 0.875rem;
    color: var(--auth-text-primary);
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* ========================================
   Auth Buttons
   ======================================== */
.auth-button {
    width: 100%;
    height: 44px;
    padding: 0 1.5rem;
    font-family: var(--auth-font-family);
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--auth-radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.auth-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary button */
.auth-button--primary {
    background: var(--auth-primary);
    color: white;
    box-shadow: var(--auth-shadow-button);
}

.auth-button--primary:hover:not(:disabled) {
    background: var(--auth-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.auth-button--primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--auth-primary-ring), var(--auth-shadow-button);
}

.auth-button--primary:active:not(:disabled) {
    transform: translateY(0);
}

/* Secondary/Outline button */
.auth-button--secondary {
    background: transparent;
    color: var(--auth-text-primary);
    border: 1px solid var(--auth-card-border);
}

.auth-button--secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--auth-input-border-focus);
}

.auth-button--secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* SSO Button */
.auth-button--sso {
    background: var(--auth-input-bg);
    color: var(--auth-text-primary);
    border: 1px solid var(--auth-input-border);
    justify-content: flex-start;
    padding-left: 1rem;
}

.auth-button--sso:hover:not(:disabled) {
    background: var(--auth-input-border);
    border-color: var(--auth-input-border-focus);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-button--sso svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Auth Links
   ======================================== */
.auth-link {
    color: var(--auth-link);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.auth-link:hover {
    color: var(--auth-link-hover);
    text-decoration: underline;
}

.auth-link:focus {
    outline: 2px solid var(--auth-primary-focus);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ========================================
   Utility Row (Remember me + Forgot password)
   ======================================== */
.auth-utility-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--auth-space-2);
    margin: -0.5rem 0;
}

/* ========================================
   Divider with text
   ======================================== */
.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--auth-space-2);
    margin: var(--auth-space-2) 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--auth-card-border);
}

.auth-divider__text {
    font-size: 0.75rem;
    color: var(--auth-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========================================
   Alert/Toast Messages
   ======================================== */
.auth-alert {
    padding: 0.875rem 1rem;
    border-radius: var(--auth-radius-md);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-left: 3px solid;
}

.auth-alert--error {
    background: var(--auth-error-bg);
    border-left-color: var(--auth-error);
    color: #FECACA;
}

.auth-alert--success {
    background: var(--auth-success-bg);
    border-left-color: var(--auth-success);
    color: #A7F3D0;
}

.auth-alert--info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--auth-primary);
    color: #BFDBFE;
}

/* ========================================
   Password Strength Meter
   ======================================== */
.auth-password-strength {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.auth-password-strength__bar {
    flex: 1;
    height: 3px;
    background: var(--auth-input-border);
    border-radius: 2px;
    transition: all 0.3s;
}

.auth-password-strength__bar--active {
    background: var(--auth-success);
}

.auth-password-strength__bar--active.weak {
    background: var(--auth-error);
}

.auth-password-strength__bar--active.ok {
    background: #F59E0B;
}

.auth-password-strength__bar--active.strong {
    background: var(--auth-success);
}

.auth-password-strength__label {
    font-size: 0.75rem;
    color: var(--auth-text-secondary);
    margin-top: 0.25rem;
}

/* ========================================
   Caps Lock Warning
   ======================================== */
.auth-caps-warning {
    font-size: 0.75rem;
    color: #F59E0B;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: -0.25rem;
}

/* ========================================
   SSO Provider List
   ======================================== */
.auth-sso-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ========================================
   Footer Link
   ======================================== */
.auth-footer {
    text-align: center;
    margin-top: var(--auth-space-3);
}

.auth-footer-text {
    font-size: 0.875rem;
    color: var(--auth-text-muted);
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (max-width: 1023px) {
    .auth-shell {
        padding: var(--auth-space-2);
    }

    .auth-card {
        padding: 1.25rem;
    }
}

@media (max-width: 640px) {
    .auth-utility-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========================================
   Accessibility - Focus visible
   ======================================== */
.auth-input:focus-visible,
.auth-button:focus-visible,
.auth-link:focus-visible,
.auth-checkbox:focus-visible {
    outline: 2px solid var(--auth-primary-focus);
    outline-offset: 2px;
}

/* ========================================
   Animation
   ======================================== */
@keyframes auth-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Second card gets a slight delay for staggered effect */
.auth-grid .auth-card:nth-child(2) {
    animation-delay: 0.15s;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .auth-card {
        animation: none;
        opacity: 1;
        transform: none;
    }
}
