/**
 * ERGOcontrol - logowanie split-screen (/web/login, /web/login/totp).
 * Wzorzec ERGOCar, paleta ERGOcontrol (indigo).
 */

.ergocontrol_login_shell,
body.ergocontrol-login-page {
    --login-form-width: 46%;
    --login-form-max: 520px;
    --login-brand: #6366f1;
    --login-brand-600: #4f46e5;
    --login-brand-50: #eef2ff;
    --login-brand-100: #e0e7ff;
    --login-ink: #1e1b4b;
    --login-ink-secondary: #374151;
    --login-ink-light: #6b7280;
    --login-ink-muted: #9ca3af;
    --login-bg: #f9fafb;
    --login-white: #ffffff;
    --login-border: #e5e7eb;
    --login-navy: #0f172a;
    --login-radius: 12px;
    --login-radius-sm: 10px;
    --login-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --login-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --login-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body.ergocontrol-login-page {
    margin: 0;
    font-family: var(--login-font);
    background: var(--login-white) !important;
    min-height: 100vh;
    color: var(--login-ink);
    -webkit-font-smoothing: antialiased;
}

body.ergocontrol-login-page #wrapwrap {
    min-height: 100vh;
    background: transparent;
}

body.ergocontrol-login-page #wrapwrap > header,
body.ergocontrol-login-page #wrapwrap > footer,
body.ergocontrol-login-page .o_footer,
body.ergocontrol-login-page .navbar,
body.ergocontrol-login-page .o_skip_to_content,
body.ergocontrol-login-page header .o_main_navbar,
body.ergocontrol-login-page .o_website_navbar,
body.ergocontrol-login-page #oe_main_menu_navbar,
body.ergocontrol-login-page a[href="/web/database/manager"],
body.ergocontrol-login-page a[href="/web/database/selector"],
body.ergocontrol-login-page .o_database_list .border-top:has(a[href*="database"]) {
    display: none !important;
}

body.ergocontrol-login-page .container.py-5 {
    padding: 0 !important;
    max-width: none !important;
}

/* Zapas: boot powłoki nie może blokować logowania (np. po błędnym stanie <html>). */
html.ergocontrol-shell-boot:has(body.ergocontrol-login-page)::before {
    display: none !important;
}

html.ergocontrol-shell-boot:has(body.ergocontrol-login-page) .o_action_manager,
html.ergocontrol-shell-boot:has(body.ergocontrol-login-page) #wrapwrap {
    margin-left: 0 !important;
    width: 100% !important;
}

body.ergocontrol-login-page .o_database_list > .card-body > .border-bottom:has(img[src*="company_logo"]) {
    display: none !important;
}

.ergocontrol_login_shell {
    min-height: 100vh;
    font-family: var(--login-font);
    color: var(--login-ink);
}

.ergocontrol_login_split {
    display: flex;
    min-height: 100vh;
}

.ergocontrol_login_panel--form {
    flex: 0 0 var(--login-form-width);
    width: var(--login-form-width);
    max-width: var(--login-form-max);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--login-white);
    padding: 40px 56px 32px;
}

.ergocontrol_login_brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
}

.ergocontrol_login_brand_mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #312e81 100%);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.28);
}

.ergocontrol_login_brand_name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--login-ink);
}

.ergocontrol_login_form_wrap,
.ergocontrol_login_shell .o_database_list {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.ergocontrol_login_hero {
    margin-bottom: 28px;
}

.ergocontrol_login_title {
    margin: 0 0 8px;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--login-ink);
}

.ergocontrol_login_lead {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--login-ink-light) !important;
}

.ergocontrol_login_form .mb-3 {
    margin-bottom: 20px !important;
}

.ergocontrol_login_label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--login-ink-secondary);
}

.ergocontrol_login_req {
    color: var(--login-brand);
    font-weight: 700;
}

.ergocontrol_login_input,
.ergocontrol_login_form .form-control,
body.ergocontrol-login-page #login,
body.ergocontrol-login-page #name,
body.ergocontrol-login-page #password,
body.ergocontrol-login-page #confirm_password,
body.ergocontrol-login-page .oe_signup_form .form-control,
body.ergocontrol-login-page .oe_reset_password_form .form-control,
body.ergocontrol-login-page #db,
body.ergocontrol-login-page #totp_token {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px !important;
    border: 1px solid var(--login-border) !important;
    border-radius: var(--login-radius) !important;
    background: var(--login-white) !important;
    font-size: 14px !important;
    font-family: inherit;
    color: var(--login-ink);
    transition: var(--login-transition);
    min-height: 46px;
    box-shadow: inset 0 1px 2px rgba(30, 27, 75, 0.03);
}

