/**
 * MotionFy Auth Modal + Topbar + Dark Mode Styles
 * 
 * BEM-style class naming convention:
 *   .auth-modal, .auth__social, .auth__field, .avatar-dropdown
 * 
 * Theme tokens (CSS custom properties) for light/dark mode.
 * WCAG AA compliant contrast ratios.
 */

/* ============================================================
   Theme Variables - Light Mode (default)
   ============================================================ */
:root {
    /* Backgrounds */
    --auth-bg: #FFFFFF;
    --auth-surface: #F7F7F8;
    --auth-surface-elevated: #FFFFFF;
    
    /* Text */
    --auth-text: #0A0A0A;
    --auth-text-secondary: #5A6578;
    --auth-text-muted: #8B95A5;
    
    /* Accent */
    --auth-accent: #0B84A5;
    --auth-accent-hover: #097A99;
    
    /* Borders */
    --auth-border: #E6EBF2;
    --auth-border-focus: #0B84A5;
    
    /* States */
    --auth-success: #10B981;
    --auth-error: #EF4444;
    
    /* Overlay */
    --auth-overlay: rgba(10, 10, 10, 0.5);
    
    /* Shadows */
    --auth-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --auth-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --auth-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.15);
    
    /* Transitions */
    --auth-transition-fast: 150ms ease;
    --auth-transition-normal: 200ms ease;
    --auth-transition-theme: 200ms ease;
    
    /* Border radius */
    --auth-radius-sm: 6px;
    --auth-radius-md: 8px;
    --auth-radius-lg: 12px;
    --auth-radius-full: 9999px;
}

/* ============================================================
   Theme Variables - Dark Mode
   ============================================================ */
