/* Modax Handheld UI - Enterprise FO-like theme */
/* Default = dark */
:root {
    --page-bg: #f3f4f6;
    --device-bg: #0f0f0f;
    --bg: #121212;
    --panel: #1E1E1E;
    --panel2: #181818;
    --border: rgba(255,255,255,0.08);
    --text: rgba(255,255,255,0.92);
    --muted: rgba(255,255,255,0.65);
    --accent: #2B78D6;
    --danger: #E04F5F;
    --shadow: 0 10px 30px rgba(0,0,0,0.55);
    --radius: 14px;
    --gap: 12px;
    --font: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Light theme overrides */
:root[data-theme="light"] {
    --page-bg: #f3f4f6;
    --device-bg: #ffffff;
    --bg: #ffffff;
    --panel: #f8fafc;
    --panel2: #ffffff;
    --border: rgba(0,0,0,0.12);
    --text: rgba(15,23,42,0.92);
    --muted: rgba(15,23,42,0.62);
    --accent: #2B78D6;
    --danger: #E04F5F;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}
body {
    background: radial-gradient(1200px 800px at 50% 35%, #163a5f 0%, #0d2440 45%, #07162a 100%);
}
.hh-root {
    color: var(--text);
    font-family: var(--font);
}

#controlAddIn, .controladdin, .controladdin-container, .root,
#modax-handheld {
    height: 100%;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}
#modax-handheld {
    display: flex;
    flex-direction: column;
}

.hh-stage {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 18px;
}

.hh-scale {
    transform-origin: center center;
    will-change: transform;
}

/* Stage branding: the script picks full / compact / none from the free space beside the device */
.hh-stage-brand,
.hh-stage-note {
    display: none;
    position: fixed;
    font-family: var(--font);
    color: rgba(255,255,255,0.92);
    pointer-events: none;
}
.hh-stage-brand {
    top: 28px;
    left: 32px;
    align-items: center;
    gap: 14px;
}
.hh-stage-logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45));
}
.hh-stage-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 26px;
}
.hh-stage-sub {
    font-size: 13px;
    color: rgba(255,255,255,0.62);
    line-height: 18px;
}
.hh-stage-note {
    left: 0;
    right: 0;
    bottom: 18px;
    text-align: center;
    font-size: 12px;
    letter-spacing: 0.4px;
    color: rgba(255,255,255,0.45);
}
body.hh-brand-full .hh-stage-brand,
body.hh-brand-compact .hh-stage-brand { display: flex; }
body.hh-brand-full .hh-stage-note,
body.hh-brand-compact .hh-stage-note { display: block; }

/* Narrow page (BC shows the add-in in a fixed-width pane): logo above the name, beside the device */
body.hh-brand-compact .hh-stage-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    top: 24px;
    left: 24px;
    max-width: 168px;
}
body.hh-brand-compact .hh-stage-logo { width: 48px; height: 48px; }
body.hh-brand-compact .hh-stage-title { font-size: 18px; line-height: 22px; }
body.hh-brand-compact .hh-stage-sub { font-size: 12px; line-height: 16px; }

/* Frame - centered phone device layout */
.hh-root {
    position: relative;
    width: 390px;
    height: 780px;
    background: var(--device-bg);
    border-radius: 36px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.10);
    border: 6px solid #2a2a2a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}
.hh-root::after {
    content: '';
    height: 6px;
    width: 120px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    margin: 8px auto 14px auto;
}

/* Content area - scrollable */
.hh-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-top: 14px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header layout */
.hh-header {
    /* stays at the top while the screen scrolls: the back arrow (fixed) always sits on it, never on the scan box */
    position: sticky;
    top: -14px;
    z-index: 50;
    background: var(--bg);
    height: 48px;
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

/* Brand + activity center stack */
.hh-brand {
    font-size: 10px;
    letter-spacing: 1px;
    opacity: .6;
    text-align: center;
    line-height: 12px;
    color: var(--muted);
}

.hh-activity {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    line-height: 20px;
    color: var(--text);
}

/* Force Back button to top-left corner (independent of header layout) */
.hh-nav-back {
    position: fixed !important;
    left: 14px !important;
    top: 28px !important;
    transform: none !important;
    z-index: 9999 !important;

    border: 0;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 10px;

    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 10px;
    line-height: 1;

    color: #111 !important;
    opacity: 0.95;
}

/* Dark mode: light arrow on dark background (project uses data-theme on :root) */
:root:not([data-theme="light"]) .hh-nav-back {
    color: #fff !important;
    background: rgba(0, 0, 0, 0.25);
}

.hh-nav-back:hover {
    opacity: 1;
}

/* Action bar - top buttons for Putaway actions */
.hh-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
}
.hh-action-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.hh-action-btn:hover {
    background: var(--panel2);
    border-color: rgba(43,120,214,0.4);
}
.hh-theme-btn svg { display: block; }

