/* =========================================================================
   Quantum Systems — Enterprise Split-Screen Login
   Scope: applied wherever Odoo renders form.oe_login_form, .o_database_list,
          or .oe_website_login_container.
   ========================================================================= */

:root {
    --qs-brand-600: #57926c;
    --qs-brand-700: #187e3c;
    --qs-brand-50:  #eeecff;
    --qs-brand-grad: linear-gradient(160deg, #105528 0%, #187e3c 55%, #289b50 100%);

    --qs-surface:        #ffffff;
    --qs-surface-alt:    #f8f9fb;
    --qs-border:         #e4e7ec;
    --qs-border-strong:  #d0d5dd;

    --qs-text:           #101828;
    --qs-text-muted:     #475467;
    --qs-text-subtle:    #667085;
    --qs-text-invert:    #ffffff;

    --qs-danger:         #d92d20;
    --qs-danger-bg:      #fef3f2;
    --qs-danger-border:  #fda29b;

    --qs-radius-sm: 8px;
    --qs-radius-md: 12px;
    --qs-radius-lg: 16px;

    --qs-shadow-card: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(16,24,40,.08);
    --qs-shadow-btn:  0 1px 2px rgba(16,24,40,.08);

    --qs-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* -------------------------------------------------------------------------
   1. Page shell — hide the website chrome on login pages and let
      .oe_website_login_container (or .o_database_list) own the viewport.
   ------------------------------------------------------------------------- */
body:has(.oe_website_login_container),
body:has(.o_database_list),
body:has(form.oe_login_form) {
    margin: 0;
    min-height: 100vh;
    background: var(--qs-surface-alt);
    font-family: var(--qs-font);
    color: var(--qs-text);
}

/* Hide the website's header/nav/footer when we're on a login page.
   Targets the real Odoo website chrome (#top, #bottom, .o_main_navbar)
   wherever they sit in the DOM. */
body:has(.oe_website_login_container) #top,
body:has(.oe_website_login_container) #bottom,
body:has(.oe_website_login_container) header#top,
body:has(.oe_website_login_container) footer#bottom,
body:has(.oe_website_login_container) #o_shared_blocks,
body:has(form.oe_login_form) .o_main_navbar {
    display: none;
}

/* Make the website wrapwrap + main fill the viewport, no padding. */
body:has(.oe_website_login_container) #wrapwrap,
body:has(.oe_website_login_container) main {
    min-height: 100vh;
    padding: 0;
    margin: 0;
    display: block;
}

/* -------------------------------------------------------------------------
   2. Split-screen layout — .oe_website_login_container is the layout root.
      Brand panel sits absolute on the left (45%), form content flows in
      the right area via padding-left.
   ------------------------------------------------------------------------- */
.oe_website_login_container,
.o_database_list {
    position: relative;
    min-height: 100vh;
    padding: 48px 48px 48px calc(45% + 48px);
    background: var(--qs-surface-alt);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    box-sizing: border-box;
}

/* Constrain the right-column children to a 420px column, left-aligned
   within the available padding area. */
.oe_website_login_container > .qs-form-brand,
.oe_website_login_container > .login-header-text,
.oe_website_login_container > form.oe_login_form,
.o_database_list > .card,
.o_database_list > form.oe_login_form {
    width: 100%;
    max-width: 420px;
    margin: 0;
    box-sizing: border-box;
}

/* Hide Odoo's empty structure placeholders + the OWL user_switch component
   on the public login page (they collapse to nothing visually but throw off
   flex spacing). */
.oe_website_login_container > .oe_structure:empty,
.oe_website_login_container > owl-component[name="web.user_switch"]:empty {
    display: none;
}

/* -------------------------------------------------------------------------
   2b. Brand panel — absolutely positioned left column
   ------------------------------------------------------------------------- */
.qs-brand-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    min-height: 100vh;
    height: 100%;
    background: var(--qs-brand-grad);
    color: var(--qs-text-invert);
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

.qs-brand-panel__top {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qs-brand-panel__logo {
    width: 56px;
    height: 56px;
    border-radius: var(--qs-radius-md);
    object-fit: contain;
    background: rgba(255,255,255,.08);
    padding: 6px;
}

.qs-brand-panel__wordmark {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--qs-text-invert);
    line-height: 1.1;
}

.qs-brand-panel__tagline {
    font-size: 16px;
    font-weight: 400;
    color: rgba(255,255,255,.8);
    margin: 0;
    line-height: 1.5;
}

.qs-brand-panel__pillars {
    list-style: none;
    padding: 0;
    margin: 48px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-top: 1px solid rgba(255,255,255,.15);
    padding-top: 32px;
}

.qs-brand-panel__pillars li {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.qs-pillar__icon {
    flex: 0 0 32px;
    height: 32px;
    border-radius: var(--qs-radius-sm);
    background: rgba(255,255,255,.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--qs-text-invert);
}

.qs-pillar__icon svg {
    width: 16px;
    height: 16px;
}

.qs-pillar__text strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--qs-text-invert);
    margin-bottom: 2px;
}

.qs-pillar__text span {
    display: block;
    font-size: 13px;
    color: rgba(255,255,255,.7);
    line-height: 1.5;
}

.qs-brand-panel__footer {
    font-size: 13px;
    color: rgba(255,255,255,.6);
    margin: 0;
}

/* -------------------------------------------------------------------------
   3. Form-side resets — the form itself sits flush, no card chrome.
      Odoo 19's quick-login behavior (form starts with .d-none, shown when
      needed) is left intact.
   ------------------------------------------------------------------------- */
body:has(.oe_website_login_container) form.oe_login_form,
body:has(.o_database_list) form.oe_login_form,
body:has(form.oe_login_form) .o_user_switch {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

/* Inline brand (mobile, also visible above form heading) */
.qs-form-brand {
    display: none;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.qs-form-brand img {
    width: 36px;
    height: 36px;
    border-radius: var(--qs-radius-sm);
    object-fit: contain;
}

.qs-form-brand span {
    font-size: 18px;
    font-weight: 700;
    color: var(--qs-text);
    letter-spacing: -0.01em;
}

/* Form heading */
.login-header-text {
    margin-bottom: 32px;
}

.login-header-text h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--qs-text);
    margin: 0 0 6px 0;
    letter-spacing: -0.01em;
}

.login-header-text p,
.login-header-text .text-muted {
    font-size: 14px;
    color: var(--qs-text-muted);
    margin: 0;
}

/* -------------------------------------------------------------------------
   4. Inputs, labels, password toggle
   ------------------------------------------------------------------------- */
.oe_login_form .mb-3,
.o_user_switch .mb-3 {
    margin-bottom: 18px;
    position: relative;
}

.oe_login_form .form-label,
.o_user_switch .form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--qs-text);
    margin-bottom: 6px;
}

