/* ── Create Order two-panel layout ──────────────────────────────────────── */

.co-page {
    display: flex;
    height: calc(100vh - 96px);
    min-height: 500px;
    overflow: hidden;
}

/* ── Left panel ──────────────────────────────────────────────────────────── */

.co-left-panel {
    width: 340px;
    min-width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 2px solid #e5e5e5;
    background: #f8f9fa;
}

.co-panel-header {
    padding: 14px 16px 12px;
    background: #1a3a5c;
    color: #fff;
    flex-shrink: 0;
}

.co-panel-title {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 2px;
}

.co-panel-subtitle {
    font-size: 12px;
    opacity: 0.75;
}

.co-left-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Sections ────────────────────────────────────────────────────────────── */

.co-section {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 10px 12px;
}

.co-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.co-field-label {
    font-size: 11px;
    color: #777;
    margin-bottom: 3px;
    display: block;
}

.co-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.co-readonly {
    background: #f5f5f5 !important;
    color: #666;
    border-color: #e0e0e0 !important;
}

.co-transport-hint {
    font-weight: 400;
    color: #aaa;
    margin-left: 4px;
}

/* ── Fixed options ───────────────────────────────────────────────────────── */

.co-fixed-options {
    display: flex;
    gap: 6px;
    border-radius: 6px;
    padding: 6px 8px;
    transition: background 0.2s;
}

.co-fixed-options.co-fixed-none { background: #fff; }
.co-fixed-options.co-fixed-partial { background: #dbeafe; }
.co-fixed-options.co-fixed-all { background: #dcfce7; }

.co-fixed-check {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    color: #444;
    padding: 4px 8px;
    border-radius: 5px;
    border: 1px solid #ddd;
    background: rgba(255,255,255,0.6);
    flex: 1;
    justify-content: center;
    user-select: none;
}

.co-fixed-check input { margin: 0; cursor: pointer; }
.co-fixed-check span { display: flex; align-items: center; gap: 4px; }

/* ── Status history timeline ─────────────────────────────────────────────── */

.osh-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 4px 0 2px;
}

.osh-entry {
    display: flex;
    gap: 10px;
    position: relative;
}

/* Vertical line between dots */
.osh-entry:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 14px;
    bottom: -8px;
    width: 2px;
    background: #e5e5e5;
}

.osh-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1a3a5c;
    flex-shrink: 0;
    margin-top: 4px;
    z-index: 1;
}

.osh-content {
    flex: 1;
    padding-bottom: 14px;
}

.osh-transition {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 3px;
}

.osh-arrow {
    font-size: 11px;
    color: #aaa;
}

.osh-label-created {
    font-size: 11.5px;
    font-weight: 600;
    color: #555;
    background: #f0f0f0;
    border-radius: 4px;
    padding: 2px 7px;
}

