/* =========================================
   1. VARIABLES & THEME SETUP
   ========================================= */
:root {
    --primary-color: #256dd9;
    --bg-light: #f0f2f5;
    --bg-dark: #000000;
    --text-light: #111827;
    --text-dark: #ffffff;
    --glass-bg-light: rgba(255, 255, 255, 0.65);
    --glass-bg-dark: rgba(0, 0, 0, 0.4);
    --glass-border: rgba(255, 255, 255, 0.2);
    --error-color: #ef4444;
    --success-color: #10b981;
}

/* =========================================
   2. GLOBAL RESET & BODY
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-light);
    min-height: 100vh;
    width: 100vw;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    transition: background-color 0.3s ease, color 0.3s ease;
    position: relative;
}

html.dark body { background-color: var(--bg-dark); color: var(--text-dark); }

/* Background Waves */
.bg-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.wave { position: absolute; width: 200vw; height: 200vw; opacity: 0.4; left: -50%; top: 10%; transform: translate(-80%,-80%); background: linear-gradient(744deg, #090933, #1b6ae0 60%, #00ddeb); border-radius: 30%; animation: bg-wave 15s infinite linear; }
html:not(.dark) .wave { opacity: 0.3; }
.wave:nth-child(2) { animation-duration: 20s; opacity: 0.3; }
@keyframes bg-wave { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* =========================================
   3. UTILITIES & ANIMATIONS
   ========================================= */
.main-container {
    width: 100%;
    max-width: 480px;
    padding: 20px;
    margin-top: clamp(60px, 12vh, 150px);
    margin-bottom: 50px;
    z-index: 10;
}

.glass-card {
    background: var(--glass-bg-light);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
    padding: 20px 30px 30px 30px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}
html.dark .glass-card {
    background: var(--glass-bg-dark);
    border-color: var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Views Management */
.view-section { display: none; animation: fadeIn 0.4s ease; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Header Logo */
.auth-header {
    text-align: center;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.auth-header .logo-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
    color: var(--primary-color);
}
.auth-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.1;
    margin: 0;
    color: var(--text-light);
}
.auth-header span {
    font-size: 0.87rem;
    font-weight: 500;
    opacity: 0.7;
    display: block;
    margin-top: 2px;
    letter-spacing: 0.5px;
}
html.dark .auth-header h1 {
    color: var(--text-dark);
}

/* Toggle Tabs */
.toggle-box {
    position: relative; display: flex;
    background: rgba(0,0,0,0.05); border-radius: 12px;
    padding: 4px; margin-bottom: 25px;
}
html.dark .toggle-box { background: rgba(255,255,255,0.05); }
.toggle-btn {
    flex: 1; padding: 10px; border: none; background: transparent;
    color: inherit; font-weight: 600; cursor: pointer; z-index: 2;
    transition: color 0.3s; opacity: 0.6;
}
.toggle-btn.active { opacity: 1; }
.slider {
    position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: calc(100% - 8px);
    background: var(--glass-bg-light); border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
}
html.dark .slider { background: #2a2a2a; }

/* SLIDING FORMS CSS */
.forms-wrapper { 
    position: relative; 
    overflow: hidden; 
    width: 100%;
}

.forms-slider {
    display: flex;
    width: 200%;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.form-content { 
    width: 50%; 
    padding: 2px; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    flex-shrink: 0; 
    position: relative;
}

/* States for Sliding */
.forms-wrapper.show-login .forms-slider {
    transform: translateX(0);
}

.forms-wrapper.show-signup .forms-slider {
    transform: translateX(-50%);
}

/* Slide Logic for Toggle Box */
.signup-mode .slider { transform: translateX(100%); }

/* Loading Screen & Spinner */
#loading-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg-light);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.5s ease;
}
html.dark #loading-screen { background: var(--bg-dark); }
.spinner {
    width: 40px; height: 40px; border: 3px solid rgba(37, 109, 217, 0.1);
    border-left-color: var(--primary-color); border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Button Spinner */
.btn-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-left-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Ensure submit button maintains size while loading */
.submit-btn.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    opacity: 0.8;
}

/* =========================================
   4. COMPONENTS (Forms, Buttons, Inputs)
   ========================================= */
/* Inputs */
.input-group { position: relative; }
.input-field {
    width: 100%; padding: 14px 40px 14px 44px;
    border-radius: 14px; border: 1px solid transparent;
    background: rgba(255,255,255,0.6);
    color: var(--text-light); font-size: 0.95rem;
    transition: 0.2s;
}
html.dark .input-field { background: rgba(255,255,255,0.08); color: var(--text-dark); }
.input-field:focus { background: #fff; box-shadow: 0 0 0 2px var(--primary-color); }
html.dark .input-field:focus { background: rgba(0,0,0,0.5); }

input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    transition: background-color 5000s ease-in-out 0s;
    -webkit-text-fill-color: var(--text-light) !important;
    -webkit-box-shadow: 0 0 0px 1000px transparent inset !important;
}
html.dark input:-webkit-autofill,
html.dark input:-webkit-autofill:hover, 
html.dark input:-webkit-autofill:focus, 
html.dark input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text-dark) !important;
    caret-color: var(--text-dark);
}

.input-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 20px; height: 20px; opacity: 0.5; pointer-events: none;
}

.toggle-password {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    cursor: pointer; opacity: 0.5; transition: 0.2s; background: none; border: none; padding: 0; color: inherit;
}
.toggle-password:hover { opacity: 1; }

.remember-me { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; margin-top: -5px; opacity: 0.8; cursor: pointer; }
.remember-me input { width: 16px; height: 16px; accent-color: var(--primary-color); cursor: pointer; }

.welcome-msg {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
    text-align: center;
    opacity: 0.9;
}

.options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 0.85rem;
    margin-top: 16.5px;
    margin-bottom: 16px;
    padding: 0 5px;
}
.forgot-password {
    color: var(--primary-color);
    text-decoration: none;
    opacity: 0.8;
}
.forgot-password:hover {
    text-decoration: underline;
    opacity: 1;
}

.signup-step {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.next-btn {
    margin-top: 5px;
}
.back-btn {
    position: absolute;
    top: 4px;
    left: 5px;
    background: transparent;
    border: none;
    padding: 0;
    color: #ffffff;
    cursor: pointer;
    z-index: 10;
    opacity: 0.9;
}
.back-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.submit-btn {
    width: 100%; padding: 14px; border-radius: 14px; border: none;
    background: var(--primary-color); color: white; font-weight: 700;
    cursor: pointer; transition: 0.2s; margin-top: 5px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.submit-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.google-btn {
    width: 100%; padding: 12px; margin-top: 20px;
    border-radius: 14px; border: 1px solid rgba(128,128,128,0.2);
    background: rgba(255,255,255,0.3); color: inherit;
    font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: 0.2s;
}
html.dark .google-btn { background: rgba(255,255,255,0.05); }
.google-btn:hover { background: rgba(255,255,255,0.5); }
html.dark .google-btn:hover { background: rgba(255,255,255,0.1); }

.status-msg {
    font-size: 0.85rem; text-align: center; margin-top: 15px;
    min-height: 20px; opacity: 0; transition: opacity 0.3s;
    padding: 8px; border-radius: 8px;
}
.status-msg.error { background: rgba(239, 68, 68, 0.1); color: var(--error-color); }
.status-msg.success { background: rgba(16, 185, 129, 0.1); color: var(--success-color); }

.verify-icon {
    width: 60px; height: 60px; border-radius: 50%; background: rgba(37, 109, 217, 0.1);
    color: var(--primary-color); display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px auto;
}
.verify-text { text-align: center; margin-bottom: 25px; line-height: 1.6; opacity: 0.8; }
.timer-text { font-size: 0.8rem; opacity: 0.6; text-align: center; margin-top: 5px; }

/* Blue Header Frame */
.header-frame {
    background-color: var(--primary-color);
    border-radius: 20px;
    padding: 40px 20px 10px 20px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(37, 109, 217, 0.3);
    margin-left: -10px;
    margin-right: -10px;
}

.header-frame .auth-header h1,
.header-frame .auth-header span {
    color: #ffffff !important;
}

.header-frame .auth-header .logo-icon {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px;
    width: auto;
    height: auto;
    display: inline-block;
}
.header-frame .auth-header .logo-icon svg {
    width: 40px;
    height: 40px;
}

/* Customize toggle box inside header frame */
.header-frame .toggle-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.header-frame .toggle-btn {
    color: rgba(255, 255, 255, 0.7);
}
.header-frame .toggle-btn.active {
    color: var(--primary-color);
}

.header-frame .slider {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-frame .auth-header {
    margin-bottom: 20px;
}

/* =========================================
   5. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 767px) {
    .main-container {
        margin-top: 20px;
        padding: 15px;
        max-width: 100%;
    }
}