/* Numbers ERP — sign-in screen
   Stage (left): Three.js hex-column field + 3D brand mark (js/login/login-scene.js)
   Panel (right): sign-in form */

:root {
    --ink: #140926;          /* stage background */
    --ink-2: #24113f;        /* stage gradient */
    --violet: #691BA6;       /* brand, from img/Numbers.png */
    --violet-hover: #5a1690;
    --lilac: #c49cf2;        /* highlights on dark */
    --paper: #ffffff;
    --mist: #f6f3fb;         /* input fill */
    --line: #e3dcef;         /* input border */
    --text: #1d1530;
    --muted: #6c6482;
    --danger: #c0264b;
    --danger-bg: #fdf0f3;
    --focus: rgba(105, 27, 166, .22);
    --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
    --font-ui: "Figtree", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(420px, 34rem);
}

/* ---------- Stage ---------- */
.stage {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(120% 90% at 50% 38%, #3a1a66 0%, var(--ink-2) 42%, var(--ink) 78%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(28px, 4vw, 56px);
}

.stage__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: -1;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.stage.is-3d .stage__canvas { opacity: 1; }

/* Scrim so the copy stays readable over the columns */
.stage::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 42%;
    background: linear-gradient(to top, rgba(20, 9, 38, .88), rgba(20, 9, 38, 0));
    z-index: -1;
    pointer-events: none;
}

/* Static brand mark, shown when WebGL / the module can't run */
.stage__fallback {
    position: absolute;
    left: 50%;
    top: 46%;
    width: min(34vh, 300px);
    transform: translate(-50%, -50%);
    z-index: -1;
    opacity: .9;
    filter: drop-shadow(0 30px 60px rgba(105, 27, 166, .55));
    transition: opacity .6s ease;
}

.stage.is-3d .stage__fallback { opacity: 0; }

.stage__brand img {
    display: block;
    height: clamp(34px, 3.4vw, 46px);
    width: auto;
}

.stage__copy { max-width: 38rem; }

.stage__title {
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.5rem, 2.3vw, 2.15rem);
    line-height: 1.2;
    letter-spacing: -.015em;
    text-wrap: balance;
}

.stage__text {
    margin: 0;
    color: rgba(255, 255, 255, .68);
    font-size: 15px;
    max-width: 26rem;
}

/* ---------- Panel ---------- */
.panel {
    display: flex;
    flex-direction: column;
    background: var(--paper);
    padding: clamp(28px, 4vw, 56px) clamp(24px, 4.5vw, 64px);
    box-shadow: -1px 0 0 var(--line);
}

.panel__head,
.panel__body,
.panel__foot {
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Company identity: its logo (or a monogram tile) followed by its name */
.panel__head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
}

.company-logo {
    flex: none;
    display: block;
    height: 44px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    object-position: left center;
}

.company-id {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.company-logo[hidden],
.monogram[hidden] { display: none; }

.monogram {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: linear-gradient(145deg, #7d2bc4, var(--violet) 55%, #4f1180);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: .02em;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 4px 10px -4px rgba(105, 27, 166, .6);
}

.company-name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 0;
}

.panel__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 2rem;
    line-height: 1.15;
    letter-spacing: -.025em;
}

.panel__subtitle {
    margin: 10px 0 32px;
    color: var(--muted);
    font-size: 15px;
}

/* ---------- Form ---------- */
.field { margin-bottom: 18px; }

.field__label {
    display: block;
    margin-bottom: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.field__control { position: relative; }

.field__icon {
    position: absolute;
    left: 14px;
    top: 15px;
    width: 18px;
    height: 18px;
    color: #9a91ad;
    pointer-events: none;
    transition: color .2s ease;
}

.input {
    width: 100%;
    height: 48px;
    padding: 0 14px 0 42px;
    border: 1px solid #d8d0e6;
    border-radius: 10px;
    background-color: #fff;
    color: var(--text);
    font: inherit;
    font-size: 15px;
    box-shadow: 0 1px 2px rgba(29, 21, 48, .05);
    transition: border-color .2s ease, box-shadow .2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.input::placeholder { color: #a39bb5; }

.input:hover { border-color: #bcaed4; }

.input:focus {
    outline: none;
    border-color: var(--violet);
    box-shadow: 0 0 0 4px var(--focus);
}

/* Keep browser autofill from painting fields blue/yellow */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px #fff inset, 0 1px 2px rgba(29, 21, 48, .05);
    transition: background-color 99999s ease-out;
}

.input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #fff inset, 0 0 0 4px var(--focus);
}

.input:autofill { background-color: #fff; }

.field__control:focus-within .field__icon { color: var(--violet); }

.input--password { padding-right: 48px; }

select.input {
    padding-right: 40px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236c6482' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
}

.reveal {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #8a81a0;
    cursor: pointer;
    transition: color .2s ease, background-color .2s ease;
}

.reveal:hover { color: var(--violet); background: rgba(105, 27, 166, .08); }
.reveal:focus-visible { outline: 2px solid var(--violet); outline-offset: 1px; }
.reveal svg { width: 18px; height: 18px; }
.reveal .icon-hide { display: none; }
.reveal[aria-pressed="true"] .icon-show { display: none; }
.reveal[aria-pressed="true"] .icon-hide { display: block; }

.caps-warning {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    font-size: 13px;
    color: #8a5a00;
}

.caps-warning.is-on { display: flex; }
.caps-warning svg { width: 15px; height: 15px; flex: none; }

/* Server-side + jquery-form-validator messages */
.field-error,
.field .form-error,
.field .help-block {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--danger);
}

.field-error:empty { display: none; }

.has-error .input,
.input.error,
.input.input-validation-error {
    border-color: var(--danger);
    background: #fff;
}

.has-error .input:focus { box-shadow: 0 0 0 4px rgba(192, 38, 75, .16); }

.alert {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--danger-bg);
    border: 1px solid #f6cbd6;
    color: #8c1534;
    font-size: 14px;
}

.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert ul { margin: 0; padding: 0; list-style: none; }
.alert.validation-summary-valid { display: none; }

.submit {
    position: relative;
    width: 100%;
    height: 50px;
    margin-top: 8px;
    border: 0;
    border-radius: 10px;
    background: var(--violet);
    color: #fff;
    font: inherit;
    font-size: 15.5px;
    font-weight: 600;
    letter-spacing: .01em;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .16) inset, 0 2px 6px -2px rgba(105, 27, 166, .45);
    transition: background-color .2s ease, box-shadow .2s ease, transform .08s ease;
}