.ergocontrol_login_input::placeholder,
.ergocontrol_login_form .form-control::placeholder,
body.ergocontrol-login-page #login::placeholder,
body.ergocontrol-login-page #password::placeholder {
    color: var(--login-ink-muted);
}

.ergocontrol_login_input:focus,
.ergocontrol_login_form .form-control:focus,
body.ergocontrol-login-page #login:focus,
body.ergocontrol-login-page #name:focus,
body.ergocontrol-login-page #password:focus,
body.ergocontrol-login-page #confirm_password:focus,
body.ergocontrol-login-page .oe_signup_form .form-control:focus,
body.ergocontrol-login-page .oe_reset_password_form .form-control:focus,
body.ergocontrol-login-page #totp_token:focus {
    border-color: var(--login-brand) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16) !important;
    outline: none;
}

.ergocontrol_login_label--password {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ergocontrol_login_forgot {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--login-brand) !important;
    padding: 0 !important;
    text-decoration: none !important;
    white-space: nowrap;
}

.ergocontrol_login_forgot:hover {
    color: var(--login-brand-600) !important;
}

.ergocontrol_login_submit,
.ergocontrol_login_form .btn-primary,
body.ergocontrol-login-page .btn-primary {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    padding: 13px 20px !important;
    border: none !important;
    border-radius: var(--login-radius) !important;
    background: var(--login-brand) !important;
    color: var(--login-white) !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    font-family: inherit;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.32);
    transition: var(--login-transition);
}

.ergocontrol_login_submit:hover,
body.ergocontrol-login-page .btn-primary:hover {
    background: var(--login-brand-600) !important;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.38) !important;
    color: var(--login-white) !important;
    transform: translateY(-1px);
}

.ergocontrol_login_submit .fa,
body.ergocontrol-login-page .oe_signup_form button[type="submit"] .fa,
body.ergocontrol-login-page .oe_reset_password_form button[type="submit"] .fa {
    flex-shrink: 0;
}

.ergocontrol_login_actions {
    padding-top: 4px !important;
}

.ergocontrol_login_accounts {
    width: 100%;
    margin-bottom: 0;
}

.ergocontrol_login_form_wrap:has(.ergocontrol_user_switch) {
    justify-content: flex-start;
    padding-top: 4px;
}

.ergocontrol_login_hero--accounts {
    margin-bottom: 20px;
}

.ergocontrol_user_switch {
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

.ergocontrol_login_switch_title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--login-ink-muted);
    text-transform: uppercase;
}

.ergocontrol_user_switch_list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 14px !important;
    padding: 0;
    border: none !important;
    border-radius: 0 !important;
}

.ergocontrol_user_switch_item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--login-border);
    border-radius: var(--login-radius);
    background: var(--login-white);
    box-shadow: var(--login-shadow-sm);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: var(--login-transition);
}

.ergocontrol_user_switch_item:hover,
.ergocontrol_user_switch_item:focus-visible {
    border-color: #c7d2fe;
    background: var(--login-brand-50);
    box-shadow: 0 4px 14px rgba(30, 27, 75, 0.06);
    outline: none;
}

.ergocontrol_user_switch_avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    object-fit: cover;
    border: 2px solid var(--login-brand-100);
    box-shadow: 0 2px 6px rgba(30, 27, 75, 0.06);
}