.hh-theme-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* The error sound button stands left of the theme button */
.hh-sound-btn {
    right: 62px;
}

/* Prompt Panel - single source for process instructions (non-clickable) */
.hh-prompt {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(43,120,214,0.35);
    background: rgba(43,120,214,0.12);
    margin: 10px 0 14px 0;
    cursor: default;
    pointer-events: none;
}
.hh-prompt-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
}
:root[data-theme="light"] .hh-prompt {
    border: 1px solid rgba(43,120,214,0.35);
    background: rgba(43,120,214,0.12);
}
:root[data-theme="light"] .hh-prompt-text {
    color: rgba(15,23,42,0.92);
}

/* Scan input - clean border + focus accent */
#scan {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
    font-size: 16px;
    margin: 8px 0;
}
.uom-card select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel2);
    color: var(--text);
    font-size: 16px;
}
.modax-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 16px;
    background: var(--panel2);
    color: var(--text);
}
.uom-card .label {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 6px;
}

#scan:focus {
    border-color: rgba(43,120,214,0.55);
    box-shadow: 0 0 0 3px rgba(43,120,214,0.15);
}
.hh-disabled {
    background-color: #f2f2f2 !important;
    color: #999 !important;
}

/* Message bar */
.hh-msg {
    width: 100%;
    max-width: 100%;
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    margin: 10px 0 var(--gap) 0;
    font-size: 14px;
    text-align: center;
}
.hh-msg.success { background: rgba(22,199,132,0.12); border-color: rgba(22,199,132,0.25); }
.hh-msg.error {
    border-color: rgba(224,79,95,0.35);
    background: rgba(224,79,95,0.1);
}
.hh-msg.empty { color: var(--muted); }

/* Cards container */
.hh-cards, #cardLabels {
    width: 100%;
    max-width: 100%;
}
.hh-cards { margin: 12px 0; }
#cardLabels { margin: 0 0 var(--gap) 0; }

.hh-cards .card, .hh-card {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 12px;
    margin: 0 0 var(--gap) 0;
}
.hh-cards .card .label, .hh-cards .card .card-label,
.hh-card .label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    display: block;
}
.hh-cards .card .value, .hh-card .value {
    font-size: 14px;
}

/* Qty card - 3 lines */
.hh-cards #cardQty .qty-line { margin: 4px 0; }
.hh-cards #cardQty .qty-label { color: var(--muted); font-size: 12px; margin-right: 8px; }

/* HOME - process / menu selection */
#hhHome {
    padding: 16px;
    width: 100%;
}
.home-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.home-back {
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
}
.home-header-title {
    font-size: 14px;
    color: var(--muted);
}
.home-title {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 12px;
}
.home-group {
    width: 100%;
    padding: 14px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-weight: 700;
    text-align: left;
    margin: 10px 0 6px 0;
    cursor: pointer;
}
.home-items {
    margin-bottom: 8px;
}
.home-item {
    width: 100%;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text);
    text-align: left;
    margin: 6px 0;
    cursor: pointer;
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    gap: 10px;
}
.step-btn {
    width: 44px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.step-value {
    min-width: 48px;
    text-align: center;
    font-size: 16px;
    font-weight: 650;
    color: var(--text);
}

.home-group,
.home-item,
.step-btn {
    background: var(--panel2);
    border-color: var(--border);
    color: var(--text);
}

/* Footer - always visible, fixed at bottom */
.hh-footer {
    z-index: 9999;
    flex: 0 0 auto;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--device-bg);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap);
}