html.theme-dark,
body.theme-dark {
    /* Backgrounds - Neutral dark gray palette */
    --auth-bg: #141414;
    --auth-surface: #1c1c1c;
    --auth-surface-elevated: #222222;
    
    /* Text */
    --auth-text: #f2f2f2;
    --auth-text-secondary: #b5b5b5;
    --auth-text-muted: #8a8a8a;
    
    /* Accent - Neutral light for dark mode */
    --auth-accent: #e0e0e0;
    --auth-accent-hover: #ffffff;
    
    /* Borders */
    --auth-border: #2c2c2c;
    --auth-border-focus: #505050;
    
    /* States */
    --auth-success: #5cb85c;
    --auth-error: #F87171;
    
    /* Overlay */
    --auth-overlay: rgba(0, 0, 0, 0.75);
    
    /* Shadows */
    --auth-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --auth-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --auth-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Apply dark mode to page backgrounds */
html.theme-dark body,
body.theme-dark {
    background-color: var(--auth-bg);
    color: var(--auth-text);
    transition: background-color var(--auth-transition-theme), color var(--auth-transition-theme);
}

/* Dark mode adjustments for existing page elements */
html.theme-dark .mf-body,
body.theme-dark .mf-body {
    background-color: var(--auth-bg);
    color: var(--auth-text);
}

html.theme-dark .mf-header,
body.theme-dark .mf-header {
    background-color: var(--auth-surface);
    border-color: var(--auth-border);
}

html.theme-dark .mf-footer,
body.theme-dark .mf-footer {
    background-color: var(--auth-surface);
    border-color: var(--auth-border);
}

/* Landing page dark mode (Tailwind overrides) */
html.theme-dark body.bg-white,
body.theme-dark.bg-white {
    background-color: var(--auth-bg) !important;
    color: var(--auth-text) !important;
}

html.theme-dark .bg-gray-50,
body.theme-dark .bg-gray-50 {
    background-color: var(--auth-surface) !important;
}

html.theme-dark .bg-white,
body.theme-dark .bg-white {
    background-color: var(--auth-surface-elevated) !important;
}

html.theme-dark .text-gray-900,
body.theme-dark .text-gray-900 {
    color: var(--auth-text) !important;
}

html.theme-dark .text-gray-700,
html.theme-dark .text-gray-600,
body.theme-dark .text-gray-700,
body.theme-dark .text-gray-600 {
    color: var(--auth-text-secondary) !important;
}

html.theme-dark .text-gray-500,
html.theme-dark .text-gray-400,
html.theme-dark .text-gray-300,
body.theme-dark .text-gray-500,
body.theme-dark .text-gray-400,
body.theme-dark .text-gray-300 {
    color: var(--auth-text-muted) !important;
}

html.theme-dark .border-gray-200,
body.theme-dark .border-gray-200 {
    border-color: var(--auth-border) !important;
}

html.theme-dark .bg-gray-100,
body.theme-dark .bg-gray-100 {
    background-color: var(--auth-surface) !important;
}

html.theme-dark .bg-gray-200,
body.theme-dark .bg-gray-200 {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
}

html.theme-dark .bg-gray-200:hover,
body.theme-dark .bg-gray-200:hover,
html.theme-dark a.bg-gray-200:hover,
body.theme-dark a.bg-gray-200:hover,
html.theme-dark .hover\:bg-gray-300:hover,
body.theme-dark .hover\:bg-gray-300:hover {
    background-color: #4a4a4a !important;
}

/* Landing page CTA buttons - make lighter in dark mode */
html.theme-dark .bg-gray-900,
body.theme-dark .bg-gray-900 {
    background-color: #f2f2f2 !important;
    color: #141414 !important;
}

html.theme-dark .bg-gray-900:hover,
body.theme-dark .bg-gray-900:hover,
html.theme-dark a.bg-gray-900:hover,
body.theme-dark a.bg-gray-900:hover {
    background-color: #d9d9d9 !important;
}

html.theme-dark .hover\:bg-gray-800:hover,
body.theme-dark .hover\:bg-gray-800:hover {
    background-color: #d9d9d9 !important;
}

/* ============================================================
   Create Page Dark Mode Overrides
   ============================================================ */
html.theme-dark .mf-controls,
body.theme-dark .mf-controls {
    background-color: var(--auth-surface);
    border-color: var(--auth-border);
}

html.theme-dark .mf-preview,
body.theme-dark .mf-preview {
    background-color: var(--auth-bg);
}

html.theme-dark .mf-canvas,
body.theme-dark .mf-canvas {
    background-color: var(--auth-surface-elevated);
    border-color: var(--auth-border);
}

html.theme-dark .mf-metadata,
body.theme-dark .mf-metadata {
    background-color: var(--auth-surface-elevated);
    border-color: var(--auth-border);
}

html.theme-dark .mf-step__title,
html.theme-dark .mf-step__indicator,
body.theme-dark .mf-step__title,
body.theme-dark .mf-step__indicator {
    color: var(--auth-text);
}

html.theme-dark .mf-step__optional,
body.theme-dark .mf-step__optional {
    color: var(--auth-text-muted);
}

html.theme-dark .mf-ad-type,
body.theme-dark .mf-ad-type {
    background-color: var(--auth-surface-elevated);
    border-color: var(--auth-border);
}

html.theme-dark .mf-ad-type:hover,
body.theme-dark .mf-ad-type:hover {
    background-color: var(--auth-surface);
    border-color: var(--auth-text-muted);
}

html.theme-dark .mf-ad-type[aria-checked="true"],
body.theme-dark .mf-ad-type[aria-checked="true"] {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: #3B82F6;
}

html.theme-dark .mf-ad-type__name,
body.theme-dark .mf-ad-type__name {
    color: var(--auth-text);
}

html.theme-dark .mf-ad-type__desc,
body.theme-dark .mf-ad-type__desc {
    color: var(--auth-text-secondary);
}

html.theme-dark .mf-upload__dropzone,
body.theme-dark .mf-upload__dropzone {
    background-color: var(--auth-surface-elevated);
    border-color: var(--auth-border);
}

html.theme-dark .mf-upload__dropzone:hover,
body.theme-dark .mf-upload__dropzone:hover {
    border-color: #3B82F6;
    background-color: var(--auth-surface);
}

html.theme-dark .mf-upload__text,
body.theme-dark .mf-upload__text {
    color: var(--auth-text);
}

html.theme-dark .mf-upload__hint,
html.theme-dark .mf-upload__guidance,
body.theme-dark .mf-upload__hint,
body.theme-dark .mf-upload__guidance {
    color: var(--auth-text-muted);
}

html.theme-dark .mf-tag,
body.theme-dark .mf-tag {
    background-color: var(--auth-surface-elevated);
    border-color: var(--auth-border);
    color: var(--auth-text);
}

html.theme-dark .mf-tag:hover,
body.theme-dark .mf-tag:hover {
    background-color: var(--auth-surface);
    border-color: var(--auth-text-muted);
}

html.theme-dark .mf-tag[aria-pressed="true"],
body.theme-dark .mf-tag[aria-pressed="true"] {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: #3B82F6;
    color: #3B82F6;
}

html.theme-dark .mf-radio,
body.theme-dark .mf-radio {
    background-color: var(--auth-surface-elevated);
    border-color: var(--auth-border);
}

html.theme-dark .mf-radio:hover,
body.theme-dark .mf-radio:hover {
    background-color: var(--auth-surface);
    border-color: var(--auth-text-muted);
}

html.theme-dark .mf-radio:has(.mf-radio__input:checked),
body.theme-dark .mf-radio:has(.mf-radio__input:checked) {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: #3B82F6;
}

html.theme-dark .mf-radio__name,
body.theme-dark .mf-radio__name {
    color: var(--auth-text);
}

html.theme-dark .mf-radio__desc,
body.theme-dark .mf-radio__desc {
    color: var(--auth-text-secondary);
}

html.theme-dark .mf-duration__btn,
body.theme-dark .mf-duration__btn {
    background-color: var(--auth-surface-elevated) !important;
    border-color: var(--auth-border) !important;
    color: var(--auth-text) !important;
}

html.theme-dark .mf-duration__option:hover .mf-duration__btn,
body.theme-dark .mf-duration__option:hover .mf-duration__btn,
html.theme-dark .mf-duration__btn:hover,
body.theme-dark .mf-duration__btn:hover {
    border-color: #505050 !important;
    background-color: #2a2a2a !important;
    color: var(--auth-text) !important;
}

html.theme-dark .mf-duration__input:checked + .mf-duration__btn,
body.theme-dark .mf-duration__input:checked + .mf-duration__btn {
    background-color: rgba(59, 130, 246, 0.15) !important;
    border-color: #3B82F6 !important;
    color: #3B82F6 !important;
}

html.theme-dark .mf-mini-input__field,
body.theme-dark .mf-mini-input__field {
    background-color: var(--auth-surface-elevated);
    border-color: var(--auth-border);
    color: var(--auth-text);
}

html.theme-dark .mf-mini-input__field:focus,
body.theme-dark .mf-mini-input__field:focus {
    border-color: #3B82F6;
}

html.theme-dark .mf-mini-input__label,
body.theme-dark .mf-mini-input__label {
    color: var(--auth-text);
}

html.theme-dark .mf-mini-input__counter,
body.theme-dark .mf-mini-input__counter {
    color: var(--auth-text-muted);
}

html.theme-dark .mf-btn--primary,
body.theme-dark .mf-btn--primary {
    background-color: #f2f2f2;
    color: #141414;
}

html.theme-dark .mf-btn--primary:hover:not(:disabled),
body.theme-dark .mf-btn--primary:hover:not(:disabled) {
    background-color: #d9d9d9;
}

html.theme-dark .mf-btn--secondary,
body.theme-dark .mf-btn--secondary {
    background-color: transparent;
    border-color: var(--auth-border);
    color: var(--auth-text-secondary);
}

html.theme-dark .mf-btn--secondary:hover:not(:disabled),
body.theme-dark .mf-btn--secondary:hover:not(:disabled) {
    background-color: var(--auth-surface);
    color: var(--auth-text);
}

html.theme-dark .mf-toggle__switch,
body.theme-dark .mf-toggle__switch {
    background-color: var(--auth-border);
}

html.theme-dark .mf-toggle__input:checked + .mf-toggle__switch,
body.theme-dark .mf-toggle__input:checked + .mf-toggle__switch {
    background-color: #3B82F6;
}

html.theme-dark .mf-toggle__text,
body.theme-dark .mf-toggle__text {
    color: var(--auth-text);
}

html.theme-dark .mf-step__actions,
body.theme-dark .mf-step__actions {
    border-color: var(--auth-border);
}

html.theme-dark .mf-toggle,
body.theme-dark .mf-toggle {
    border-color: var(--auth-border);
}

html.theme-dark .mf-duration,
body.theme-dark .mf-duration {
    border-color: var(--auth-border);
}

html.theme-dark .mf-duration__label,
body.theme-dark .mf-duration__label {
    color: var(--auth-text);
}

html.theme-dark .mf-status__text,
body.theme-dark .mf-status__text {
    color: var(--auth-text-secondary);
}

html.theme-dark .mf-metadata__title,
body.theme-dark .mf-metadata__title {
    color: var(--auth-text);
}

html.theme-dark .mf-metadata__label,
body.theme-dark .mf-metadata__label {
    color: var(--auth-text-muted);
}

html.theme-dark .mf-metadata__value,
body.theme-dark .mf-metadata__value {
    color: var(--auth-text);
}

html.theme-dark .mf-result__title,
body.theme-dark .mf-result__title {
    color: var(--auth-text);
}

html.theme-dark .mf-result__desc,
body.theme-dark .mf-result__desc {
    color: var(--auth-text-secondary);
}

html.theme-dark .mf-footer__copy,
body.theme-dark .mf-footer__copy {
    color: var(--auth-text-muted);
}

html.theme-dark .mf-footer__link,
body.theme-dark .mf-footer__link {
    color: var(--auth-text-secondary);
}

html.theme-dark .mf-footer__link:hover,
body.theme-dark .mf-footer__link:hover {
    color: var(--auth-text-secondary);
}

/* Landing page footer links - subtle hover in dark mode */
html.theme-dark footer a.hover\:text-gray-900:hover,
body.theme-dark footer a.hover\:text-gray-900:hover,
html.theme-dark footer a.hover\:text-gray-700:hover,
body.theme-dark footer a.hover\:text-gray-700:hover {
    color: var(--auth-text-secondary) !important;
}

html.theme-dark .mf-canvas__helper,
body.theme-dark .mf-canvas__helper {
    color: var(--auth-text-muted);
}

html.theme-dark .mf-tags__hint,
body.theme-dark .mf-tags__hint {
    color: var(--auth-text-muted);
}

html.theme-dark .mf-upload__icon,
body.theme-dark .mf-upload__icon {
    color: var(--auth-text-muted);
}

html.theme-dark .mf-ad-type__indicator,
html.theme-dark .mf-radio__indicator,
body.theme-dark .mf-ad-type__indicator,
body.theme-dark .mf-radio__indicator {
    border-color: var(--auth-border);
}

html.theme-dark .mf-ad-type[aria-checked="true"] .mf-ad-type__indicator,
html.theme-dark .mf-radio:has(.mf-radio__input:checked) .mf-radio__indicator,
body.theme-dark .mf-ad-type[aria-checked="true"] .mf-ad-type__indicator,
body.theme-dark .mf-radio:has(.mf-radio__input:checked) .mf-radio__indicator {
    border-color: #3B82F6;
    background-color: #3B82F6;
}

/* ============================================================
   Topbar Auth Buttons
   ============================================================ */
.auth-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-topbar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: var(--auth-radius-sm);
    cursor: pointer;
    transition: background var(--auth-transition-fast), color var(--auth-transition-fast), border-color var(--auth-transition-fast);
}