.oe_login_form .form-control,
.o_user_switch .form-control {
    width: 100%;
    height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--qs-border);
    border-radius: var(--qs-radius-md);
    background: var(--qs-surface);
    color: var(--qs-text);
    font-family: var(--qs-font);
    font-size: 15px;
    line-height: 1.4;
    box-sizing: border-box;
    transition: border-color .15s ease, box-shadow .15s ease;
    box-shadow: var(--qs-shadow-btn);
}

.oe_login_form .form-control::placeholder {
    color: var(--qs-text-subtle);
}

.oe_login_form .form-control:hover {
    border-color: var(--qs-border-strong);
}

.oe_login_form .form-control:focus,
.o_user_switch .form-control:focus {
    outline: none;
    border-color: var(--qs-brand-600);
    box-shadow: 0 0 0 4px var(--qs-brand-50);
}

/* Invalid state — was undefined despite JS adding the class */
.oe_login_form .form-control.is-invalid,
.o_user_switch .form-control.is-invalid {
    border-color: var(--qs-danger);
    box-shadow: 0 0 0 4px var(--qs-danger-bg);
}

/* Password field with show/hide eye icon */
.qs-password-wrapper {
    position: relative;
}

.qs-password-wrapper .form-control {
    padding-right: 44px;
}

.qs-password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--qs-radius-sm);
    color: var(--qs-text-subtle);
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease;
}

