
:root {
    --primary: #005555;
    --primary-light: #007777;
    --primary-dark: #003f3f;
    --text-primary: #1f2937;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --hover: #f3f4f6;
    --white: #ffffff;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --grad-1: #10b981;
    --grad-2: #059669;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gold: #fbbf24;
    --online: #10b981;
    --online-dark: #059669;
    --typing: #499f6a;
    --offline: #6b7280;
    --accent: #005555;
    --radius: 12px;
    --radius-lg: 1.5rem;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.08);
    --input-bg: var(--bg-primary);
    --primary-rgb: 0, 85, 85;
    --info: #3b82f6;
    --success-text-rgb: 5, 150, 105;
    --danger-text-rgb: 220, 38, 38;
}

[data-theme="dark"] {
    --primary: #003f3f;
    --primary-light: #006666;
    --primary-dark: #002f2f;
    --text-primary: #f3f4f6;
    --text-muted: #9ca3af;
    --border: #374151;
    --hover: #1f2937;
    --white: #f9fafb;
    --bg-primary: #111827;
    --bg-secondary: #0f172a;
    --grad-1: #059669;
    --grad-2: #047857;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gold: #fbbf24;
    --online: #10b981;
    --online-dark: #045967;
    --typing: #499f6a;
    --offline: #6b7280;
    --accent: #006666;
    --input-bg: #1f2937;
    --primary-rgb: 0, 63, 63;
    --info: #60a5fa;
    --success-text-rgb: 52, 211, 153;
    --danger-text-rgb: 248, 113, 113;
}
html,
body {
    overflow-y: auto !important;
}