.osh-badge {
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    padding: 2px 7px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.osh-badge-pending   { background: #fef3c7; color: #92400e; }
.osh-badge-changes   { background: #dbeafe; color: #1e40af; }
.osh-badge-confirmed { background: #dcfce7; color: #166534; }
.osh-badge-cancelled { background: #fee2e2; color: #991b1b; }
.osh-badge-finished  { background: #ede9fe; color: #5b21b6; }

.osh-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #aaa;
}

.osh-meta i { margin-right: 2px; }

.osh-empty {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: #ccc;
    padding: 6px 0;
}

/* Dark mode */
[data-theme="dark"] .osh-entry::after { background: #2e2e4a; }
[data-theme="dark"] .osh-dot { background: #4a7fbf; }
[data-theme="dark"] .osh-label-created { background: #2a2a3e; color: #aaa; }
[data-theme="dark"] .osh-meta { color: #666; }
[data-theme="dark"] .osh-empty { color: #555; }

/* ── Right panel ─────────────────────────────────────────────────────────── */

.co-right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    min-width: 0;
}

/* ── Product header row ──────────────────────────────────────────────────── */

.co-product-header {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1fr 1fr 1fr 1fr 1fr;
    gap: 6px;
    padding: 8px 16px;
    background: #f8f9fa;
    border-bottom: 2px solid #e5e5e5;
    flex-shrink: 0;
}

.co-ph-name,
.co-ph-col {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #888;
}

.co-ph-col { text-align: center; }

/* ── Product list ────────────────────────────────────────────────────────── */

.co-product-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.co-product-row {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1fr 1fr 1fr 1fr 1fr;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-left: 4px solid #1a3a5c;
    border-radius: 8px;
    font-size: 13px;
}

.co-product-row.co-price-pending {
    border-left-color: #f5a623;
}

.co-product-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.co-product-col input {
    text-align: center;
    font-size: 13px;
}

.co-product-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.co-product-img-wrap {
    flex-shrink: 0;
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.co-product-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.co-product-text { min-width: 0; flex: 1; }

.co-product-name {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    color: #1a1a2e;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.co-product-sub {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.co-price-chip {
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.co-price-ok { background: #e6f4ea; color: #1e7e34; border: 1px solid #c3e6cb; }
.co-price-warn { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

.co-prices-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.co-price-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.co-price-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.co-price-unit {
    font-weight: 400;
    opacity: 0.7;
    font-size: 10.5px;
}

.co-price-unaccepted {
    font-size: 11px;
    color: #dc3545;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}

.co-price-none {
    font-size: 11px;
    color: #bbb;
    font-style: italic;
}

/* Details-specific: dim products with no ordered quantity */
.co-product-empty {
    opacity: 0.45;
    border-left-color: #ccc !important;
}

/* ── Bottom bar ──────────────────────────────────────────────────────────── */

.co-bottom-bar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-top: 2px solid #e5e5e5;
    background: #fff;
    margin-top: auto;
}

.co-warning-band {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    font-size: 12.5px;
    font-weight: 600;
    color: #dc3545;
    background: #ffeef0;
    border-bottom: 1px solid #f5c6cb;
}

.co-bottom-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
}

.co-bottom-totals {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.co-total-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0 14px;
}

.co-total-item:first-child { padding-left: 0; }

.co-total-item span {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #999;
    white-space: nowrap;
}

.co-total-item strong {
    font-size: 15px;
    color: #1a1a2e;
    font-weight: 700;
    white-space: nowrap;
}

.co-total-divider {
    width: 1px;
    height: 36px;
    background: #e5e5e5;
    margin: 0 6px;
    flex-shrink: 0;
}

.co-total-grand strong {
    font-size: 17px;
    color: #1a3a5c;
}

.co-bottom-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.co-bottom-actions .btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .co-page { flex-direction: column; height: auto; }
    .co-left-panel { width: 100%; min-width: unset; border-right: none; border-bottom: 2px solid #e5e5e5; }
    .co-info-grid { grid-template-columns: 1fr 1fr; }
    .co-product-header,
    .co-product-row { grid-template-columns: 2fr 1fr 1fr 1fr; }
    .co-ph-col:nth-child(n+5),
    .co-product-col:nth-child(n+5) { display: none; }
}

/* ── No contact person warning ───────────────────────────────────────────── */

.co-no-contact-warning {
    background: #fff8e1;
    border: 1px solid #f9a825;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: #7a5800;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.co-no-contact-warning i { color: #f9a825; flex-shrink: 0; }
.co-no-contact-link {
    margin-left: auto;
    font-weight: 600;
    color: #1a3a5c;
    text-decoration: none;
    white-space: nowrap;
}
.co-no-contact-link:hover { text-decoration: underline; }

[data-bs-theme="dark"] .co-no-contact-warning {
    background: #2e2500;
    border-color: #f9a825;
    color: #ffd54f;
}
[data-bs-theme="dark"] .co-no-contact-link { color: #90caf9; }