.qs-password-toggle:hover {
    color: var(--qs-text);
    background: var(--qs-surface-alt);
}

.qs-password-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--qs-brand-50);
    color: var(--qs-brand-600);
}

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

/* Hide stock Odoo password toggle if it ships one — we provide our own */
.o_caps_lock_warning .o_show_password {
    background: transparent;
    border: 0;
    color: var(--qs-text-subtle);
}

/* -------------------------------------------------------------------------
   5. Options row (Remember me + Forgot password)
   ------------------------------------------------------------------------- */
.qs-options-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 20px 0;
}

.qs-remember {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--qs-text-muted);
    user-select: none;
}

.qs-remember input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--qs-border-strong);
    border-radius: 4px;
    background: var(--qs-surface);
    cursor: pointer;
    position: relative;
    transition: background-color .15s ease, border-color .15s ease;
    margin: 0;
}

.qs-remember input[type="checkbox"]:hover {
    border-color: var(--qs-brand-600);
}

.qs-remember input[type="checkbox"]:checked {
    background: var(--qs-brand-600);
    border-color: var(--qs-brand-600);
}

.qs-remember input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.qs-remember input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--qs-brand-50);
}

/* -------------------------------------------------------------------------
   5b. "Back to home" link — fixed top-right, visible above brand & form
   ------------------------------------------------------------------------- */
.qs-home-link {
    position: fixed;
    top: 20px;
    right: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--qs-text);
    border: 1px solid var(--qs-border);
    border-radius: var(--qs-radius-md);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    box-shadow: var(--qs-shadow-btn);
    z-index: 100;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.qs-home-link:hover {
    color: var(--qs-brand-600);
    border-color: var(--qs-brand-600);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--qs-brand-50);
}

.qs-home-link:focus-visible {
    outline: none;
    color: var(--qs-brand-600);
    border-color: var(--qs-brand-600);
    box-shadow: 0 0 0 3px var(--qs-brand-50);
}

.qs-home-link svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 767.98px) {
    .qs-home-link {
        top: 12px;
        right: 12px;
        padding: 7px 12px;
        font-size: 13px;
    }
    .qs-home-link svg { width: 14px; height: 14px; }
}

/* -------------------------------------------------------------------------
   6. Primary button
   ------------------------------------------------------------------------- */
.oe_login_form .btn-primary,
.o_user_switch .btn-primary {
    width: 100%;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--qs-brand-600);
    border: 1px solid var(--qs-brand-600);
    color: #fff;
    font-family: var(--qs-font);
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--qs-radius-md);
    padding: 0 16px;
    box-shadow: var(--qs-shadow-btn);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.oe_login_form .btn-primary:hover,
.o_user_switch .btn-primary:hover {
    background: var(--qs-brand-700);
    border-color: var(--qs-brand-700);
}

.oe_login_form .btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--qs-brand-50);
}

.oe_login_form .btn-primary:active {
    transform: translateY(1px);
}

/* Sign-up footer template removed — no styles needed. */

/* -------------------------------------------------------------------------
   8. Server-side auth errors (scoped to login pages only)
   ------------------------------------------------------------------------- */
body:has(form.oe_login_form) .alert-danger,
body:has(.o_database_list) .alert-danger,
body:has(.oe_website_login_container) .alert-danger {
    background: var(--qs-danger-bg);
    border: 1px solid var(--qs-danger-border);
    color: var(--qs-danger);
    border-radius: var(--qs-radius-md);
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}

body:has(form.oe_login_form) .alert-danger::before,
body:has(.o_database_list) .alert-danger::before,
body:has(.oe_website_login_container) .alert-danger::before {
    content: "";
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    background-color: var(--qs-danger);
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>') no-repeat center / contain;
            mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>') no-repeat center / contain;
}

/* -------------------------------------------------------------------------
   9. Client-side validation tooltip (used by login_validation.js)
   ------------------------------------------------------------------------- */
