/* Login page (Bootstrap 5 layout). Scoped to .login-body so it never leaks into app pages.
   Brand tokens: Orange #f39f1e, Light Grey #f4f4f4, Charcoal #2a2a2a, White #ffffff, Black #000000.
   Fonts: Poppins (UI) + Montserrat (headings).
   Theme: <html data-bs-theme="light|dark"> (set by the layout's head script; toggle on the page). */

@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/montserrat/montserrat-latin-variable.woff2") format("woff2");
}

.login-body {
    /* Brand palette (fixed) */
    --brand-orange: #f39f1e;
    --brand-light-grey: #f4f4f4;
    --brand-charcoal: #2a2a2a;
    --brand-white: #ffffff;
    --brand-black: #000000;

    /* Semantic tokens, light theme (derived from the palette by opacity/overlay only) */
    --lg-brand-bg: var(--brand-charcoal);
    --lg-brand-circle-1: rgba(0, 0, 0, 0.35);
    --lg-brand-circle-2: rgba(243, 159, 30, 0.14);
    --lg-form-bg: var(--brand-light-grey);
    --lg-surface: var(--brand-white);      /* card (desktop) */
    --lg-input-bg: var(--brand-white);     /* inputs, toggle */
    --lg-card-shadow: 0 24px 60px rgba(0, 0, 0, 0.08);
    --lg-text: var(--brand-charcoal);
    --lg-text-strong: var(--brand-black);
    --lg-muted: rgba(42, 42, 42, 0.68);
    --lg-placeholder: rgba(42, 42, 42, 0.45);
    --lg-border: rgba(42, 42, 42, 0.18);
    --lg-control-hover-bg: rgba(42, 42, 42, 0.06);
    --lg-orange-soft: rgba(243, 159, 30, 0.18);
    --lg-on-dark-muted: rgba(255, 255, 255, 0.72);
    --lg-on-dark-soft: rgba(255, 255, 255, 0.9);
    --lg-focus: 0 0 0 0.25rem rgba(243, 159, 30, 0.35);
    --lg-radius: 8px;

    --font-ui: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-heading: "Montserrat", "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--lg-form-bg);
    color: var(--lg-text);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    color-scheme: light;
}

/* Dark theme: black brand panel, charcoal form panel, white text; orange stays the accent */
[data-bs-theme="dark"] .login-body {
    --lg-brand-bg: var(--brand-black);
    --lg-brand-circle-1: rgba(42, 42, 42, 0.85);
    --lg-brand-circle-2: rgba(243, 159, 30, 0.16);
    --lg-form-bg: var(--brand-charcoal);
    --lg-surface: #363636; /* charcoal lifted by ~6% white */
    --lg-input-bg: #363636;
    --lg-card-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    --lg-text: var(--brand-white);
    --lg-text-strong: var(--brand-white);
    --lg-muted: rgba(255, 255, 255, 0.7);
    --lg-placeholder: rgba(255, 255, 255, 0.42);
    --lg-border: rgba(255, 255, 255, 0.18);
    --lg-control-hover-bg: rgba(255, 255, 255, 0.08);
    --lg-orange-soft: rgba(243, 159, 30, 0.22);
    color-scheme: dark;
}

/* ---------- Shell: brand panel + form panel ---------- */

.login-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr; /* compact brand strip on top, form takes the rest */
}

@media (min-width: 992px) {
    .login-shell {
        grid-template-columns: 45fr 55fr;
        grid-template-rows: 1fr;
    }

    /* Inside the desktop card, dark inputs sit slightly recessed */
    [data-bs-theme="dark"] .login-body {
        --lg-input-bg: var(--brand-charcoal);
    }
}

/* ---------- Brand panel (dark, centered content, decorative circles) ---------- */

.brand-panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    color: var(--brand-white);
    background: var(--lg-brand-bg);
    overflow: hidden;
    isolation: isolate;
}

.brand-panel::before,
.brand-panel::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    z-index: -1;
}

.brand-panel::before {
    width: 380px;
    height: 380px;
    top: -190px;
    left: -190px;
    background: var(--lg-brand-circle-1);
}

.brand-panel::after {
    width: 420px;
    height: 420px;
    right: -210px;
    bottom: -210px;
    background: var(--lg-brand-circle-2);
}