.hh-footer .btn {
    pointer-events: auto;
    width: 100%;
    margin-bottom: 10px;
    border-radius: 12px;
    padding: 14px 12px;
    font-size: 16px;
    font-weight: 600;
    border: 1px solid var(--border);
    cursor: pointer;
}
.hh-footer .btn:last-child {
    margin-bottom: 0;
}
.hh-footer .btn-apply {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.hh-footer .btn-cancel {
    background: transparent;
    color: var(--text);
}

/* Task lists: groups first, then tappable rows */
.hh-list { width: 100%; margin-bottom: 12px; }
.hh-list-title {
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted);
    margin: 4px 0 8px 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.hh-list-count {
    display: inline-block;
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 11px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    text-transform: none;
    letter-spacing: 0;
}
.hh-list-back {
    border: none;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-size: 12px;
    padding: 0;
    cursor: pointer;
}
.hh-list-group, .hh-list-row {
    display: flex;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.hh-list-group { align-items: center; justify-content: space-between; font-weight: 700; }
.hh-list-row { flex-direction: column; gap: 3px; }
.hh-list-group:hover, .hh-list-row:hover { border-color: rgba(43,120,214,0.5); background: var(--panel2); }
.hh-list-row-title { font-weight: 700; font-size: 14px; }
.hh-list-row-sub { font-size: 12px; color: var(--muted); }
.hh-list-flag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    vertical-align: middle;
}
.hh-list-empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }
.hh-list-row-selected { border-color: rgba(43,120,214,0.9); background: rgba(43,120,214,0.14); }
.hh-list-row-selected:hover { background: rgba(43,120,214,0.2); }
.hh-list-row-locked { cursor: default; opacity: 0.85; }
.hh-list-row-locked:hover { border-color: rgba(43,120,214,0.9); background: rgba(43,120,214,0.14); }
.hh-list-batch { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.hh-list-batch-count { font-weight: 700; font-size: 13px; }
.hh-list-done, .hh-list-clear {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(43,120,214,0.6);
    background: rgba(43,120,214,0.9);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}
.hh-list-clear { background: transparent; color: var(--muted); border-color: rgba(120,120,120,0.4); margin-left: auto; }

/* A warning inside the (green) message box */
.hh-msg-warn { color: #b91c1c; font-weight: 600; }

/* Menu tiles tinted by family (translucent: reads on the light and the dark theme) */
.home-item.fam-receive { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.35); }
.home-item.fam-put     { background: rgba(34, 197, 94, 0.12);  border-color: rgba(34, 197, 94, 0.35); }
.home-item.fam-move    { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.40); }
.home-item.fam-quality { background: rgba(244, 63, 94, 0.11);  border-color: rgba(244, 63, 94, 0.35); }
.home-item.fam-count   { background: rgba(139, 92, 246, 0.12); border-color: rgba(139, 92, 246, 0.35); }
.home-item.fam-ship    { background: rgba(20, 184, 166, 0.12); border-color: rgba(20, 184, 166, 0.35); }
.home-item.fam-make    { background: rgba(217, 119, 6, 0.12);  border-color: rgba(217, 119, 6, 0.35); }
.home-item.fam-lookup  { background: rgba(100, 116, 139, 0.10); border-color: rgba(100, 116, 139, 0.30); }

/* Receiving list: a line with nothing left, and the line being handled */
.hh-list-row-done { opacity: 0.55; }
.hh-list-row-done .hh-list-flag { background: rgba(34, 197, 94, 0.18); color: #15803d; }
.hh-list-row-current { border-color: #2563eb; background: rgba(37, 99, 235, 0.10); }

/* A line closed short: the rest may still come */
.hh-list-row-short { border-color: #f59e0b; background: rgba(245, 158, 11, 0.10); }
.hh-list-row-short .hh-list-flag { background: rgba(245, 158, 11, 0.22); color: #92400e; }

/* The list's title reads as a heading, not a hint */
.hh-list-title { color: #1d4ed8 !important; font-weight: 700 !important; }

/* Back buttons in the list title: a finger-sized pill */
.hh-list-back { font-size: 13px !important; font-weight: 700 !important; padding: 6px 12px !important; margin-right: 8px !important; border-radius: 999px !important; border: 1px solid #93c5fd !important; background: rgba(37, 99, 235, 0.10) !important; color: #1d4ed8 !important; text-transform: none !important; letter-spacing: 0 !important; min-height: 32px; }

/* Flag colours: when a delivery is expected, and good states */
.hh-list-flag.hh-flag-late { background: #dc2626; color: #fff; }
.hh-list-flag.hh-flag-today { background: #16a34a; color: #fff; }
.hh-list-flag.hh-flag-tomorrow { background: #2563eb; color: #fff; }
.hh-list-flag.hh-flag-future { background: #f59e0b; color: #1f2937; }
.hh-list-flag.hh-flag-ok { background: #16a34a; color: #fff; }

/* Something still blocks the order (trailer inspection, QC hold): an outlined red badge */
.hh-list-flag.hh-flag-need { background: #fff; color: #b91c1c; border: 1px solid #b91c1c; }

/* A receiving line with its side action */
.hh-list-row-wrap { display: flex; align-items: stretch; gap: 6px; margin: 6px 0; }
.hh-list-row-wrap .hh-list-row-main { flex: 1 1 auto; margin: 0 !important; }
.hh-list-row-side { flex: 0 0 auto; width: 74px; border-radius: 12px; border: 1px solid #f59e0b; background: rgba(245, 158, 11, 0.12); color: #92400e; font: inherit; font-size: 11px; font-weight: 700; line-height: 1.15; cursor: pointer; }

/* The short-delivery action stands apart from the put-away actions */
.hh-action-btn.hh-action-short { border-color: #f59e0b; background: rgba(245, 158, 11, 0.14); color: #92400e; }

/* What waits behind a menu, on its tile */
.home-badge { float: right; min-width: 22px; padding: 0 8px; border-radius: 999px; background: #1E2761; color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.home-group .home-badge { background: #2563eb; }
