/* KiwiMill Parts catalog. Built for a landscape touch kiosk and phones. */

:root {
    --green-900: #1f3317;
    --green-800: #2d4a21;
    --green-700: #3f6a2a;
    --green-600: #507f37;   /* brand green from the logo */
    --green-500: #5f8f3c;
    --lime-400: #b5d334;    /* kiwi flesh */
    --lime-100: #eef5dc;
    --lime-50:  #f6faee;

    --bg: #f4f6f1;
    --surface: #ffffff;
    --ink: #1b2415;
    --ink-2: #4f5c47;
    --ink-3: #7c8874;
    --line: #e0e6d8;
    --danger: #b3261e;
    --danger-bg: #fdecea;

    --radius: 18px;
    --radius-sm: 12px;
    --shadow-1: 0 1px 2px rgba(31, 51, 23, .06), 0 2px 8px rgba(31, 51, 23, .06);
    --shadow-2: 0 4px 12px rgba(31, 51, 23, .10), 0 12px 32px rgba(31, 51, 23, .10);

    --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;

    --header-h: 64px;
    --nav-h: 64px;
    --gutter: 16px;
    --tap: 48px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 700; }
h1:focus { outline: none; }
p { margin: 0; }
a { color: var(--green-700); }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- App shell ---------- */

.app-header {
    position: sticky; top: 0; z-index: 20;
    height: calc(var(--header-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) var(--gutter) 0;
    display: flex; align-items: center; gap: 16px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 40px; height: 40px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--green-700); line-height: 1; }
.brand-sub { font-size: .78rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }

.top-nav { display: none; gap: 4px; margin-left: 24px; }
.top-nav a {
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 16px; border-radius: 999px;
    text-decoration: none; color: var(--ink-2); font-weight: 600;
}
.top-nav a:hover { background: var(--lime-50); }
.top-nav a.active { background: var(--lime-100); color: var(--green-800); }

.header-spacer { flex: 1; }

.app-main {
    max-width: 1440px; margin: 0 auto;
    padding: 20px var(--gutter) calc(var(--nav-h) + 40px + env(safe-area-inset-bottom));
}

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex; background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(31, 51, 23, .06);
}
.bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--ink-3); font-size: .75rem; font-weight: 600;
}
.bottom-nav a .rzi { font-size: 26px; }
.bottom-nav a.active { color: var(--green-700); }

.fab {
    position: fixed; z-index: 21;
    right: 20px; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
    height: 60px; padding: 0 22px 0 18px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--green-600); color: #fff; text-decoration: none;
    font-weight: 700; font-size: 1.05rem;
    box-shadow: 0 6px 20px rgba(63, 106, 42, .45);
}
.fab .rzi { font-size: 28px; }
.fab:active { transform: scale(.97); }

@media (min-width: 900px) {
    :root { --gutter: 28px; --header-h: 76px; }
    .brand img { width: 48px; height: 48px; }
    .brand-name { font-size: 1.5rem; }
    .top-nav { display: flex; }
    .bottom-nav { display: none; }
    .app-main { padding-bottom: 48px; }
    .fab { bottom: 28px; right: 28px; }
}

/* ---------- User menu ---------- */

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--green-600); color: #fff; font-weight: 700; letter-spacing: .02em;
}
.user-panel {
    position: absolute; right: 0; top: 52px; width: 260px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2); padding: 16px;
}
.user-panel .who { font-weight: 700; }
.user-panel .roles { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.user-panel .note { color: var(--ink-3); font-size: .85rem; margin-bottom: 14px; }
.signin-link {
    display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 16px;
    border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
    color: var(--ink-2); font-weight: 600; text-decoration: none;
}

/* ---------- Buttons, chips, badges ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--tap); padding: 0 20px; border-radius: 999px;
    border: 1px solid transparent; cursor: pointer; text-decoration: none;
    font-weight: 700; font-size: 1rem; white-space: nowrap;
    transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn .rzi { font-size: 22px; }
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-secondary { background: var(--surface); color: var(--green-800); border-color: var(--line); }
.btn-secondary:hover { background: var(--lime-50); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #f1c7c3; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(0,0,0,.04); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
    width: var(--tap); height: var(--tap); border-radius: 50%; padding: 0;
    display: inline-grid; place-items: center; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.icon-btn .rzi { font-size: 24px; }

.chip {
    display: inline-flex; align-items: center; height: 26px; padding: 0 10px;
    border-radius: 999px; background: var(--lime-100); color: var(--green-800);
    font-size: .8rem; font-weight: 600;
}

.code {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; height: 28px; padding: 0 9px; border-radius: 8px;
    background: var(--green-800); color: #fff;
    font-family: var(--font-display); font-weight: 700; font-size: .95rem; letter-spacing: .02em;
}
.code-lg { height: 40px; min-width: 64px; font-size: 1.35rem; border-radius: 10px; }
.bin { color: var(--ink-3); font-size: .85rem; font-weight: 600; }

/* ---------- Search ---------- */

.search-hero { max-width: 880px; margin: 8px auto 24px; text-align: center; }
.search-hero h1 { font-size: 2rem; margin-bottom: 6px; }
.search-hero p { color: var(--ink-2); margin-bottom: 18px; }
.search-box { position: relative; }
.search-box .rzi {
    position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
    font-size: 28px; color: var(--green-600); pointer-events: none;
}
.search-box input {
    width: 100%; height: 64px; padding: 0 64px 0 60px;
    border-radius: 999px; border: 2px solid var(--line); background: var(--surface);
    font-size: 1.25rem; box-shadow: var(--shadow-1); outline: none;
    -webkit-appearance: none; appearance: none;
}
.search-box input::-webkit-search-cancel-button, .search-box input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search-box input:focus { border-color: var(--green-500); box-shadow: 0 0 0 4px rgba(95, 143, 60, .18); }
.search-box .clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent;
}
.search-box .clear .rzi { position: static; transform: none; color: var(--ink-3); font-size: 24px; }
.result-count { color: var(--ink-2); margin: 0 0 14px; font-weight: 600; }