.ergocontrol_user_switch_body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ergocontrol_user_switch_name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--login-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ergocontrol_user_switch_login {
    font-size: 12px;
    line-height: 1.35;
    color: var(--login-ink-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ergocontrol_user_switch_remove {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--login-ink-muted);
    transition: var(--login-transition);
}

.ergocontrol_user_switch_remove:hover {
    background: #fef2f2;
    color: #dc2626;
}

.ergocontrol_user_switch_other {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 2px;
    padding: 11px 14px !important;
    border: 1px dashed var(--login-border) !important;
    border-radius: var(--login-radius-sm) !important;
    color: var(--login-ink-light) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
}

.ergocontrol_user_switch_other:hover {
    border-color: var(--login-brand) !important;
    color: var(--login-brand-600) !important;
    background: var(--login-brand-50);
}

.ergocontrol_user_switch_pick,
.ergocontrol_login_form .o_user_switch_btn {
    color: var(--login-brand) !important;
    font-weight: 600;
    text-decoration: none !important;
}

.ergocontrol_login_panel_footer {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-top: auto;
    padding-top: 28px;
    border-top: 1px solid var(--login-border);
}

.ergocontrol_login_panel_footer_meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    width: 100%;
}

.ergocontrol_login_db_link,
body.ergocontrol-login-page a[href="/web/database/manager"],
body.ergocontrol-login-page a[href="/web/database/selector"] {
    display: none !important;
}

.ergocontrol_login_copyright {
    font-size: 12px;
    color: var(--login-ink-muted);
}

.ergocontrol_login_panel--visual {
    flex: 1;
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    background: var(--login-navy);
}

.ergocontrol_login_visual_bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.ergocontrol_login_visual_mesh {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.12) 0%, rgba(30, 27, 75, 0.72) 100%),
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.28), transparent 42%),
        radial-gradient(circle at 80% 30%, rgba(20, 184, 166, 0.14), transparent 38%);
}

.ergocontrol_login_visual_content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 100%;
    padding: 56px 48px;
}

.ergocontrol_login_visual_kicker {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #c7d2fe;
}

.ergocontrol_login_visual_title {
    margin: 0 0 12px;
    max-width: 420px;
    font-size: clamp(1.5rem, 2.2vw, 2rem);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: #fff;
}

.ergocontrol_login_visual_lead {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.72);
}

#totp_token.ergocontrol_login_input,
body.ergocontrol-login-page #totp_token {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-align: center;
}

body.ergocontrol-login-page .btn-secondary {
    border-radius: var(--login-radius-sm);
    font-size: 13px;
    font-weight: 600;
}

body.ergocontrol-login-page .btn-link {
    color: var(--login-ink-light);
    font-size: 13px;
    text-decoration: none;
}

body.ergocontrol-login-page .alert-danger,
.ergocontrol_login_form .alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: 8px;
    font-size: 13px;
}

.ergocontrol_login_remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--login-ink-light);
}

body.ergocontrol-login-page .oe_signup_form label,
body.ergocontrol-login-page .oe_reset_password_form label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--login-ink-secondary);
}

.ergocontrol_login_input[readonly],
.ergocontrol_login_input:read-only,
body.ergocontrol-login-page .oe_signup_form .field-login input[readonly],
body.ergocontrol-login-page .oe_signup_form .field-name input[readonly],
body.ergocontrol-login-page .oe_reset_password_form input[readonly],
body.ergocontrol-login-page .ergocontrol_login_field--locked .ergocontrol_login_input {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
    color: var(--login-ink-muted) !important;
    box-shadow: none !important;
    cursor: default;
    opacity: 0.88;
}

body.ergocontrol-login-page .ergocontrol_login_field--locked .ergocontrol_login_label {
    color: var(--login-ink-muted);
}

body.ergocontrol-login-page .ergocontrol_login_field--locked::after {
    content: "Ustawione z linku zaproszenia - nie można edytować";
    display: block;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--login-ink-muted);
}

.ergocontrol_login_input[readonly]:focus,
.ergocontrol_login_input:read-only:focus,
body.ergocontrol-login-page .ergocontrol_login_field--locked .ergocontrol_login_input:focus {
    border-color: #d1d5db !important;
    box-shadow: none !important;
    outline: none;
}

@media (max-width: 960px) {
    .ergocontrol_login_panel--visual {
        display: none;
    }

    .ergocontrol_login_panel--form {
        flex: 1;
        width: 100%;
        max-width: none;
        padding: 32px 24px 24px;
    }

    .ergocontrol_login_brand {
        margin-bottom: 32px;
    }
}

@media (max-width: 480px) {
    .ergocontrol_login_panel--form {
        padding: 24px 20px 20px;
    }

    .ergocontrol_login_title {
        font-size: 1.5rem;
    }

    .ergocontrol_login_form_wrap {
        max-width: none;
    }
}
