/* Daily Vegetable Order page styling */

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f0f0f0;
    margin: 0;
    padding: 20px;
    color: #222;
}

.sheet {
    max-width: 1000px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #999;
    padding: 16px 20px 24px;
}

.page-header {
    margin-bottom: 14px;
}

.order-number-bar {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.order-number-bar .field-row {
    /* only the input is narrow - the lookup result below it can grow
       as wide as it needs to so its columns are never cut off */
    flex: 1;
    min-width: 0;
}

.order-number-bar #order-number {
    width: 150px;
}

h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

h2 {
    font-size: 14px;
    color: #555;
    margin: 0;
    font-weight: normal;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

th, td {
    border: 1px solid #ccc;
    padding: 5px 8px;
    text-align: left;
}

th {
    background: #e6e6e6;
    font-weight: bold;
}

tr:nth-child(even) {
    background: #fafafa;
}

.error {
    color: #b00020;
}

.empty {
    color: #666;
}

/* Dialog */
dialog#order-dialog {
    border: 1px solid #999;
    border-radius: 4px;
    padding: 0;
    box-sizing: border-box;
    width: 300px;
    max-width: 94vw;
    max-height: 90vh;
    overflow-y: auto;
}

dialog#order-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.dialog-header {
    background: #2f4f4f;
    color: #fff;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: bold;
    cursor: move;
    user-select: none;
}

.dialog-body {
    padding: 16px;
}

.field-row {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.autocomplete-wrap {
    /* keeps the suggestion list positioned against this field only */
}

.suggestions {
    list-style: none;
    margin: 0;
    padding: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #bbb;
    max-height: 160px;
    overflow-y: auto;
    z-index: 10;
}

.suggestions:empty {
    border: none;
}

.suggestions li {
    padding: 6px 8px;
    font-size: 12.5px;
    cursor: pointer;
}

.suggestions li:hover {
    background: #2f4f4f;
    color: #fff;
}

.field-row label {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #444;
}

.label-hint {
    font-weight: normal;
    font-style: italic;
    color: #777;
    font-size: 11px;
    margin-left: 6px;
}

.field-row input {
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid #bbb;
    box-sizing: border-box;
}

#item-name {
    /* sized to fit ~30 characters, but never wider than the dialog.
       content-box here so the 30ch is the actual typing area, not
       shrunk by padding/border like the border-box default above. */
    box-sizing: content-box;
    width: 30ch;
    max-width: 100%;
}

.field-row input:disabled {
    background: #eee;
    color: #999;
}

#order-lookup-result {
    margin-top: 8px;
    max-width: 100%;
    overflow-x: auto;
}

#order-lookup-result .checking {
    color: #666;
    font-size: 12px;
    font-style: italic;
    margin: 0;
}

#order-lookup-result .continue-input {
    color: #1a5d1a;
    background: #eaf7ea;
    border: 1px solid #a9d8a9;
    padding: 6px 8px;
    font-size: 12.5px;
    font-weight: bold;
    margin: 6px 0 0;
}

#order-lookup-result .new-order {
    color: #a15c00;
    background: #fff4e0;
    border: 1px solid #f0c988;
    padding: 6px 8px;
    font-size: 12.5px;
    font-weight: bold;
    margin: 0;
}

#order-lookup-result .error {
    color: #b00020;
    font-size: 12px;
    margin: 0;
}

#order-lookup-result table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

#order-lookup-result th,
#order-lookup-result td {
    border: 1px solid #ccc;
    padding: 3px 5px;
    white-space: nowrap;
}

#order-lookup-result th {
    background: #e6e6e6;
    font-size: 10px;
    font-weight: bold;
    white-space: normal;
    word-break: break-word;
    max-width: 90px;
    line-height: 1.2;
}

.field-hint {
    color: #666;
    font-size: 11.5px;
    margin: -4px 0 8px;
}

.save-error {
    color: #b00020;
    font-size: 12.5px;
    margin-top: 4px;
}

.save-error:empty {
    margin-top: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #eee;
}

.dialog-actions button {
    padding: 7px 16px;
    font-size: 13px;
    cursor: pointer;
    border: none;
}

.dialog-actions .save-btn {
    background: #2f4f4f;
    color: #fff;
}

.dialog-actions .save-btn:hover {
    background: #1f3a3a;
}

.dialog-actions .cancel-btn {
    background: #eee;
    color: #333;
}

.dialog-actions .cancel-btn:hover {
    background: #ddd;
}

.print-btn {
    margin-top: 10px;
    background: #2f4f4f;
    color: #fff;
    border: none;
    padding: 7px 16px;
    font-size: 13px;
    cursor: pointer;
}

.print-btn:hover {
    background: #1f3a3a;
}

/* Smaller, tighter dialog for phone screens. */
@media (max-width: 480px) {
    dialog#order-dialog {
        width: 88vw;
        max-width: 88vw;
    }

    .dialog-header {
        padding: 8px 12px;
        font-size: 14px;
    }

    .dialog-body {
        padding: 10px 12px;
    }

    .field-row {
        margin-bottom: 8px;
    }

    .field-row label {
        font-size: 11px;
        margin-bottom: 2px;
    }

    .field-row input {
        padding: 7px 8px;
        /* 16px keeps iOS Safari from auto-zooming in when the field
           is focused - a smaller size here actually makes the page
           harder to fit, not easier. */
        font-size: 16px;
    }

    #item-name {
        /* let it use the dialog's full width instead of a fixed 30ch,
           which is wider than most phone screens can spare. Switch to
           border-box here so 100% actually means "fits the container"
           instead of adding padding/border on top and overflowing it. */
        box-sizing: border-box;
        width: 100%;
    }

    .label-hint {
        display: block;
        margin-left: 0;
        font-size: 10px;
    }

    .field-hint {
        font-size: 10.5px;
        margin: -2px 0 6px;
    }

    .dialog-actions {
        padding: 8px 12px;
        gap: 6px;
    }

    .dialog-actions button {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Printing shows only the order lookup table - hide the input, hints,
   and the Print button itself. */
@media print {
    body {
        background: #fff;
        padding: 0;
    }
    .sheet {
        border: none;
        max-width: none;
    }
    .no-print,
    label[for="order-number"],
    #order-number {
        display: none;
    }
}