@media (min-width: 900px) {
    .search-hero { margin-top: 24px; margin-bottom: 36px; }
    .search-hero h1 { font-size: 2.8rem; }
    .search-hero p { font-size: 1.15rem; }
    .search-box input { height: 80px; font-size: 1.6rem; padding-left: 72px; }
    .search-box .rzi { font-size: 34px; left: 26px; }
}

/* ---------- Section headers ---------- */

.section-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; flex-wrap: wrap; }
.section-head h2 { flex: 1; }
.section-head .sub { color: var(--ink-3); font-weight: 600; }

/* ---------- Card grids ---------- */

.grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { gap: 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }

.card {
    position: relative; display: flex; flex-direction: column;
    background: var(--surface); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-1); text-decoration: none; color: inherit;
    transition: transform .12s, box-shadow .12s;
}
.card:hover { box-shadow: var(--shadow-2); }
.card:active { transform: scale(.985); }
.card-photo { aspect-ratio: 1 / 1; background: var(--lime-50); overflow: hidden; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.card-title {
    font-weight: 700; line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; align-items: center; gap: 8px; }
.card .code { position: absolute; top: 10px; left: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }

.box-card .card-photo { aspect-ratio: 4 / 3; }
.box-card .card-title { font-size: 1.05rem; }
.box-card .count { color: var(--ink-3); font-size: .9rem; font-weight: 600; }

@media (min-width: 900px) {
    .card-body { padding: 12px 14px 14px; }
    .card-title { font-size: 1.05rem; }
}

/* Placeholder for missing photos */
.no-photo {
    width: 100%; height: 100%; display: grid; place-items: center;
    background: repeating-linear-gradient(45deg, var(--lime-50), var(--lime-50) 12px, #fff 12px, #fff 24px);
    color: var(--green-500);
}
.no-photo .rzi { font-size: 44px; opacity: .6; }
.no-photo-code { font-family: var(--font-display); font-size: 3rem; font-weight: 700; color: var(--green-600); opacity: .55; }

/* ---------- Empty states ---------- */

.empty {
    text-align: center; padding: 48px 16px; color: var(--ink-2);
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.empty .rzi { font-size: 48px; color: var(--green-500); }
.empty h2 { margin: 10px 0 6px; }

/* ---------- Box header ---------- */

.box-hero {
    display: grid; gap: 16px; align-items: center;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1);
    padding: 14px; margin-bottom: 22px;
}
.box-hero-photo { border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 4 / 3; background: var(--lime-50); }
.box-hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.box-hero-info { display: flex; flex-direction: column; gap: 10px; }
.box-hero-info .code { align-self: flex-start; }
.box-hero-info .series { color: var(--ink-3); font-weight: 600; }
.box-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
@media (min-width: 700px) {
    .box-hero { grid-template-columns: 320px 1fr; padding: 18px; gap: 28px; }
}

/* ---------- Item detail ---------- */

.back-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.detail {
    display: grid; gap: 20px;
}
.detail-photo {
    background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-1);
    display: grid; place-items: center; min-height: 240px;
}
.detail-photo img { width: 100%; height: auto; max-height: 72vh; object-fit: contain; }
.detail-photo .no-photo { aspect-ratio: 1 / 1; }
.detail-info { display: flex; flex-direction: column; gap: 16px; }
.detail-info h1 { font-size: 2rem; }
.detail-info .desc { color: var(--ink-2); font-size: 1.05rem; white-space: pre-line; }
.location {
    display: flex; align-items: center; gap: 14px; padding: 16px;
    background: var(--lime-100); border-radius: var(--radius-sm); text-decoration: none; color: inherit;
}
.location .where { display: flex; flex-direction: column; }
.location .label { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--green-700); }
.location .name { font-weight: 700; font-size: 1.1rem; }
.location .rzi { margin-left: auto; color: var(--green-700); }
@media (min-width: 900px) {
    .detail { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 36px; align-items: start; }
    .detail-info h1 { font-size: 2.6rem; }
}

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; font-size: .9rem; color: var(--ink-2); }
.input, .select, .textarea {
    width: 100%; min-height: 54px; padding: 12px 16px;
    border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--surface);
    font-size: 1.05rem; outline: none;
}
.textarea { min-height: 110px; resize: vertical; }
.select { -webkit-appearance: none; appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
    background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
    background-size: 6px 6px; background-repeat: no-repeat; padding-right: 44px;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--green-500); box-shadow: 0 0 0 4px rgba(95, 143, 60, .15); }