.auth-topbar__btn--login {
    background: transparent;
    color: var(--auth-text-secondary);
    border: 1px solid transparent;
}

.auth-topbar__btn--login:hover {
    color: var(--auth-text);
    background: var(--auth-surface);
}

.auth-topbar__btn--signup {
    background: var(--auth-text);
    color: var(--auth-bg);
}

html.theme-dark .auth-topbar__btn--signup,
body.theme-dark .auth-topbar__btn--signup {
    background: #f2f2f2;
    color: #141414;
}

html.theme-dark .auth-topbar__btn--signup:hover,
body.theme-dark .auth-topbar__btn--signup:hover {
    background: #ffffff;
}

.auth-topbar__btn--signup:hover {
    opacity: 0.9;
}

/* Dark mode login button - better contrast */
html.theme-dark .auth-topbar__btn--login,
body.theme-dark .auth-topbar__btn--login {
    color: #b5b5b5;
}

html.theme-dark .auth-topbar__btn--login:hover,
body.theme-dark .auth-topbar__btn--login:hover {
    color: #f2f2f2;
    background: rgba(255, 255, 255, 0.1);
}

/* Hidden state */
.auth-topbar--hidden {
    display: none;
}

/* ============================================================
   Avatar & Dropdown
   ============================================================ */
