/* =====================================================================
   Login (html/login.html, routes /, /home and the catch-all)
   Two-panel card: Shibaura Machine branding + illustration on the left,
   the sign-in form on white on the right. login.js still drives the form
   (#m_login, #m_form, #m_login_signin_submit, input names, .m-login__signin).
   ===================================================================== */

:root {
    --lg-primary: #264e87;
    --lg-primary-rgb: 38, 78, 135;
    --lg-primary-hover: #1f4273;
    --lg-primary-deep: #142d52;
    --lg-page: #0d1b31;
    --lg-surface: #ffffff;
    --lg-ink: #13233d;
    --lg-muted: #5d6b80;
    --lg-border: #d6deea;
    --lg-field: #f4f7fb;
    --lg-danger: #c62f3c;
    --lg-radius: 10px;
}

/* ---------- Page: fixed, no rubber-band / zoom; the shell scrolls when the card is taller ---------- */
html,
body {
    overflow: hidden !important;
    touch-action: none;
    max-width: 100%;
    height: 100%;
    position: fixed;
    width: 100%;
}

body {
    overscroll-behavior: none;
    margin: 0;
    font-family: "Poppins", "Roboto", Arial, sans-serif;
    color: var(--lg-ink);
    background:
        radial-gradient(1100px 620px at 12% -10%, rgba(var(--lg-primary-rgb), 0.55), transparent 62%),
        radial-gradient(900px 560px at 105% 110%, rgba(var(--lg-primary-rgb), 0.38), transparent 60%),
        var(--lg-page);
}

@supports (-webkit-touch-callout: none) {
    body {
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
        -webkit-text-size-adjust: 100%;
    }
}

.login-page {
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
    display: flex;
    flex-direction: column;
}

.login-shell {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vh, 48px) clamp(16px, 4vw, 48px) 12px;
}

/* ---------- Card (#m_login keeps the theme's m-login--5 sign-in / sign-up / forgot switching) ---------- */
.m-login.m-login--5.login-card {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    width: min(1200px, 100%);
    height: auto;
    min-height: min(720px, calc(100vh - 112px));
    overflow: hidden;
    border-radius: 24px;
    background: var(--lg-surface);
    box-shadow: 0 30px 80px rgba(3, 12, 28, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* ---------- Left: brand panel ---------- */
.login-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 36px;
    min-width: 0;
    padding: clamp(32px, 4vw, 56px);
    color: #ffffff;
    background: linear-gradient(155deg, #2d5a98 0%, var(--lg-primary) 42%, var(--lg-primary-deep) 100%);
    isolation: isolate;
}

/* faint engineering grid, fading towards the bottom */
.login-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.35) 70%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.35) 70%, transparent 100%);
}

.login-brand__chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    padding: 7px 14px 7px 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.login-brand__chip-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--lg-primary);
    font-size: 13px;
}

.login-brand__title {
    margin: 26px 0 14px;
    color: #ffffff;
    font-family: inherit;
    font-size: clamp(28px, 2.7vw, 40px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.login-brand__desc {
    max-width: 470px;
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 15px;
    line-height: 1.65;
}

/* features on the left, the illustration on the right */
.login-brand__showcase {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
}

.login-brand__features {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.login-brand__features li {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
}

.login-brand__feature-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 17px;
}

/* Illustration (img/shibara-login.png: square, transparent, drawn for a light background)
   on a round white stage with soft rings */
.login-brand__visual {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(180px, 19vw, 280px);
    aspect-ratio: 1 / 1;
    padding: 6%;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 45%, #ffffff 0%, #ffffff 55%, #e9eff8 100%);
    box-shadow:
        0 0 0 10px rgba(255, 255, 255, 0.08),
        0 0 0 22px rgba(255, 255, 255, 0.04),
        0 24px 48px rgba(4, 16, 38, 0.4);
}

.login-brand__visual img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---------- Right: form panel ---------- */
.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: clamp(28px, 4vw, 56px);
    background: var(--lg-surface);
}

.login-panel__inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px;
}

.login-head {
    margin-bottom: 30px;
    text-align: center;
}