.field-error { color: var(--danger); font-size: .9rem; font-weight: 600; }

.photo-picker {
    position: relative; display: block; cursor: pointer;
    border-radius: var(--radius); overflow: hidden; aspect-ratio: 1 / 1;
    background: var(--surface); border: 2px dashed #c9d6b8;
}
.photo-picker img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.photo-picker input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-empty {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    color: var(--green-700); font-weight: 700; font-size: 1.1rem; pointer-events: none;
}
.photo-empty .rzi { font-size: 56px; }
.photo-tools { display: flex; gap: 10px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.photo-busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.75); font-weight: 700; color: var(--green-700); }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-actions .grow { flex: 1; }
@media (max-width: 899px) {
    /* Save stays in reach of the thumb on phones */
    .form-actions.sticky {
        position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
        background: rgba(244, 246, 241, .95); backdrop-filter: blur(8px);
        padding: 10px 0; margin: 0 calc(-1 * var(--gutter)); padding-left: var(--gutter); padding-right: var(--gutter);
    }
}

.notice {
    padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 600;
    background: var(--lime-100); color: var(--green-800);
}
.notice.error { background: var(--danger-bg); color: var(--danger); }

/* ---------- Blazor defaults ---------- */

.blazor-error-boundary {
    background: #b32121; padding: 1rem 1rem 1rem 1.2rem; color: white; border-radius: var(--radius-sm);
}
.blazor-error-boundary::after { content: "Something went wrong on this page."; }

/* ---------- Kiosk (see js/app.js) ---------- */

/* Nobody signs in on the shared screen, and nothing on it is editable */
.kiosk .signin-link, .kiosk .user-menu, .kiosk .fab { display: none; }

/* Box cards without their own photo show their first items */
.collage { width: 100%; height: 100%; display: grid; gap: 2px; background: var(--line); }
.collage img { width: 100%; height: 100%; object-fit: cover; }
.collage-2 { grid-template-columns: 1fr 1fr; }
.collage-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.collage-3 img:first-child { grid-row: span 2; }
.collage-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.preview-title { color: var(--ink-2); font-weight: 600; }

@media (max-width: 899px) {
    /* Keep the Name field on screen under the photo on phones */
    .photo-picker { aspect-ratio: 4 / 3; max-height: 46vh; }
}

/* ---------- Radzen dialogs (delete confirm) in catalog colors ---------- */

:root {
    --rz-primary: var(--green-600);
    --rz-primary-light: var(--green-500);
    --rz-primary-lighter: var(--lime-100);
    --rz-primary-dark: var(--green-700);
    --rz-primary-darker: var(--green-800);
    --rz-text-font-family: var(--font);
    --rz-dialog-border-radius: var(--radius);
    --rz-button-border-radius: 999px;
}
.rz-dialog { font-family: var(--font); }
.rz-dialog-titlebar { font-family: var(--font-display); font-weight: 700; }
.rz-dialog .rz-button { text-transform: none; letter-spacing: 0; font-weight: 700; min-height: var(--tap); padding-inline: 20px; box-shadow: none; }
/* The only confirm dialog is Delete, so its OK button is the destructive one */
.rz-dialog-confirm-buttons .rz-button.rz-primary { background: var(--danger); color: #fff; }