.avatar-container {
    position: relative;
}

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--auth-radius-full);
    background: var(--auth-accent);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    overflow: hidden;
    transition: box-shadow var(--auth-transition-fast);
}

.avatar:hover {
    box-shadow: 0 0 0 2px var(--auth-surface), 0 0 0 4px var(--auth-accent);
}

/* Keep avatar teal in dark mode */
html.theme-dark .avatar,
body.theme-dark .avatar {
    background: #0B84A5;
}

html.theme-dark .avatar:hover,
body.theme-dark .avatar:hover {
    box-shadow: 0 0 0 2px var(--auth-surface), 0 0 0 4px #0B84A5;
}

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

.avatar__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar__initials {
    text-transform: uppercase;
}

/* Avatar Hidden State */
.avatar-container--hidden {
    display: none;
}

/* Dropdown */
.avatar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--auth-surface-elevated);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-md);
    box-shadow: var(--auth-shadow-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--auth-transition-normal), transform var(--auth-transition-normal), visibility var(--auth-transition-normal);
}

.avatar-dropdown--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.avatar-dropdown__header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--auth-border);
}

.avatar-dropdown__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--auth-text);
    margin: 0 0 2px;
}

.avatar-dropdown__email {
    font-size: 12px;
    color: var(--auth-text-muted);
    margin: 0;
}

