/* ========================================
   AUTH MODAL - Compact iOS Design
   ======================================== */

/* Overlay */
.auth-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: linear-gradient(to bottom right, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.95));
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.auth-modal-overlay.active {
    display: flex;
    animation: authOverlayIn 0.3s ease-out;
}

@keyframes authOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Container - compact with safe areas */
.auth-modal-container {
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    padding-top: max(env(safe-area-inset-top, 20px), 40px);
    padding-bottom: max(env(safe-area-inset-bottom, 20px), 30px);
    box-sizing: border-box;
}

/* Background effects - subtle */
.auth-bg-grid,
.auth-bg-gradient {
    display: none;
}

/* Logo section - compact */
.auth-branding {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
    animation: authBrandIn 0.4s ease-out 0.05s backwards;
}

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

.auth-logo-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(16, 185, 129, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.auth-logo-glow {
    display: none;
}

.auth-logo {
    width: 40px;
    height: 40px;
}

.auth-title,
.auth-subtitle {
    display: none;
}

/* Form wrapper */
.auth-form-wrapper {
    width: 100%;
    max-width: 360px;
    animation: authFormIn 0.4s ease-out 0.1s backwards;
}

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

/* Form container - card style */
.auth-form-container {
    padding: 24px 20px;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-form-title {
    font-size: 20px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 4px 0;
    text-align: center;
}

.auth-form-subtitle {
    color: #94a3b8;
    font-size: 14px;
    margin: 0 0 20px 0;
    text-align: center;
}

/* Error */
.auth-error {
    display: none;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 14px;
    animation: authErrorIn 0.35s ease-out;
}

@keyframes authErrorIn {
    0% { opacity: 0; transform: translateY(-6px); }
    60% { opacity: 1; transform: translateY(2px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Inputs */
.auth-input-group {
    margin-bottom: 14px;
}

.auth-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.auth-label i {
    color: #10b981;
    font-size: 12px;
}

.auth-input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    color: #f8fafc;
    font-size: 16px;
    font-weight: 500;
    box-sizing: border-box;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.auth-input::placeholder {
    color: #64748b;
}

.auth-input:focus {
    border-color: #10b981;
    outline: none;
    background: rgba(15, 23, 42, 0.7);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

/* Submit button */
.auth-submit-btn {
    width: 100%;
    height: 50px;
    padding: 0 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.auth-submit-btn:active {
    opacity: 0.92;
    transform: scale(0.98);
}

.auth-submit-btn:disabled {
    opacity: 0.5;
}

/* Divider */
.auth-divider {
    position: relative;
    text-align: center;
    margin: 20px 0;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(148, 163, 184, 0.15);
}

.auth-divider span {
    position: relative;
    background: rgba(30, 41, 59, 0.8);
    padding: 0 12px;
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

/* Toggle buttons */
.auth-toggle-btn {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    color: #cbd5e1;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.auth-toggle-btn:active {
    background: rgba(255, 255, 255, 0.04);
    transform: scale(0.99);
}

.auth-toggle-btn strong {
    color: #10b981;
}

/* Forgot button */
.auth-forgot-btn {
    width: 100%;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 14px;
    margin-top: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Back button */
.auth-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 12px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.auth-back-btn:active {
    opacity: 0.8;
}

/* Footer */
.auth-footer {
    text-align: center;
    margin-top: 20px;
}

.auth-footer p {
    color: #475569;
    font-size: 11px;
    margin: 0;
}

/* View transitions (main ↔ form) */
#authMainView,
#authForm {
    animation: authViewIn 0.3s ease-out;
}

@keyframes authViewIn {
    from { opacity: 0; transform: translateX(8px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.auth-oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 50px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.auth-oauth-btn:active {
    opacity: 0.9;
    transform: scale(0.98);
}

.auth-oauth-btn i,
.auth-oauth-btn svg {
    font-size: 18px;
}

.apple-btn {
    background: #000;
    border: none;
    color: #fff;
}

.google-btn {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #1f2937;
}

/* ========================================
   LIGHT THEME
   ======================================== */

body.light-theme .auth-modal-overlay {
    background: linear-gradient(to bottom right, rgba(241, 245, 249, 0.98), rgba(226, 232, 240, 0.98), rgba(241, 245, 249, 0.98));
}

body.light-theme .auth-logo-wrapper {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.15);
}

body.light-theme .auth-form-container {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .auth-form-title {
    color: #1e293b;
}

body.light-theme .auth-form-subtitle {
    color: #64748b;
}

body.light-theme .auth-label {
    color: #475569;
}

body.light-theme .auth-input {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(148, 163, 184, 0.2);
    color: #1e293b;
}

body.light-theme .auth-input:focus {
    background: #fff;
}

body.light-theme .auth-divider span {
    background: rgba(255, 255, 255, 0.9);
}

body.light-theme .auth-toggle-btn {
    border-color: rgba(148, 163, 184, 0.2);
    color: #475569;
}

body.light-theme .auth-forgot-btn,
body.light-theme .auth-back-btn {
    color: #94a3b8;
}

body.light-theme .auth-footer p {
    color: #94a3b8;
}

/* ========================================
   REDUCE MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .auth-modal-overlay.active,
    .auth-branding,
    .auth-form-wrapper,
    .auth-error,
    #authMainView,
    #authForm {
        animation: none;
    }
    .auth-input,
    .auth-submit-btn,
    .auth-toggle-btn,
    .auth-oauth-btn,
    .auth-back-btn {
        transition: none;
    }
}

/* ========================================
   LOADING
   ======================================== */

.auth-loading {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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