@import url('palette.css');
/* static/css/auth.css — the pages shown before the app's sidebar: sign in, sign up, password reset, two-factor
   (templates: accounts/_auth_page.html), and company setup (company/create.html, further down).
   Same accent and type as the app (palette.css). The form sits on one side; beside it a till receipt prints, the same
   one the error pages use. Sizes are on a 4px grid. */

:root {
    /* neutrals: the app's slate, light */
    --a-bg: #ffffff;
    --a-text: #1e293b;
    --a-text-2: #475569;
    --a-muted: #64748b;
    --a-line: #e2e8f0;
    --a-line-strong: #cbd5e1;
    --a-field: #ffffff;
    --a-hover: #f1f5f9;
    --a-link: var(--accent-text);
    /* the counter the till stands on, and its paper */
    --a-counter: #1e293b;
    --a-slot: #0f172a;
    --a-slot-edge: #475569;
    --a-paper: #ffffff;
    --a-ink: #334155;
    --a-ink-muted: #64748b;
    --a-rule: #cbd5e1;
    --a-ease: cubic-bezier(.2, .7, .3, 1);

    /* company setup page */
    --page-bg: #f0f4f8;
    --muted: #64748b;
    --line: #e2e8f0;
}
html[data-bs-theme="dark"] {      /* the app's dark surfaces (static/css/theme.css) */
    --a-bg: #18191d;
    --a-text: #e2e8f0;
    --a-text-2: #cbd5e1;
    --a-muted: #94a3b8;
    --a-line: #2a2c31;
    --a-line-strong: #393b42;
    --a-field: #1d1f23;
    --a-hover: #24262b;
    --a-counter: #101114;
    --a-slot: #000000;
    --a-slot-edge: #393b42;
    --a-paper: #f1f5f9;
    --a-ink: #1e293b;
}

body {
    font-family: var(--font-ui);
    background: var(--page-bg);
    color: #1e293b;
    min-height: 100vh;
}
html[lang="km"] body, html[lang="km"] button, html[lang="km"] input, html[lang="km"] select, html[lang="km"] textarea, [lang="km"] {
    font-family: 'Kantumruy Pro', system-ui, sans-serif;
}

/* ── Sign in, sign up and the pages around them ── */

body.auth-page { background: var(--a-bg); color: var(--a-text); }

.auth-shell { display: grid; grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); min-height: 100vh; min-height: 100dvh; }

.auth-main { display: flex; flex-direction: column; padding: 24px 32px; min-height: 100vh; min-height: 100dvh; }

.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; }
.auth-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--a-text); font-size: 15px; font-weight: 600; text-decoration: none; }
.auth-brand i { color: var(--accent-text); font-size: 18px; }
.auth-brand:hover { color: var(--a-text); }

/* English or Khmer: two plain words, the one in use darker */
.auth-language { display: flex; align-items: center; gap: 4px; color: var(--a-muted); }
.auth-language i { font-size: 14px; margin-right: 4px; }
.auth-language button {
    border: 0; background: none; color: var(--a-muted); border-radius: 8px; padding: 4px 8px; font-size: 14px; line-height: 20px;
    transition: color .15s var(--a-ease), background-color .15s var(--a-ease);
}
.auth-language button:hover { color: var(--a-text); background: var(--a-hover); }
.auth-language button.is-on { color: var(--a-text); font-weight: 500; }
.auth-language button[lang="km"] { font-size: 15px; }       /* Khmer letters read smaller at the same size */

/* The form, a little above the middle */
.auth-body {
    flex: 1; display: flex; flex-direction: column; justify-content: center;
    width: 100%; max-width: 384px; margin: 0 auto; padding: 40px 0 72px;
}
.auth-body h1 { font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 8px; }
.auth-body .lead-text { color: var(--a-text-2); font-size: 15px; line-height: 24px; margin: 0 0 32px; }
.auth-body a { color: var(--a-link); text-decoration: none; }
.auth-body a:hover { text-decoration: underline; }