/* Credits Display in Dropdown */
.avatar-dropdown__credits {
    padding: 12px 16px;
    background: var(--auth-surface);
    border-bottom: 1px solid var(--auth-border);
}

.avatar-dropdown__credits-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.avatar-dropdown__credits-label {
    font-size: 12px;
    color: var(--auth-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.avatar-dropdown__credits-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--auth-text);
}

.avatar-dropdown__credits-plan {
    margin-top: 6px;
}

.avatar-dropdown__plan-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: var(--auth-radius-full);
    background: var(--auth-border);
    color: var(--auth-text-muted);
}

.avatar-dropdown__plan-badge--starter {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
}

.avatar-dropdown__plan-badge--business {
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
}

.avatar-dropdown__plan-badge--scale {
    background: rgba(139, 92, 246, 0.1);
    color: #8B5CF6;
}

/* Admin badge - internal/testing use only */
.avatar-dropdown__plan-badge--admin {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(245, 158, 11, 0.15) 100%);
    color: #D97706;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.avatar-dropdown__plan-badge--hidden {
    display: none;
}

html.theme-dark .avatar-dropdown__plan-badge--starter,
body.theme-dark .avatar-dropdown__plan-badge--starter {
    background: rgba(59, 130, 246, 0.2);
    color: #60A5FA;
}

html.theme-dark .avatar-dropdown__plan-badge--business,
body.theme-dark .avatar-dropdown__plan-badge--business {
    background: rgba(16, 185, 129, 0.2);
    color: #34D399;
}

html.theme-dark .avatar-dropdown__plan-badge--scale,
body.theme-dark .avatar-dropdown__plan-badge--scale {
    background: rgba(139, 92, 246, 0.2);
    color: #A78BFA;
}

/* Admin badge dark mode */
html.theme-dark .avatar-dropdown__plan-badge--admin,
body.theme-dark .avatar-dropdown__plan-badge--admin {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.25) 0%, rgba(245, 158, 11, 0.25) 100%);
    color: #FBBF24;
    border-color: rgba(234, 179, 8, 0.4);
}

.avatar-dropdown__menu {
    padding: 8px 0;
}

.avatar-dropdown__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14px;
    color: var(--auth-text);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background var(--auth-transition-fast);
}

.avatar-dropdown__item:hover {
    background: var(--auth-surface);
}

.avatar-dropdown__item--danger {
    color: var(--auth-error);
}

.avatar-dropdown__item--hidden {
    display: none;
}

.avatar-dropdown__divider {
    height: 1px;
    background: var(--auth-border);
    margin: 8px 0;
}

/* Dark Mode Toggle in Dropdown */
.avatar-dropdown__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--auth-border);
    border-radius: var(--auth-radius-full);
    cursor: pointer;
    transition: background var(--auth-transition-fast);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #FFFFFF;
    border-radius: var(--auth-radius-full);
    transition: transform var(--auth-transition-fast);
    box-shadow: var(--auth-shadow-sm);
}

.toggle-switch--active {
    background: #3B82F6;
}

.toggle-switch--active::after {
    transform: translateX(18px);
}

/* ============================================================
   Auth Modal - Overlay
   ============================================================ */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--auth-overlay);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--auth-transition-normal), visibility var(--auth-transition-normal);
}

.auth-modal-overlay--open {
    opacity: 1;
    visibility: visible;
}

/* ============================================================
   Auth Modal - Container
   ============================================================ */