.login-logo {
    display: block;
    width: 100%;
    max-width: 250px;
    height: auto;
    margin: 0 auto 30px;
}

.login-title {
    margin: 0 0 6px;
    color: var(--lg-ink);
    font-family: inherit;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.25;
}

.login-subtitle {
    margin: 0;
    color: var(--lg-muted);
    font-size: 14px;
    line-height: 1.5;
}

.login-form {
    margin: 0;
}

/* Fields. .m-form__group gives the theme validator its has-danger hook; its padding is reset here.
   The validator inserts div.form-control-feedback right after the input, inside .login-input. */
.m-form .login-field.m-form__group {
    position: relative;
    margin: 0 0 18px;
    padding: 0;
}

.login-input {
    position: relative;
}

.login-form .login-input input {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 52px;
    padding: 0 48px 0 46px;
    border: 1px solid var(--lg-border);
    border-radius: var(--lg-radius);
    background: var(--lg-field);
    color: var(--lg-ink);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.login-form .login-input input::placeholder {
    color: #8b97a8;
    font-size: 14px;
    font-weight: 400;
}

.login-form .login-input input:hover {
    border-color: #b9c6d8;
}

.login-form .login-input input:focus {
    border-color: var(--lg-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(var(--lg-primary-rgb), 0.14);
}

/* browser autofill keeps the field colours */
.login-form .login-input input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 40px var(--lg-field) inset;
    -webkit-text-fill-color: var(--lg-ink);
}

.login-form .login-input input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 40px #ffffff inset, 0 0 0 4px rgba(var(--lg-primary-rgb), 0.14);
}

/* icons sit on the input row (26px = half the 52px input), so an error message below does not move them */
.login-input .bi {
    position: absolute;
    top: 26px;
    left: 16px;
    transform: translateY(-50%);
    color: #8b97a8;
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
    transition: color 0.15s ease;
}

.login-input:focus-within .bi {
    color: var(--lg-primary);
}

.login-input .eye-icon {
    left: auto;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    pointer-events: auto;
}

.login-input .eye-icon:hover {
    color: var(--lg-primary);
    background: rgba(var(--lg-primary-rgb), 0.08);
}

.login-input .eye-icon:focus-visible {
    outline: 2px solid var(--lg-primary);
    outline-offset: 1px;
}

/* validation */
.login-field .form-control-feedback {
    margin-top: 6px;
    padding-left: 2px;
    color: var(--lg-danger);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.4;
}

.login-field.has-danger .login-input input {
    border-color: var(--lg-danger);
    background: #fff8f8;
}

.login-field.has-danger .login-input input:focus {
    box-shadow: 0 0 0 4px rgba(198, 47, 60, 0.12);
}

.login-field.has-danger .login-input .bi:not(.eye-icon) {
    color: var(--lg-danger);
}

/* server messages from login.js showErrorMsg (prepended to the form) */
.login-form > .m-alert {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: var(--lg-radius);
    font-size: 13px;
    line-height: 1.45;
}

.login-form > .m-alert.alert-danger {
    border: 1px solid #f1c3c8;
    background: #fdf1f2;
    color: #9f1f2c;
}

.login-form > .m-alert.alert-success {
    border: 1px solid #bfe3cd;
    background: #effaf3;
    color: #1d6b3d;
}

/* Remember me / forgot password */
.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 2px 0 26px;
    font-size: 14px;
}

/* .m-form label is 1rem (11px on this theme) */
.m-form .login-remember {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: inherit;
    color: var(--lg-muted);
    cursor: pointer;
    user-select: none;
}

.login-remember input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--lg-primary);
    cursor: pointer;
}

.login-forgot,
.login-forgot:hover {
    color: var(--lg-primary);
    font-weight: 600;
    text-decoration: none;
}

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