body.form-page-body {
        margin: 0;
        font-family: 'Inter', system-ui, sans-serif;
        background: var(--bg-page, var(--bg-secondary));
        color: var(--text, var(--text-primary));
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding: 1.5rem;
    }

    .form-container {
        width: 100%;
        max-width: 420px;
        margin: 1rem 0;
    }

    .form-card {
        background: var(--bg, var(--bg-primary));
        border-radius: 1.25rem;
        padding: 2.5rem 2rem;
        box-shadow: var(--shadow);
        border: 1px solid var(--border);
    }
    .logo-container {
        text-align: center;
        margin-bottom: 1.75rem;
    }

    .logo-img {
        max-width: 140px;
        height: auto;
        display: block;
        margin: 0 auto;
    }
    
    .welcome-title {
        font-size: 1.875rem;
        font-weight: 700;
        text-align: center;
        margin: 0 0 0.5rem;
        color: var(--text, var(--text-primary));
    }

    .welcome-subtitle {
        text-align: center;
        color: var(--muted, var(--text-muted));
        margin: 0 0 2.25rem;
        font-size: 0.95rem;
    }

    .form-group {
        position: relative;
        margin-bottom: 1.25rem;
    }

    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem;
    }

    .form-group input {
        width: 100%;
        padding: 0.95rem 1rem 0.95rem 2.8rem;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        font-size: 0.95rem;
        background: var(--bg, var(--bg-primary));
        transition: border-color 0.2s, box-shadow 0.2s;
    }

    .form-group input:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
    }

    .input-icon {
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--muted, var(--text-muted));
        font-size: 1.1rem;
        pointer-events: none;
    }

    .password-wrapper {
        position: relative;
    }

    .toggle-password {
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        color: var(--muted, var(--text-muted));
        font-size: 1.1rem;
        cursor: pointer;
        padding: 0;
    }

    label {
        position: absolute;
        left: 1.30rem;
        top: 50%;
        transform: translateY(-50%);
        padding: 0 0.1rem;
        color: var(--muted, var(--text-muted));
        font-size: 0.95rem;
        pointer-events: none;
        transition: all 0.2s ease;
    }

    .form-group.has-value label,
    .form-group input:focus + label,
    .form-group:focus-within label {
        top: 0;
        transform: translateY(-50%);
        background: var(--bg, var(--bg-primary));
        padding: 0 0.35rem;
        z-index: 1;
        font-size: 0.75rem;
        color: var(--primary);
    }

    .form-group input::placeholder {
        color: transparent;
    }

    .password-strength {
        width: 100%;
        height: 6px;
        margin-top: 0.55rem;
        border-radius: 999px;
        background: #e5e7eb;
        overflow: hidden;
    }

    .password-strength-fill {
        width: 0%;
        height: 100%;
        border-radius: 999px;
        transition: width 0.25s ease, background-color 0.25s ease;
    }

    .password-strength-text {
        margin-top: 0.35rem;
        font-size: 0.82rem;
        font-weight: 600;
    }

    .password-rules {
        margin: 0.5rem 0 0;
        padding: 0;
        list-style: none;
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .password-rules li {
        font-size: 0.78rem;
        color: var(--muted, var(--text-muted));
    }

    .password-rules li.met {
        color: #059669;
    }

    .password-rules li.unmet {
        color: #9ca3af;
    }

    .forgot-row {
        text-align: right;
        margin: -0.5rem 0 1.25rem;
    }

    .forgot-link {
        color: var(--primary);
        font-size: 0.875rem;
        text-decoration: none;
        font-weight: 500;
    }

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

    .btn-signin {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        font-weight: 600;
        color: white;
        background: var(--primary);
        border: none;
        border-radius: var(--radius);
        cursor: pointer;
        transition: background 0.2s, transform 0.2s;
    }

    .btn-signin:hover {
        background: var(--primary-dark);
        transform: translateY(-1px);
    }

    .divider {
        text-align: center;
        margin: 1.75rem 0;
        color: var(--muted, var(--text-muted));
        font-size: 0.8rem;
        font-weight: 600;
        position: relative;
    }

    .divider span {
        background: var(--bg, var(--bg-primary));
        padding: 0 1.25rem;
        position: relative;
        z-index: 1;
    }

    .divider::before {
        content: "";
        position: absolute;
        left: 0; right: 0; top: 50%;
        height: 1px;
        background: var(--border);
        z-index: 0;
    }

    .btn-magic-link {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        font-weight: 600;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        color: var(--primary);
        background: rgba(22,163,74,0.08);
        border: 1px solid rgba(22,163,74,0.3);
        border-radius: var(--radius);
        cursor: pointer;
        transition: all 0.2s;
    }

    .btn-magic-link:hover {
        background: rgba(22,163,74,0.15);
        border-color: var(--primary);
    }

    .quick-access-toggle {
        text-align: center;
        margin: 1.25rem 0 2rem;
        font-size: 0.95rem;
    }

    .toggle-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.45rem;
        padding: 0.65rem 1rem;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--bg, var(--bg-primary));
        color: var(--primary);
        font-weight: 600;
        text-decoration: none;
        transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    }

    .toggle-link:hover {
        background: var(--hover);
        border-color: #b9bcc2;
    }

    .register-text {
        text-align: center;
        color: var(--muted, var(--text-muted));
        font-size: 0.9rem;
        margin: 0;
    }

    .register-text a {
        color: var(--primary);
        font-weight: 600;
        text-decoration: none;
    }

    .footer-text {
        text-align: center;
        color: var(--muted, var(--text-muted));
        font-size: 0.9rem;
        margin-top: 1rem;
    }

    .footer-text a {
        color: var(--primary);
        font-weight: 600;
        text-decoration: none;
    }

    .btn-magic {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        font-weight: 600;
        color: white;
        background: var(--primary);
        border: none;
        border-radius: var(--radius);
        cursor: pointer;
        transition: background 0.2s, transform 0.2s;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }

    .btn-magic:hover {
        background: var(--primary-dark);
        transform: translateY(-1px);
    }

    @media (max-width: 768px) {
        body.form-page-body {
            padding: 1rem;
        }

        .form-container {
            max-width: 100%;
            margin: 0.5rem 0;
        }

        .form-card {
            padding: 1.75rem 1.25rem;
            border-radius: 1rem;
        }

        .welcome-title {
            font-size: 1.55rem;
        }

        .welcome-subtitle {
            font-size: 0.9rem;
            margin-bottom: 1.4rem;
        }

        .form-group {
            margin-bottom: 1rem;
        }

        .form-group input {
            font-size: 16px;
        }

        .btn-signin,
        .btn-magic-link,
        .btn-magic {
            font-size: 0.95rem;
            padding: 0.9rem;
        }

        .quick-access-toggle {
            margin: 1rem 0 1.5rem;
        }

        .form-row {
            grid-template-columns: 1fr;
            gap: 0.6rem;
        }
    }

    @media (max-width: 480px) {
        body.form-page-body {
            padding: 0.75rem;
        }

        .form-card {
            padding: 1.4rem 1rem;
        }

        .logo-img {
            max-width: 118px;
        }

        .welcome-title {
            font-size: 1.35rem;
        }

        .toggle-link {
            width: 100%;
        }
    }

/* Dark mode specific overrides */
[data-theme="dark"] .form-page-body .form-container .form-group input:focus + label,
[data-theme="dark"] .form-page-body .form-container .form-group.has-value label,
[data-theme="dark"] .form-page-body .form-container .password-wrapper input:focus + label,
[data-theme="dark"] .form-page-body .form-container .password-wrapper.has-value label {
    background: var(--bg-primary);
}

/* Smooth transitions for form switching */
#magic-link-form,
#password-form {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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