.auth-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    background: var(--auth-surface-elevated);
    border-radius: var(--auth-radius-lg);
    box-shadow: var(--auth-shadow-lg);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: opacity var(--auth-transition-normal), transform var(--auth-transition-normal), visibility var(--auth-transition-normal);
}

.auth-modal--open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal Close Button */
.auth-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--auth-radius-sm);
    color: var(--auth-text-muted);
    cursor: pointer;
    transition: background var(--auth-transition-fast), color var(--auth-transition-fast);
    z-index: 10;
}

.auth-modal__close:hover {
    background: var(--auth-surface);
    color: var(--auth-text);
}

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

/* Modal Content */
.auth-modal__content {
    padding: 40px 32px 32px;
    overflow-y: auto;
    max-height: 90vh;
}

/* Modal Header */
.auth-modal__header {
    text-align: left;
    margin-bottom: 28px;
}

.auth-modal__logo {
    display: block;
    height: 44px;
    width: auto;
    margin: 0 0 20px -30px;
    transform: scale(2.8);
    transform-origin: left center;
}

.auth-modal__subtitle {
    font-size: 15px;
    font-weight: 500;
    color: var(--auth-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 8px;
}

.auth-modal__title {
    font-size: 28px;
    font-weight: 600;
    color: var(--auth-text);
    margin: 0;
    line-height: 1.3;
}

/* ============================================================
   Auth Modal - Social Buttons
   ============================================================ */
.auth__social {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.auth__social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: var(--auth-text);
    background: var(--auth-surface-elevated);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-md);
    cursor: pointer;
    transition: background var(--auth-transition-fast), border-color var(--auth-transition-fast);
}

.auth__social-btn:hover {
    background: var(--auth-surface);
    border-color: var(--auth-text-muted);
}

.auth__social-btn:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
}

.auth__social-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.auth__social-icon svg {
    width: 100%;
    height: 100%;
    fill: #4B5563;
}

html.theme-dark .auth__social-icon svg,
body.theme-dark .auth__social-icon svg {
    fill: #b5b5b5;
}

/* Email icon - uses stroke instead of fill */
.auth__social-icon--email {
    color: #1f2937;
}

.auth__social-icon--email svg {
    fill: none;
}

html.theme-dark .auth__social-icon--email,
body.theme-dark .auth__social-icon--email {
    color: #b5b5b5;
}

/* ============================================================
   Auth Modal - Divider
   ============================================================ */
.auth__divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.auth__divider-line {
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

.auth__divider-text {
    font-size: 13px;
    color: var(--auth-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================================
   Auth Modal - Email Flow
   ============================================================ */
.auth__email-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: var(--auth-text);
    background: var(--auth-surface-elevated);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-md);
    cursor: pointer;
    transition: background var(--auth-transition-fast), border-color var(--auth-transition-fast);
}

.auth__email-btn:hover {
    background: var(--auth-surface);
    border-color: var(--auth-text-muted);
}

.auth__email-btn:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
}

.auth__email-btn--hidden {
    display: none;
}

/* Email Form - Hidden by default, expands on click */
.auth__email-form {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 200ms ease, opacity 200ms ease, margin 200ms ease;
}

.auth__email-form--visible {
    max-height: 500px;
    overflow: visible;
    opacity: 1;
    margin-top: 16px;
}

/* ============================================================
   Auth Modal - Form Fields
   ============================================================ */
.auth__field {
    margin-bottom: 16px;
}

.auth__label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--auth-text);
    margin-bottom: 6px;
}

.auth__input {
    width: 100%;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 15px;
    color: var(--auth-text);
    background: var(--auth-surface-elevated);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-md);
    transition: border-color var(--auth-transition-fast), box-shadow var(--auth-transition-fast);
}

.auth__input::placeholder {
    color: var(--auth-text-muted);
}

.auth__input:focus {
    outline: none;
    border-color: var(--auth-border-focus);
    box-shadow: 0 0 0 3px rgba(11, 132, 165, 0.15);
}

html.theme-dark .auth__input:focus,
body.theme-dark .auth__input:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.auth__input--error {
    border-color: var(--auth-error);
}

.auth__input--error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.auth__hint {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--auth-text-muted);
}

.auth__error {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--auth-error);
}

/* ============================================================
   Auth Modal - Password Validation
   ============================================================ */
.auth__password-rules {
    margin-top: 12px;
    padding: 12px;
    background: var(--auth-surface);
    border-radius: var(--auth-radius-sm);
}

.auth__password-rule {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--auth-text-muted);
    margin-bottom: 6px;
}