.brand-panel__inner {
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    margin-bottom: 28px;
}

.brand-logo {
    display: block;
    height: 32px;
    width: auto;
}

.brand-headline {
    margin: 0 0 16px;
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--brand-white);
}

.brand-sub {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--lg-on-dark-muted);
}

.brand-features {
    display: none;
    list-style: none;
    padding: 0;
    margin: 44px auto 0;
    width: max-content;
    max-width: 100%;
    text-align: left;
}

.brand-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    color: var(--lg-on-dark-soft);
}

.brand-features li:last-child {
    margin-bottom: 0;
}

.feature-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--lg-orange-soft);
    color: var(--brand-orange);
}

.feature-icon svg {
    width: 16px;
    height: 16px;
}

.brand-foot {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 28px;
    margin: 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--lg-on-dark-muted);
}

@media (min-width: 992px) {
    .brand-panel {
        padding: 80px 56px;
    }

    /* Circles scale with the panel so wide screens do not feel empty */
    .brand-panel::before {
        width: clamp(420px, 42vw, 720px);
        height: clamp(420px, 42vw, 720px);
        top: calc(clamp(420px, 42vw, 720px) / -2);
        left: calc(clamp(420px, 42vw, 720px) / -2);
    }

    .brand-panel::after {
        width: clamp(460px, 46vw, 800px);
        height: clamp(460px, 46vw, 800px);
        right: calc(clamp(460px, 46vw, 800px) / -2);
        bottom: calc(clamp(460px, 46vw, 800px) / -2);
    }

    .brand-panel__inner {
        max-width: 540px;
    }

    .brand-mark {
        margin-bottom: 44px;
    }

    .brand-logo {
        height: 44px;
    }

    .brand-headline {
        font-size: 3.25rem;
        margin-bottom: 20px;
    }

    .brand-sub {
        font-size: 1.15rem;
        max-width: 480px;
        margin: 0 auto;
    }

    .brand-features {
        display: block;
        margin-top: 52px;
    }

    .brand-features li {
        font-size: 1.05rem;
        gap: 14px;
        margin-bottom: 18px;
    }

    .feature-icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .feature-icon svg {
        width: 18px;
        height: 18px;
    }

    .brand-foot {
        display: block;
    }
}

/* ---------- Form panel ---------- */

.form-panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 20px 32px;
    background: var(--lg-form-bg);
}

.form-panel__inner {
    position: relative;
    width: 100%;
    max-width: 448px;
}

.form-title {
    margin: 0 0 4px;
    font-family: var(--font-heading);
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--lg-text-strong);
}

.form-subtitle {
    margin: 0 0 28px;
    font-size: 0.95rem;
    color: var(--lg-muted);
}

@media (min-width: 992px) {
    .form-panel {
        padding: 64px 48px;
    }

    /* Desktop: the form lives in a card so the wide panel has structure */
    .form-panel__inner {
        max-width: 480px;
        padding: 44px 40px 36px;
        background: var(--lg-surface);
        border: 1px solid var(--lg-border);
        border-radius: 16px;
        box-shadow: var(--lg-card-shadow);
    }

    .form-title {
        font-size: 1.75rem;
        padding-right: 56px; /* keep clear of the theme toggle */
    }
}

/* Theme toggle: above the form on mobile (in the panel's top padding), inside the card on desktop */
.theme-toggle {
    position: absolute;
    top: -48px;
    right: 0;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--lg-border);
    border-radius: 50%;
    background: var(--lg-input-bg);
    color: var(--lg-text);
    cursor: pointer;
}

@media (min-width: 992px) {
    .theme-toggle {
        top: 20px;
        right: 20px;
    }
}

