/* =========================================================================
   LOGIN — DENTAL CLINIC PREMIUM
   Warm, professional, trustworthy. High-end dental practice aesthetic.
   Teal accent · Warm whites · Champagne details · Organic softness.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dental Brand Palette */
    --teal: #0d9488;
    --teal-light: #14b8a6;
    --teal-deep: #0f766e;
    --champagne: #d4a574;
    --champagne-light: #e8c9a0;
    --champagne-subtle: rgba(212, 165, 116, 0.08);

    /* Physics */
    --spring: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    --spring-bouncy: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    /* Light Mode — Warm Cream */
    --bg-base: #faf8f5;
    --bg-warm: #f5f0ea;
    --card-bg: rgba(255, 255, 255, 0.82);
    --text-primary: #1a1a1a;
    --text-secondary: #5c5a56;
    --text-muted: #9c9890;
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: rgba(0, 0, 0, 0.07);
    --input-focus-border: var(--teal);
    --label-color: #6b6963;
    --footer-border: rgba(0, 0, 0, 0.05);
    --divider: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-base: #0c0c0e;
    --bg-warm: #151517;
    --card-bg: rgba(22, 22, 26, 0.75);
    --text-primary: #f0ece6;
    --text-secondary: #a09c94;
    --text-muted: #6b6963;
    --input-bg: rgba(0, 0, 0, 0.35);
    --input-border: rgba(255, 255, 255, 0.07);
    --input-focus-border: var(--teal-light);
    --label-color: #a09c94;
    --footer-border: rgba(255, 255, 255, 0.05);
    --divider: rgba(255, 255, 255, 0.05);
}

/* -------------------------------------------------------------------------
   1. BODY — WARM AMBIENT GLOW
   ------------------------------------------------------------------------- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text-primary);
    padding: 20px;
    margin: 0;
    position: relative;
    overflow: hidden;
}

/* Warm organic ambient — soft teal and champagne orbs */
body::before {
    content: '';
    position: fixed;
    top: -40%;
    left: -40%;
    width: 180%;
    height: 180%;
    background:
        radial-gradient(ellipse at 25% 25%, rgba(13, 148, 136, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 20%, rgba(212, 165, 116, 0.1) 0%, transparent 45%),
        radial-gradient(ellipse at 65% 80%, rgba(13, 148, 136, 0.08) 0%, transparent 45%),
        radial-gradient(ellipse at 20% 75%, rgba(212, 165, 116, 0.06) 0%, transparent 40%);
    animation: warmDrift 30s ease-in-out infinite alternate;
    z-index: 0;
    will-change: transform;
    /* A2: GPU layer promotion for smooth animation */
}

/* Secondary subtle layer */
body::after {
    content: '';
    position: fixed;
    top: -30%;
    left: -30%;
    width: 160%;
    height: 160%;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(245, 240, 234, 0.4) 0%, transparent 50%);
    animation: warmDrift 30s ease-in-out infinite alternate-reverse;
    z-index: 0;
    will-change: transform;
    /* A2: GPU layer promotion for smooth animation */
}

@keyframes warmDrift {
    0% {
        transform: translate(0%, 0%) rotate(0deg);
    }

    50% {
        transform: translate(2%, -1.5%) rotate(0.5deg);
    }

    100% {
        transform: translate(-1%, 1%) rotate(-0.5deg);
    }
}