.submit:hover { background: var(--violet-hover); }
.submit:active { transform: translateY(1px); }
.submit:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.submit[disabled] { cursor: progress; opacity: .92; }

.submit__spinner {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.submit.is-loading .submit__label { visibility: hidden; }
.submit.is-loading .submit__spinner { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.panel__foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid #eee9f5;
    font-size: 13px;
    color: var(--muted);
}

.panel__foot a { color: inherit; text-decoration: none; }
.panel__foot a:hover { color: var(--violet); }
.panel__foot a:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 3px; }
.panel__foot strong { color: var(--text); font-weight: 600; }

/* Entrance: one orchestrated moment */
@media (prefers-reduced-motion: no-preference) {
    .panel__head, .panel__body > * { animation: rise .7s cubic-bezier(.2, .7, .2, 1) both; }
    .panel__body > *:nth-child(2) { animation-delay: .06s; }
    .panel__body > *:nth-child(3) { animation-delay: .12s; }
    .panel__body > *:nth-child(4) { animation-delay: .18s; }
    .stage__copy { animation: rise .9s .35s cubic-bezier(.2, .7, .2, 1) both; }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .auth { grid-template-columns: minmax(0, 1fr) 420px; }
}

/* Phones / small tablets: the page fits the screen exactly. The 3D band takes whatever height
   the form leaves (never less than 120px), so there is no page scroll. */
@media (max-width: 860px) {
    .auth {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(120px, 1fr) auto;
    }
    .stage {
        min-height: 0;
        padding: 18px 20px 38px;
    }
    .stage__brand img { height: 30px; }
    .stage__copy { display: none; }
    .stage__fallback { width: min(110px, 60%); top: 50%; }
    .panel {
        box-shadow: none;
        border-radius: 20px 20px 0 0;
        margin-top: -20px;
        position: relative;
        padding: 22px 20px calc(14px + env(safe-area-inset-bottom, 0px));
    }
    .panel__head { min-height: 40px; }
    .monogram { width: 38px; height: 38px; border-radius: 10px; font-size: 14px; }
    .company-logo { height: 38px; }
    .panel__body { flex: none; padding: 20px 0 22px; }
    .panel__title { font-size: 1.5rem; }
    .panel__subtitle { margin: 4px 0 20px; font-size: 14px; }
    .field { margin-bottom: 14px; }
    .field__label { margin-bottom: 6px; }
    .submit { margin-top: 4px; }
    .panel__foot { padding-top: 14px; font-size: 12px; }
    .panel__foot > * { white-space: nowrap; }
}

/* Short phones (iPhone SE, small Androids): tighten further */
@media (max-width: 860px) and (max-height: 700px) {
    .auth { grid-template-rows: minmax(96px, 1fr) auto; }
    .stage { padding: 14px 20px 34px; }
    .stage__brand img { height: 26px; }
    .panel { padding-top: 18px; }
    .panel__head { min-height: 34px; }
    .monogram { width: 34px; height: 34px; font-size: 13px; }
    .company-logo { height: 34px; }
    .panel__body { padding: 14px 0 16px; }
    .panel__title { font-size: 1.35rem; }
    .panel__subtitle { margin-bottom: 14px; }
    .field { margin-bottom: 10px; }
    .field__label { margin-bottom: 4px; font-size: 13px; }
    .input { height: 44px; }
    .field__icon { top: 13px; }
    .reveal { top: 4px; }
    .submit { height: 46px; }
}

@media (max-width: 860px) and (max-height: 600px) {
    .auth { grid-template-rows: minmax(72px, 1fr) auto; }
    .panel__subtitle { font-size: 13px; }
}

@media (max-height: 640px) and (min-width: 861px) {
    .panel__body { padding: 20px 0; }
    .panel__subtitle { margin-bottom: 18px; }
    .field { margin-bottom: 12px; }
}
