/* ===== High-contrast black & white theme (outdoor / sunlight readable) ===== */
:root {
    --ink: #000000;         /* text, borders */
    --paper: #ffffff;       /* surfaces */
    --muted: #666666;       /* secondary text / placeholders */
    --disabled: #b5b5b5;    /* disabled controls */
    --line-width: 2px;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--paper);
    color: var(--ink);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* App shell: header + categories + scrollable grid + bottom dock */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
    background-color: var(--paper);
}

/* Header */
.app-header {
    flex-shrink: 0;
    background-color: var(--paper);
    border-bottom: var(--line-width) solid var(--ink);
    padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--ink);
}

.logo-accent {
    font-weight: 900;
    color: var(--ink);
}

/* Category Navigation */
/* Temporarily hidden by request. Markup and JS stay in place so it can be
   re-enabled by removing this display:none. */
.category-nav {
    display: none;
    flex-shrink: 0;
    background-color: var(--paper);
    padding: 10px 0 12px;
    border-bottom: var(--line-width) solid var(--ink);
}

.category-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 0 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.category-btn {
    flex-shrink: 0;
    padding: 10px 20px;
    border: var(--line-width) solid var(--ink);
    border-radius: 0;
    background-color: var(--paper);
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.category-btn.active {
    background-color: var(--ink);
    color: var(--paper);
}

/* Scrollable grid area */
.grid-area {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
}

.material-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

/* Material Card */
.material-card {
    position: relative;
    background-color: var(--paper);
    color: var(--ink);
    border: var(--line-width) solid var(--ink);
    border-radius: 0;
    padding: 14px 14px 16px;
    min-height: 108px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    -webkit-tap-highlight-color: transparent;
}

.material-card:focus-within {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
}

/* Weighed = inverted card (max contrast, instantly scannable) */
.material-card.weighed {
    background-color: var(--ink);
    color: var(--paper);
}

.material-name {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.2;
    color: inherit;
    word-break: break-word;
}

.material-weight-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.weight-input {
    width: 100%;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 0;
    font-family: inherit;
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.1;
    color: inherit;
}

.weight-input:focus {
    outline: none;
}

.weight-input::placeholder {
    color: var(--muted);
    opacity: 1;
    font-weight: 700;
}

.weight-unit {
    flex-shrink: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: inherit;
}

/* Bottom Control Dock (thumb zone) */
.control-dock {
    flex-shrink: 0;
    background-color: var(--paper);
    border-top: var(--line-width) solid var(--ink);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.collector-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.collector-label {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--ink);
}

.collector-input {
    width: 100%;
    padding: 14px;
    border: var(--line-width) solid var(--ink);
    border-radius: 0;
    background: var(--paper);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
}

.collector-input::placeholder {
    color: var(--muted);
}

.collector-input:focus {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

.send-order-btn {
    width: 100%;
    padding: 16px 18px;
    border: var(--line-width) solid var(--ink);
    border-radius: 0;
    background-color: var(--ink);
    color: var(--paper);
    font-size: 1.15rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.send-order-btn:active {
    transform: scale(0.99);
}

.send-order-btn:disabled {
    background-color: var(--paper);
    color: var(--disabled);
    border-color: var(--disabled);
    cursor: default;
}

.send-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 800;
}

.send-order-btn:disabled .send-count {
    background: var(--disabled);
    color: var(--paper);
}

/* Initial Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    background-color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    padding: 20px;
}

.loading-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--paper);
    margin-bottom: 30px;
}

.loading-bar-container {
    width: 200px;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 0;
    margin: 0 auto 20px;
    overflow: hidden;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: var(--paper);
    transition: width 0.3s ease;
}

.loading-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
}

/* Error Screen */
.error-screen {
    position: fixed;
    inset: 0;
    background-color: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.error-content {
    text-align: center;
    padding: 20px;
}

.error-icon {
    width: 60px;
    height: 60px;
    border: 3px solid var(--ink);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 2rem;
    font-weight: bold;
    color: var(--ink);
}

.error-content h2 {
    color: var(--ink);
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.error-content p {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 25px;
}

.retry-btn {
    padding: 12px 30px;
    background-color: var(--ink);
    color: var(--paper);
    border: var(--line-width) solid var(--ink);
    border-radius: 0;
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
}

/* Touch feedback / no text selection on controls */
.category-btn,
.material-card,
.material-name,
.retry-btn,
.send-order-btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.category-btn:active,
.retry-btn:active {
    opacity: 0.85;
}

/* Small phones */
@media screen and (max-width: 360px) {
    .material-card {
        min-height: 96px;
        padding: 12px;
    }

    .material-name {
        font-size: 1.05rem;
    }

    .weight-input {
        font-size: 1.6rem;
    }
}