[data-theme="dark"] body::before {
    background:
        radial-gradient(ellipse at 25% 25%, rgba(13, 148, 136, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 20%, rgba(212, 165, 116, 0.06) 0%, transparent 45%),
        radial-gradient(ellipse at 65% 80%, rgba(13, 148, 136, 0.06) 0%, transparent 45%),
        radial-gradient(ellipse at 20% 75%, rgba(212, 165, 116, 0.04) 0%, transparent 40%);
}

[data-theme="dark"] body::after {
    background:
        radial-gradient(ellipse at 50% 40%, rgba(22, 22, 26, 0.6) 0%, transparent 50%);
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

/* Focus Indicators WCAG */
*:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

button:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

input:focus-visible {
    outline: none;
}

/* -------------------------------------------------------------------------
   2. LOGIN CONTAINER
   ------------------------------------------------------------------------- */
.login-container {
    width: 100%;
    max-width: 480px;
    position: relative;
    z-index: 1;
    animation: cardEntrance 0.9s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    will-change: transform, opacity;
    /* A2: GPU layer promotion */
}

/* A1: Glow lives on the container (outside card's overflow:hidden) */
.login-container::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 31px;
    background: linear-gradient(150deg,
            rgba(13, 148, 136, 0.25),
            rgba(20, 184, 166, 0.15),
            rgba(212, 165, 116, 0.15),
            rgba(13, 148, 136, 0.1));
    z-index: -1;
    filter: blur(20px);
    opacity: 0.7;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .login-container::before {
    background: linear-gradient(150deg,
            rgba(13, 148, 136, 0.2),
            rgba(20, 184, 166, 0.12),
            rgba(212, 165, 116, 0.1),
            rgba(13, 148, 136, 0.08));
    filter: blur(32px);
    opacity: 0.6;
}

.login-container:hover::before {
    opacity: 0.95;
    filter: blur(24px);
}

[data-theme="dark"] .login-container:hover::before {
    opacity: 0.8;
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.97);
        /* filter: blur removed — it creates a stacking context that blocks
           pointer events on child elements (like the theme toggle) during animation */
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* -------------------------------------------------------------------------
   3. CARD — FROSTED GLASS WITH WARM TEAL AURA
   ------------------------------------------------------------------------- */
.login-card {
    position: relative;
    background: var(--card-bg);
    backdrop-filter: blur(60px) saturate(160%);
    -webkit-backdrop-filter: blur(60px) saturate(160%);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow:
        0 1px 0 0 rgba(255, 255, 255, 0.5) inset,
        0 20px 60px rgba(0, 0, 0, 0.06),
        0 8px 24px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    /* Clips the header accent line cleanly */
    /* A3: Specific transitions instead of 'all' to prevent flicker */
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        border-color 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* A1: Glow moved to .login-container::before (see section 2) */

[data-theme="dark"] .login-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 1px 0 0 rgba(255, 255, 255, 0.04) inset,
        0 32px 80px rgba(0, 0, 0, 0.5),
        0 12px 32px rgba(0, 0, 0, 0.3);
}

.login-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.28);
}

[data-theme="dark"] .login-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

/* -------------------------------------------------------------------------
   4. CARD HEADER — CHAMPAGNE ACCENT LINE + TEAL WASH
   ------------------------------------------------------------------------- */
.card-header {
    padding: 44px 48px 28px;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-radius: 28px 28px 0 0;
    /* Match the card's top radius to clip the line cleanly */
}

/* Elegant teal-to-champagne gradient line at top */
.card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
            var(--teal),
            var(--teal-light),
            var(--champagne),
            var(--champagne-light),
            var(--teal-light));
    background-size: 200% 100%;
    animation: accentSlide 8s ease infinite;
    border-radius: 28px 28px 0 0;
}

@keyframes accentSlide {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

/* Soft warm wash behind header content */
.card-header::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(180deg,
            rgba(13, 148, 136, 0.04),
            transparent);
    pointer-events: none;
    z-index: 5;
    /* Explicitly below .theme-toggle (z-index: 20) */
}

[data-theme="dark"] .card-header::after {
    background: linear-gradient(180deg,
            rgba(13, 148, 136, 0.06),
            transparent);
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
    padding: 0;
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    transition: var(--spring);
    z-index: 20;
    /* Raised above ::after overlay (z-index: 5) */
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .theme-toggle {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.07);
    color: #a09c94;
}

.theme-toggle:hover {
    background: rgba(13, 148, 136, 0.08);
    border-color: rgba(13, 148, 136, 0.2);
    color: var(--teal);
    transform: scale(1.08) rotate(12deg);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(20, 184, 166, 0.1);
    border-color: rgba(20, 184, 166, 0.2);
    color: var(--teal-light);
}