.auth__password-rule:last-child {
    margin-bottom: 0;
}

.auth__password-rule--valid {
    color: var(--auth-success);
}

.auth__password-rule--invalid {
    color: var(--auth-error);
}

.auth__rule-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ============================================================
   Auth Modal - Submit Button
   ============================================================ */
.auth__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: #FFFFFF;
    background: var(--auth-accent);
    border: none;
    border-radius: var(--auth-radius-md);
    cursor: pointer;
    transition: background var(--auth-transition-fast), opacity var(--auth-transition-fast);
    margin-top: 20px;
}

.auth__submit:hover:not(:disabled) {
    background: var(--auth-accent-hover);
}

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

.auth__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

html.theme-dark .auth__submit,
body.theme-dark .auth__submit {
    background: #f2f2f2;
    color: #141414;
}

html.theme-dark .auth__submit:hover:not(:disabled),
body.theme-dark .auth__submit:hover:not(:disabled) {
    background: #ffffff;
}

html.theme-dark .auth__submit:focus-visible,
body.theme-dark .auth__submit:focus-visible {
    outline-color: #707070;
}

/* ============================================================
   Auth Modal - Switch Link
   ============================================================ */
.auth__switch {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--auth-text-secondary);
}

.auth__switch-link {
    color: var(--auth-accent);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.auth__switch-link:hover {
    text-decoration: underline;
}

/* ============================================================
   Auth Modal - Consent
   ============================================================ */
.auth__consent {
    margin-top: 16px;
    font-size: 12px;
    color: var(--auth-text-muted);
    text-align: center;
    line-height: 1.5;
}

.auth__consent a {
    color: var(--auth-text-secondary);
    text-decoration: underline;
}

.auth__consent a:hover {
    color: var(--auth-text);
}

/* ============================================================
   Auth Modal - Form Error Message
   Positioned OUTSIDE form, between form/buttons and switch link
   Takes up space and pushes content down when visible
   ============================================================ */
.auth__form-error {
    /* Hidden by default - no space taken */
    display: none;
    padding: 12px 14px;
    margin: 20px 0 0 0;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--auth-error);
    border-radius: var(--auth-radius-md);
    color: var(--auth-error);
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
}

.auth__form-error--visible {
    display: block;
}

html.theme-dark .auth__form-error,
body.theme-dark .auth__form-error {
    background: rgba(248, 113, 113, 0.12);
}

/* ============================================================
   Auth Modal - Loading Spinner
   ============================================================ */
.auth__spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: auth-spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes auth-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   Auth Modal - Login vs Signup Views
   ============================================================ */
.auth__view {
    display: none;
}

.auth__view--active {
    display: block;
}

/* Name field - only visible in signup */
.auth__field--name {
    display: none;
}

.auth__view--signup .auth__field--name {
    display: block;
}

/* Password rules - only visible in signup */
.auth__password-rules {
    display: none;
}

.auth__view--signup .auth__password-rules {
    display: block;
}

/* ============================================================
   Mobile Responsiveness - Bottom Sheet
   ============================================================ */
@media (max-width: 540px) {
    .auth-modal {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translateY(100%);
        max-width: none;
        max-height: 90vh;
        border-radius: var(--auth-radius-lg) var(--auth-radius-lg) 0 0;
    }
    
    .auth-modal--open {
        transform: translateY(0);
    }
    
    .auth-modal__content {
        padding: 32px 24px 40px;
    }
    
    .auth-modal__close {
        top: 12px;
        right: 12px;
    }
    
    /* Bottom sheet handle */
    .auth-modal::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--auth-border);
        border-radius: var(--auth-radius-full);
    }
    
    .avatar-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        min-width: auto;
        border-radius: var(--auth-radius-lg) var(--auth-radius-lg) 0 0;
        transform: translateY(100%);
    }
    
    .avatar-dropdown--open {
        transform: translateY(0);
    }
}

/* Tablet and up */
@media (min-width: 541px) {
    .auth-topbar__btn {
        padding: 8px 20px;
    }
}

/* ============================================================
   Utility Classes
   ============================================================ */
.auth--hidden {
    display: none !important;
}

/* Screen reader only */
.auth-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus trap helper */
[data-focus-trap] {
    outline: none;
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
    .auth-modal-overlay,
    .auth-modal,
    .auth-topbar,
    .avatar-container {
        display: none !important;
    }
}