.custom-error-tooltip {
    position: absolute;
    bottom: -36px;
    left: 0;
    background: var(--qs-danger);
    color: #fff;
    padding: 6px 10px;
    border-radius: var(--qs-radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(217,45,32,.25);
    z-index: 10;
    animation: qs-slide-up .2s ease-out;
}

.custom-error-tooltip::before {
    content: "";
    position: absolute;
    top: -4px;
    left: 14px;
    width: 8px;
    height: 8px;
    background: var(--qs-danger);
    transform: rotate(45deg);
}

.custom-error-tooltip svg {
    width: 14px;
    height: 14px;
}

@keyframes qs-slide-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes qs-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

/* -------------------------------------------------------------------------
   10. User switcher (backend)
   ------------------------------------------------------------------------- */
.o_user_switch .list-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    border: none;
}

.o_user_switch .list-group-item {
    width: 120px;
    height: 120px;
    flex: 0 0 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--qs-radius-md);
    border: 1px solid var(--qs-border);
    background: var(--qs-surface);
    padding: 10px;
    text-align: center;
    transition: border-color .15s ease, box-shadow .15s ease;
    cursor: pointer;
}

.o_user_switch .list-group-item:hover {
    border-color: var(--qs-brand-600);
    box-shadow: 0 0 0 3px var(--qs-brand-50);
}

.o_user_switch .list-group-item img,
.o_user_switch .list-group-item .o_user_switch_initials {
    width: 48px;
    height: 48px;
    font-size: 18px;
    line-height: 48px;
    margin-bottom: 8px;
}

.o_user_switch .list-group-item div {
    font-size: 13px;
    font-weight: 600;
    color: var(--qs-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* -------------------------------------------------------------------------
   11. Hide Odoo defaults we don't want surfaced (scoped to login pages only)
   ------------------------------------------------------------------------- */
body:has(form.oe_login_form) .o_login_auth,
body:has(form.oe_login_form) .o_brand_promotion,
body:has(form.oe_login_form) .o_caps_lock_warning .btn-link,
body:has(form.oe_login_form) .o_footer_copyright,
body:has(.o_database_list) .o_database_list .card-body > div.text-center:first-child,
body:has(.oe_website_login_container) .o_brand_promotion {
    display: none;
}

.o_brand_promotion {
    display: none;
}

body:has(form.oe_login_form) a[href*="/web/signup"],
body:has(form.oe_login_form) a[href*="superuser"],
body:has(form.oe_login_form) a[href*="login=super"],
body:has(form.oe_login_form) button[value="/web/become"] {
    display: none;
}

/* -------------------------------------------------------------------------
   12. Mobile (< 768px) — hide brand panel, show inline brand above form
   ------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .qs-brand-panel {
        display: none;
    }

    body:has(form.oe_login_form) .qs-form-brand,
    body:has(.o_database_list) .qs-form-brand,
    body:has(.oe_website_login_container) .qs-form-brand {
        display: inline-flex;
    }

    .oe_website_login_container,
    .o_database_list {
        padding: 56px 24px 32px 24px;
        align-items: stretch;
        justify-content: flex-start;
    }

    .oe_website_login_container > .qs-form-brand,
    .oe_website_login_container > .login-header-text,
    .oe_website_login_container > form.oe_login_form,
    .oe_website_login_container > .qs-form-footer,
    .o_database_list > .card,
    .o_database_list > form.oe_login_form {
        max-width: 100%;
    }
}

/* -------------------------------------------------------------------------
   13. Reduced motion — scoped to login surfaces so Odoo backend animations
       elsewhere are untouched.
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    body:has(form.oe_login_form) *,
    body:has(form.oe_login_form) *::before,
    body:has(form.oe_login_form) *::after,
    body:has(.o_database_list) *,
    body:has(.o_database_list) *::before,
    body:has(.o_database_list) *::after,
    body:has(.oe_website_login_container) *,
    body:has(.oe_website_login_container) *::before,
    body:has(.oe_website_login_container) *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