/* -------------------------------------------------------------------------
   5. LOGO — WARM GLASS WITH TEAL GLOW RING
   ------------------------------------------------------------------------- */
.logo-wrapper {
    position: relative;
    z-index: 2;
    margin-bottom: 20px;
}

.logo {
    width: 96px;
    height: 96px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow:
        0 10px 32px rgba(13, 148, 136, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.05),
        inset 0 1px 2px rgba(255, 255, 255, 1),
        inset 0 -1px 2px rgba(0, 0, 0, 0.01);
    animation: logoEntrance 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.15s backwards;
    transition: var(--spring-bouncy);
    will-change: transform;
    /* A2: GPU layer promotion */
}

/* Teal-champagne ring glow */
.logo::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 24px;
    background: linear-gradient(145deg,
            rgba(13, 148, 136, 0.35),
            rgba(212, 165, 116, 0.25),
            rgba(20, 184, 166, 0.3));
    z-index: -1;
    opacity: 0.5;
    transition: var(--spring);
}

[data-theme="dark"] .logo {
    background: rgba(18, 18, 22, 0.9);
    box-shadow:
        0 10px 32px rgba(13, 148, 136, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.06),
        inset 0 -1px 2px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .logo::after {
    background: linear-gradient(145deg,
            rgba(13, 148, 136, 0.3),
            rgba(212, 165, 116, 0.2),
            rgba(20, 184, 166, 0.25));
    opacity: 0.45;
}

.logo:hover {
    transform: scale(1.05) translateY(-3px);
}

.logo:hover::after {
    opacity: 0.9;
    filter: blur(4px);
    inset: -4px;
}

@keyframes logoEntrance {
    from {
        opacity: 0;
        transform: scale(0.75) translateY(16px);
        filter: blur(6px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

.logo img {
    width: 62px;
    height: 62px;
    object-fit: contain;
}

/* -------------------------------------------------------------------------
   6. TYPOGRAPHY — WARM + PROFESSIONAL
   ------------------------------------------------------------------------- */
.card-header h1 {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
}

.card-header p {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

/* -------------------------------------------------------------------------
   7. CARD BODY
   ------------------------------------------------------------------------- */
.card-body {
    padding: 36px 48px 44px;
    position: relative;
}

/* Subtle teal-champagne divider */
.card-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 32px;
    right: 32px;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            var(--divider) 15%,
            rgba(13, 148, 136, 0.1) 40%,
            rgba(212, 165, 116, 0.08) 60%,
            var(--divider) 85%,
            transparent);
}

.welcome-message {
    text-align: center;
    margin-bottom: 28px;
}

.welcome-message h2 {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.welcome-message p {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* -------------------------------------------------------------------------
   8. FORM — WARM INPUTS
   ------------------------------------------------------------------------- */
.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--label-color);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    opacity: 0.35;
    pointer-events: none;
    z-index: 10;
    transition: var(--spring);
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-secondary);
    transition: var(--spring);
}

/* A6: Robust selectors using :has() — no dependency on HTML sibling order */
.input-wrapper:has(input:focus) .input-icon {
    opacity: 0.8;
}

.input-wrapper:has(input:focus) .input-icon svg {
    stroke: var(--teal);
}

[data-theme="dark"] .input-icon {
    opacity: 0.4;
}

[data-theme="dark"] .input-wrapper:has(input:focus) .input-icon {
    opacity: 0.9;
}

input[type="password"] {
    width: 100%;
    padding: 16px 22px 16px 50px;
    border-radius: 14px;
    border: 1px solid var(--input-border);
    font-size: 15px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: var(--spring);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

input[type="password"]::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

[data-theme="dark"] input[type="password"]::placeholder {
    color: #6b6963;
}

input[type="password"]:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow:
        0 0 0 3px rgba(13, 148, 136, 0.12),
        0 4px 16px rgba(13, 148, 136, 0.08);
    background: rgba(255, 255, 255, 0.98);
    transform: translateY(-1px);
}

[data-theme="dark"] input[type="password"]:focus {
    background: rgba(18, 18, 22, 0.95);
    box-shadow:
        0 0 0 3px rgba(20, 184, 166, 0.15),
        0 4px 16px rgba(20, 184, 166, 0.08);
}

/* -------------------------------------------------------------------------
   9. BUTTON — TEAL GRADIENT WITH CHAMPAGNE SHIMMER
   ------------------------------------------------------------------------- */
button[type="submit"] {
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Outfit', inherit;
    cursor: pointer;
    background: linear-gradient(135deg, var(--teal-deep), var(--teal), var(--teal-light));
    background-size: 200% 200%;
    animation: btnTeal 5s ease infinite;
    color: white;
    box-shadow:
        0 8px 24px rgba(13, 148, 136, 0.35),
        0 2px 8px rgba(13, 148, 136, 0.15),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
    transition: var(--spring-bouncy);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

@keyframes btnTeal {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

button[type="submit"]:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow:
        0 16px 40px rgba(13, 148, 136, 0.4),
        0 4px 16px rgba(13, 148, 136, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

button[type="submit"]:active {
    transform: translateY(0) scale(0.98);
    box-shadow:
        0 2px 8px rgba(13, 148, 136, 0.25),
        inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

button[type="submit"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    animation: none;
}

/* Champagne shimmer on hover */
button[type="submit"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(212, 165, 116, 0.2),
            rgba(255, 255, 255, 0.15),
            transparent);
    transition: left 0.7s ease;
}

button[type="submit"]:hover::before {
    left: 100%;
}

.button-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

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

button[type="submit"]:disabled .spinner {
    display: block;
}

button[type="submit"]:disabled .button-text {
    display: none;
}

/* -------------------------------------------------------------------------
   10. STATUS MESSAGES
   ------------------------------------------------------------------------- */
.status {
    margin-top: 20px;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    display: none;
    animation: statusSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@keyframes statusSlide {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.status.success {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.18);
    display: block;
}

.status.error {
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.15);
    display: block;
}

[data-theme="dark"] .status.success {
    color: #34d399;
}

[data-theme="dark"] .status.error {
    color: #fb7185;
}

.status::before {
    display: inline-flex;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 20px;
    margin-right: 10px;
    font-weight: bold;
    font-size: 12px;
    vertical-align: middle;
}

.status.success::before {
    content: '✓';
    background: var(--teal);
    color: white;
}

.status.error::before {
    content: '✕';
    background: #ef4444;
    color: white;
}

/* -------------------------------------------------------------------------
   11. FOOTER
   ------------------------------------------------------------------------- */
.footer-note {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--footer-border);
    font-size: 12.5px;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

/* -------------------------------------------------------------------------
   12. RESPONSIVE
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
    body {
        padding: 16px;
    }

    .login-container {
        max-width: 100%;
    }

    /* A5: Match the card radius reduction across all related elements */
    .login-container::before {
        border-radius: 27px;
    }

    .login-card {
        border-radius: 24px;
    }

    .card-header {
        padding: 32px 24px 20px;
        border-radius: 24px 24px 0 0;
        /* A5: Match card's reduced radius */
    }

    .card-header::before {
        border-radius: 24px 24px 0 0;
        /* A5: Match card's reduced radius */
    }

    .card-body {
        padding: 24px 24px 32px;
    }

    .logo {
        width: 76px;
        height: 76px;
        border-radius: 18px;
    }

    .logo img {
        width: 48px;
        height: 48px;
    }

    .card-header h1 {
        font-size: 22px;
    }

    button[type="submit"] {
        padding: 14px 20px;
        font-size: 15px;
    }
}

/* -------------------------------------------------------------------------
   A4. REDUCED MOTION — Accessibility
   Disables all animations for users with motion sensitivity.
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}