.auth-field { margin-bottom: 20px; }
.auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.auth-label-row a { font-size: 14px; line-height: 20px; }

.auth-page .form-label { display: inline-flex; align-items: center; gap: 4px; color: var(--a-text); font-size: 14px; line-height: 20px; font-weight: 500; margin-bottom: 8px; }
.auth-page .form-control {
    height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--a-line-strong);
    background-color: var(--a-field); color: var(--a-text); font-size: 16px;
    transition: border-color .15s var(--a-ease), box-shadow .15s var(--a-ease);
}
.auth-page .form-control:hover { border-color: var(--a-muted); }
.auth-page .form-control:focus { border-color: var(--accent-600); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18); }
.auth-page .form-control.is-invalid { border-color: var(--bs-form-invalid-border-color); }
.auth-page .form-text { color: var(--a-muted); font-size: 13px; line-height: 20px; margin-top: 8px; }
.auth-page .invalid-feedback { font-size: 13px; line-height: 20px; margin-top: 8px; }

.auth-page .btn { border-radius: 10px; font-weight: 500; transition: background-color .15s var(--a-ease), border-color .15s var(--a-ease), transform .1s var(--a-ease); }
.auth-page .btn:active { transform: scale(.99); }
.auth-submit { width: 100%; height: 44px; margin-top: 12px; }
.auth-body .btn.w-100 { min-height: 44px; }     /* the other pages' main buttons, the same height as the fields */

.auth-page .alert { border-radius: 10px; padding: 12px 16px; font-size: 14px; line-height: 20px; margin-bottom: 24px; }

.auth-shell .auth-foot { color: var(--a-muted); font-size: 14px; line-height: 20px; text-align: left; margin-top: 24px; }
.auth-shell .auth-foot a { color: var(--a-link); font-weight: 500; }
.auth-shell .auth-foot a.quiet { color: var(--a-muted); font-weight: 400; }
.auth-shell .auth-foot .btn-link { color: var(--a-link); font-size: 14px; font-weight: 500; text-decoration: none; vertical-align: baseline; }
.auth-shell .auth-foot .btn-link:hover { text-decoration: underline; }

/* (?) beside a label: its words show on hover, keyboard focus or tap. Plain CSS, as these pages load no script files. */
.auth-tip { position: relative; display: inline-flex; border: 0; background: none; padding: 0 2px; color: var(--a-muted); font-size: 14px; line-height: 20px; border-radius: 4px; }
.auth-tip:hover, .auth-tip:focus-visible { color: var(--a-text); }
.auth-tip:focus-visible { outline: 2px solid var(--accent-600); outline-offset: 1px; }
.auth-tip::after {
    content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 5;
    width: max-content; max-width: 240px; padding: 8px 12px; border-radius: 8px;
    background: #0f172a; color: #f8fafc; font-size: 13px; line-height: 20px; font-weight: 400; text-align: left;
    opacity: 0; pointer-events: none; transform: translate(-50%, 4px);
    transition: opacity .15s var(--a-ease), transform .15s var(--a-ease);
}
.auth-tip:hover::after, .auth-tip:focus::after { opacity: 1; transform: translate(-50%, 0); }

/* ── The till beside the form ── */

.auth-side {
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden;
    display: grid; place-items: center; padding: 48px; background: var(--a-counter);
}
.till { width: min(320px, 100%); }
.till-slot { position: relative; z-index: 2; height: 20px; border-radius: 10px; background: var(--a-slot); box-shadow: inset 0 -3px 0 var(--a-slot-edge); }
.till-window { overflow: hidden; margin: -10px 16px 0; padding-bottom: 16px; filter: drop-shadow(0 16px 24px rgba(0, 0, 0, .28)); }
.receipt {
    background: var(--a-paper); color: var(--a-ink); padding: 32px 20px 36px;
    font: 13px/24px ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', 'Kantumruy Pro', monospace;
    font-variant-numeric: tabular-nums;
    animation: receipt-print 1.1s var(--a-ease) .15s both;
    /* torn edge along the bottom */
    -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat,
                  conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 14px 10px repeat-x;
            mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat,
                  conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 14px 10px repeat-x;
}
@keyframes receipt-print { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .receipt { animation: none; } }