.theme-toggle:hover {
    color: var(--brand-orange);
    border-color: var(--brand-orange);
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: var(--lg-focus);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.theme-toggle .icon-sun,
[data-bs-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

[data-bs-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

/* Alerts: keep Bootstrap's semantic colors (they adapt to data-bs-theme), tighten the look */
.login-body .alert {
    border-radius: var(--lg-radius);
    padding: 12px 14px;
    font-size: 0.95rem;
}

/* ---------- Fields (label above input) ---------- */

.login-body .form-label {
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--lg-text);
}

.login-body .form-control {
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--lg-border);
    border-radius: var(--lg-radius);
    background-color: var(--lg-input-bg);
    color: var(--lg-text);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    box-shadow: none;
}

.login-body .form-control::placeholder {
    color: var(--lg-placeholder);
}

.login-body .form-control:focus {
    background-color: var(--lg-input-bg);
    color: var(--lg-text);
    border-color: var(--brand-orange);
    box-shadow: var(--lg-focus);
}

/* Keep browser autofill on-theme */
.login-body .form-control:-webkit-autofill,
.login-body .form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--lg-input-bg) inset;
    -webkit-text-fill-color: var(--lg-text);
    caret-color: var(--lg-text);
}

.login-body .invalid-feedback {
    font-size: 0.85rem;
    margin-top: 6px;
}

/* Password field with show/hide toggle */
.password-wrap {
    position: relative;
}

.password-wrap > .form-control {
    padding-right: 48px;
}

.password-wrap > .form-control.is-invalid {
    background-image: none;
}

.pw-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--lg-radius);
    background: transparent;
    color: var(--lg-muted);
    cursor: pointer;
}

.pw-toggle:hover {
    color: var(--lg-text-strong);
}

.pw-toggle:focus-visible {
    outline: none;
    box-shadow: var(--lg-focus);
}

.pw-toggle svg {
    width: 18px;
    height: 18px;
}

.pw-toggle .icon-hide,
.pw-toggle.is-on .icon-show {
    display: none;
}

.pw-toggle.is-on .icon-hide {
    display: block;
}

/* Remember me */
.login-body .form-check {
    padding-left: 1.6em;
}

.login-body .form-check-input {
    width: 1.05em;
    height: 1.05em;
    margin-top: 0.22em;
    margin-left: -1.6em;
    background-color: var(--lg-input-bg);
    border-color: var(--lg-border);
}

.login-body .form-check-input:checked {
    background-color: var(--brand-orange);
    border-color: var(--brand-orange);
}

.login-body .form-check-input:focus {
    border-color: var(--brand-orange);
    box-shadow: var(--lg-focus);
}

.login-body .form-check-label {
    font-size: 0.9rem;
    color: var(--lg-text);
}

/* ---------- Primary button ---------- */

.btn-brand {
    --bs-btn-bg: var(--brand-orange);
    --bs-btn-border-color: var(--brand-orange);
    --bs-btn-color: var(--brand-white);
    --bs-btn-hover-bg: var(--brand-orange);
    --bs-btn-hover-border-color: var(--brand-orange);
    --bs-btn-hover-color: var(--brand-white);
    --bs-btn-active-bg: var(--brand-orange);
    --bs-btn-active-border-color: var(--brand-orange);
    --bs-btn-active-color: var(--brand-white);
    --bs-btn-disabled-bg: var(--brand-orange);
    --bs-btn-disabled-border-color: var(--brand-orange);
    --bs-btn-disabled-color: var(--brand-white);
    --bs-btn-disabled-opacity: 0.65;
    --bs-btn-focus-box-shadow: var(--lg-focus);
    --bs-btn-font-weight: 600;
    --bs-btn-border-radius: var(--lg-radius);
    min-height: 44px;
    font-family: var(--font-ui);
    font-size: 0.95rem;
}

/* Hover/active darken the brand orange with a black overlay instead of a new hue */
.btn-brand:hover {
    background-image: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1));
}

.btn-brand:active,
.btn-brand.active {
    background-image: linear-gradient(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.18));
}

.btn-brand .spinner-border {
    display: none;
    margin-right: 8px;
}

.btn-brand.is-busy .spinner-border {
    display: inline-block;
}

.form-foot {
    margin: 24px 0 0;
    font-size: 0.9rem;
    color: var(--lg-muted);
    text-align: center;
}

.form-foot__accent {
    color: var(--brand-orange);
    font-weight: 600;
}

/* ---------- Motion (only when the user allows it) ---------- */

@media (prefers-reduced-motion: no-preference) {
    .login-body,
    .brand-panel,
    .form-panel,
    .login-body .form-control,
    .btn-brand,
    .pw-toggle,
    .theme-toggle {
        transition: border-color 150ms ease-out, box-shadow 150ms ease-out, background-color 200ms ease-out, background-image 150ms ease-out, color 150ms ease-out;
    }
}