.login-forgot:focus-visible,
.login-remember input:focus-visible {
    outline: 2px solid var(--lg-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Login button. Equal side padding (the theme's .m-loader--right padding) keeps the label centred
   and the button the same size while login.js shows its spinner. */
#login_btn .login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 52px;
    padding: 0 3.1rem;
    border: 0;
    border-radius: var(--lg-radius);
    background: var(--lg-primary);
    color: #ffffff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.08em;
    box-shadow: 0 10px 24px rgba(var(--lg-primary-rgb), 0.32);
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

#login_btn .login-btn:hover {
    background: var(--lg-primary-hover);
    box-shadow: 0 12px 28px rgba(var(--lg-primary-rgb), 0.4);
}

#login_btn .login-btn:active {
    transform: translateY(1px);
}

#login_btn .login-btn:focus,
#login_btn .login-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(var(--lg-primary-rgb), 0.28), 0 10px 24px rgba(var(--lg-primary-rgb), 0.32);
}

#login_btn .login-btn .bi {
    font-size: 17px;
    transition: transform 0.15s ease;
}

#login_btn .login-btn:hover .bi {
    transform: translateX(3px);
}

#login_btn .login-btn[disabled] {
    opacity: 0.85;
    cursor: progress;
}

#login_btn .login-btn.m-loader .bi {
    display: none;
}

/* MES application logo */
.login-powered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 34px;
    padding-top: 22px;
    border-top: 1px solid #e7ecf3;
    color: var(--lg-muted);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.login-powered img {
    display: block;
    width: auto;
    height: 22px;
    max-width: 170px;
    object-fit: contain;
}

/* ---------- Footer ---------- */
.login-footer {
    flex: 0 0 auto;
    padding: 6px clamp(16px, 4vw, 48px) 16px;
    color: rgba(255, 255, 255, 0.62);
    font-size: 13px;
    text-align: center;
}

.login-footer small {
    font-size: 11px;
}

/* ---------- Responsive ---------- */

/* short laptop screens: tighter brand panel */
@media (min-width: 992px) and (max-height: 820px) {
    .login-brand {
        gap: 26px;
    }

    .login-brand__title {
        margin-top: 20px;
    }

    .login-head {
        margin-bottom: 24px;
    }

    .login-logo {
        margin-bottom: 22px;
    }

    .login-powered {
        margin-top: 26px;
        padding-top: 18px;
    }
}

/* small laptops: smaller illustration so the feature labels keep their width */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .login-brand__showcase {
        gap: 20px;
    }

    .login-brand__visual {
        width: 170px;
    }

    .login-brand__features li {
        font-size: 13px;
    }
}

/* tablets and below: stacked card, brand on top without the illustration */
@media (max-width: 991.98px) {
    .m-login.m-login--5.login-card {
        grid-template-columns: minmax(0, 1fr);
        width: min(680px, 100%);
        min-height: 0;
        border-radius: 20px;
    }

    .login-brand {
        gap: 22px;
        padding: 32px 36px;
    }

    .login-brand__title {
        margin: 20px 0 10px;
        font-size: 30px;
    }

    .login-brand__title br {
        display: none;
    }

    .login-brand__showcase {
        grid-template-columns: minmax(0, 1fr);
    }

    .login-brand__features {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px 20px;
    }

    .login-brand__visual {
        display: none;
    }

    .login-panel {
        padding: 36px;
    }
}

/* phones: compact brand header, no feature list */
@media (max-width: 575.98px) {
    .login-shell {
        align-items: flex-start;
        padding: 16px 16px 8px;
    }

    .m-login.m-login--5.login-card {
        border-radius: 18px;
    }

    .login-brand {
        padding: 22px 20px;
    }

    .login-brand__chip {
        font-size: 12px;
    }

    .login-brand__title {
        margin: 16px 0 6px;
        font-size: 23px;
    }

    .login-brand__desc {
        font-size: 13.5px;
        line-height: 1.55;
    }

    .login-brand__features {
        display: none;
    }

    .login-panel {
        padding: 28px 20px 24px;
    }

    .login-logo {
        max-width: 210px;
        margin-bottom: 22px;
    }

    .login-head {
        margin-bottom: 24px;
    }

    .login-title {
        font-size: 24px;
    }

    .login-options {
        font-size: 13px;
    }

    .login-powered {
        margin-top: 26px;
        padding-top: 18px;
    }

    .login-footer {
        font-size: 12px;
    }
}

/* iOS zooms into inputs under 16px */
@media (max-width: 768px) {
    .login-form .login-input input {
        font-size: 16px;
    }
}