.receipt-shop { text-align: center; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.receipt-meta { text-align: center; color: var(--a-ink-muted); }
.receipt-rule { border-top: 1px dashed var(--a-rule); margin: 12px 0; }
.receipt-line { display: flex; justify-content: space-between; gap: 16px; }
.receipt-line span:last-child:not(:first-child) { text-align: right; white-space: nowrap; }
.receipt-total { font-weight: 700; }
.receipt-code {
    height: 36px; width: 176px; margin: 24px auto 8px;
    background: repeating-linear-gradient(90deg, var(--a-ink) 0 2px, #0000 2px 4px, var(--a-ink) 4px 5px, #0000 5px 8px, var(--a-ink) 8px 11px, #0000 11px 13px, var(--a-ink) 13px 14px, #0000 14px 16px);
}
.receipt-thanks { text-align: center; color: var(--a-ink-muted); }

/* A phone or a narrow window: the form alone */
@media (max-width: 899.98px) {
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    .auth-side { display: none; }
    .auth-main { padding: 20px; }
    .auth-body { max-width: 420px; padding: 32px 0 48px; }
}

/* ── Shared small pieces ── */

.optional { color: var(--muted); font-weight: 400; }

/* Password field with a show/hide button inside it */
.password-field { position: relative; }
.password-field .form-control { padding-right: 44px; }
.password-field .toggle {
    position: absolute; top: 0; right: 0; height: 38px; width: 40px;
    border: 0; background: none; color: var(--muted);
}
.password-field .toggle:hover { color: #1e293b; }
.password-field .form-control.is-invalid { background-image: none; }
.auth-page .password-field .toggle { height: 44px; width: 44px; color: var(--a-muted); border-radius: 10px; }
.auth-page .password-field .toggle:hover { color: var(--a-text); }

.btn-primary { background: var(--blue-600); border-color: var(--blue-600); }
.btn-primary:hover, .btn-primary:focus { background: var(--blue-700); border-color: var(--blue-700); }

/* ── Company setup (company/create.html): a card in the middle of the page ── */

.auth {
    max-width: 420px;
    margin: 0 auto;
    padding: 64px 16px 48px;
}
.auth-wide { max-width: 560px; padding-top: 48px; }

.auth-app-name {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-weight: 600; color: var(--blue-600); margin-bottom: 20px;
}

.auth-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15, 30, 60, 0.06);
    padding: 32px;
}
.auth h1 { font-size: 1.4rem; font-weight: 600; margin-bottom: 4px; }
.auth .lead-text { color: var(--muted); font-size: 0.925rem; margin-bottom: 24px; }

.auth .form-label { font-size: 0.875rem; font-weight: 600; margin-bottom: 4px; }
.auth .form-control:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12); }
.auth .form-text { color: var(--muted); }

.auth-foot { color: var(--muted); font-size: 0.875rem; text-align: center; margin-top: 16px; }
.auth-foot a { color: var(--blue-600); text-decoration: none; font-weight: 500; }
.auth-foot a:hover { text-decoration: underline; }
.auth-foot a.quiet { color: var(--muted); font-weight: 400; }

/* Company logo picker */
.logo-row { display: flex; align-items: center; gap: 16px; }
.logo-preview {
    width: 64px; height: 64px; flex-shrink: 0;
    border: 1px solid var(--line); border-radius: 10px; background: #f8fafc;
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8; font-size: 1.5rem; overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 480px) {
    .auth { padding-top: 32px; }
    .auth-card { padding: 20px; }
}
