/* Header (PO Step 1) Sheet — shared between admin wizard_step1.html and PSC popup.
 * Lifted verbatim from templates/admin/purchasing/purchaseorder/wizard_step1.html
 * (the inline <style> block, lines 7-329). See docs/po-wizard/.
 */

/* ── Top Identity Bar ── */
.po-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a2e;
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 6px 6px 0 0;
    margin-bottom: 0;
}
.po-top-bar .po-identity {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
}
.po-top-bar .po-number {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.po-top-bar .po-supplier {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.65);
}
.po-top-bar .po-collection {
    font-size: 0.95rem;
    color: #c29954;
    font-weight: 600;
}
.po-top-bar .po-meta-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
}
.po-status-pill {
    display: inline-block;
    padding: 0.25rem 0.85rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.po-status-pill.draft { background: #555; color: #fff; }
.po-status-pill.processing { background: #e8a735; color: #1a1a2e; }
.po-status-pill.submitted { background: #2e7d32; color: #fff; }
.po-status-pill.approved { background: #1565c0; color: #fff; }
.po-status-pill.closed { background: #78909c; color: #fff; }
.po-saved-indicator {
    color: rgba(255,255,255,0.5);
    font-size: 0.78rem;
}
.po-saved-indicator .dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.po-saved-indicator .dot.clean { background: #4caf50; }
.po-saved-indicator .dot.dirty { background: #e8a735; }
.po-version-line {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.38);
    margin-top: 2px;
}

/* ── Section Cards ── */
.po-form-body {
    background: #f4f5f7;
    padding: 1.25rem;
    border-radius: 0 0 6px 6px;
    border: 1px solid #ddd;
    border-top: none;
}
.po-section {
    background: #fff;
    border: 1px solid #e2e4e8;
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}
.po-section:last-child { margin-bottom: 0; }
.po-section-header {
    background: #f8f9fb;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #e2e4e8;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.po-section-header h3 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1a1a2e;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.po-section-header .section-icon {
    font-size: 0.9rem;
    opacity: 0.5;
}
.po-section-body {
    padding: 1rem 1.25rem;
}

/* ── Field Grid ── */
.po-field-grid {
    display: grid;
    gap: 0.9rem 1.25rem;
}
.po-field-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.po-field-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.po-field-grid.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.po-field-grid.cols-5 { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }
.po-field-grid.cols-2-1 { grid-template-columns: 2fr 1fr; }
.po-field-grid.cols-2-1-1 { grid-template-columns: 2fr 1fr 1fr; }

.po-field label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #72727e;
    margin-bottom: 0.3rem;
}
.po-field input,
.po-field select,
.po-field textarea {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid #d1d1d9;
    border-radius: 5px;
    font-size: 0.88rem;
    color: #2d2d3a;
    background: #fff;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.po-field input:focus,
.po-field select:focus,
.po-field textarea:focus {
    border-color: #417690;
    outline: none;
    box-shadow: 0 0 0 2px rgba(65,118,144,0.15);
}
.po-field .field-error {
    color: #ba2121;
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

/* ── Symbol Warning Callout ── */
.po-symbol-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    color: #795548;
    margin-top: 0.4rem;
    line-height: 1.4;
}
.po-symbol-warning .warn-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ── KPI Tiles ── */
.po-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}
.po-kpi-tile {
    background: #f8f9fb;
    border: 1px solid #e2e4e8;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    text-align: center;
}
.po-kpi-tile .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.2;
}
.po-kpi-tile .kpi-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #72727e;
    margin-top: 0.15rem;
}
.po-kpi-tile.editable {
    cursor: pointer;
    transition: border-color 0.15s;
}
.po-kpi-tile.editable:hover { border-color: #417690; }
.po-kpi-tile .kpi-edit-fields {
    display: none;
    margin-top: 0.4rem;
}
.po-kpi-tile.editing .kpi-value { display: none; }
.po-kpi-tile.editing .kpi-edit-fields { display: flex; gap: 0.5rem; }
.po-kpi-tile .kpi-edit-fields input {
    width: 100%;
    padding: 0.3rem 0.4rem;
    border: 1px solid #d1d1d9;
    border-radius: 4px;
    font-size: 0.82rem;
    text-align: center;
    box-sizing: border-box;
}

/* ── Delivery Countdown ── */
.delivery-helper {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.2rem;
}
.delivery-helper.green { color: #2e7d32; }
.delivery-helper.amber { color: #e8a735; }
.delivery-helper.red { color: #c62828; }
.delivery-helper.grey { color: #999; }

/* ── Notes ── */
.po-notes-area textarea {
    min-height: 80px;
    max-height: 250px;
    resize: vertical;
}
.po-notes-counter {
    text-align: right;
    font-size: 0.72rem;
    color: #999;
    margin-top: 0.2rem;
}
.po-notes-counter.warn { color: #e8a735; }
.po-notes-counter.full { color: #c62828; }
.po-notes-hint {
    font-size: 0.75rem;
    color: #999;
    font-style: italic;
}

/* ── Sticky Action Bar ── */
.po-action-bar {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 2px solid #e2e4e8;
    padding: 0.6rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 20;
    margin: 1rem -1rem -1rem;
    border-radius: 0 0 6px 6px;
}
.po-action-bar .action-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.po-action-bar .action-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.po-action-bar .btn-primary {
    background: #1a1a2e;
    color: #fff;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.po-action-bar .btn-primary:hover { background: #2d2d4a; }
.po-action-bar .btn-ghost {
    background: transparent;
    color: #666;
    border: 1px solid #d1d1d9;
    padding: 0.5rem 1.25rem;
    border-radius: 5px;
    font-size: 0.85rem;
    cursor: pointer;
}
.po-action-bar .btn-ghost:hover { background: #f5f5f5; }
.po-dirty-state {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #999;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .po-top-bar { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .po-field-grid.cols-3,
    .po-field-grid.cols-4,
    .po-field-grid.cols-5,
    .po-field-grid.cols-2-1-1 { grid-template-columns: 1fr 1fr; }
    .po-kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .po-field-grid.cols-2,
    .po-field-grid.cols-2-1 { grid-template-columns: 1fr; }
}

/* ────────────────────────────────────────────────────────────────────
   VIEW-ONLY mode — linked PO rendered as read-only static spans.
   Triggered when build_header_context(po, view_only=True) is called.
   Used by downstream SOPs (e.g. Client Documents Fan-out PSC 1).
   ──────────────────────────────────────────────────────────────────── */
.po-form-body--view-only .po-field-value {
    display: block;
    padding: 0.45rem 0.65rem;
    background: var(--bk-surface-inset, #f4f5f7);
    border: 1px solid var(--bk-border, #e2e4e8);
    border-radius: var(--bk-radius-sm, 6px);
    color: var(--bk-text, #2d2d3a);
    font-size: 0.9rem;
    line-height: 1.35;
    min-height: 32px;
    word-break: break-word;
}
.po-form-body--view-only .po-field-value--notes {
    min-height: 64px;
    white-space: pre-wrap;
}
.po-form-body--view-only .po-field label {
    color: var(--bk-text-muted, #72727e);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
    display: block;
}
.po-form-body--view-only .po-kpi-tile {
    cursor: default;
}
.po-saved-indicator--readonly .dot.clean {
    background: var(--bk-text-muted, #72727e);
}
.po-saved-indicator--readonly {
    color: var(--bk-text-muted, #72727e);
    font-style: italic;
}
.po-top-bar--view-only {
    background: var(--bk-surface-inset, #f8f9fb);
}
