/* ============================================================
   БКМ-СТАТУС — order.css
   Панель "Моя заявка" + модалка отправки.
   Подключается на /price-list/, /calculator/ и любых страницах,
   где используется общая корзина (bkm_order_v1 в localStorage).
   ============================================================ */

/* --- Sidebar panel --- */
.order-panel {
    background: #fff;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: var(--header-h);
    max-height: calc(100vh - var(--header-h));
    overflow: hidden;
}
.order-panel-head {
    background: var(--navy);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.order-panel-title { color: #fff; font-size: 13px; font-weight: 600; }
.order-count {
    background: var(--orange);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 20px;
}
.order-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: #B4B2A9;
    font-size: 13px;
    gap: 10px;
}
#orderItems { flex: 1; overflow-y: auto; }
.order-item {
    padding: 10px 14px;
    border-bottom: 0.5px solid var(--border);
}
.order-item-name { font-size: 12px; font-weight: 600; color: var(--navy); line-height: 1.3; }
.order-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.order-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}
.order-qty {
    width: 70px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    font-size: 12px;
    text-align: right;
    outline: none;
    color: var(--text);
}
.order-qty:focus { border-color: var(--blue); }
.order-item-unit { font-size: 11px; color: var(--text-muted); }
.order-item-sum { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--navy); white-space: nowrap; }
.order-item-del { background: none; border: none; color: #C0CAD4; font-size: 17px; line-height: 1; padding: 0 3px; cursor: pointer; }
.order-item-del:hover { color: var(--red); }
.order-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-page);
    flex-shrink: 0;
}
.order-total-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.order-total-label { font-size: 12px; color: var(--text-muted); }
.order-total-val { font-size: 20px; font-weight: 700; color: var(--navy); }
.order-total-note { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.btn-order-send {
    width: 100%;
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn-order-send:hover { background: #C96A10; }
.btn-order-clear { width: 100%; background: none; border: none; font-size: 11px; color: #aaa; margin-top: 6px; cursor: pointer; }

/* --- Modal --- */
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(20,45,73,0.55); z-index:200; align-items:center; justify-content:center; }
.modal-overlay.open { display:flex; }
.modal { background:#fff; border-radius:var(--radius-lg); width:440px; max-width:96vw; overflow:hidden; max-height:92vh; overflow-y:auto; }
.modal-header { background:var(--navy); padding:14px 18px; display:flex; align-items:center; justify-content:space-between; }
.modal-title { color:#fff; font-size:14px; font-weight:600; }
.modal-close { background:none; border:none; color:rgba(255,255,255,0.6); font-size:22px; cursor:pointer; line-height:1; }
.modal-body { padding:18px; }
.modal-intro { font-size:13px; color:var(--text-muted); margin-bottom:12px; }
.order-summary { background:var(--bg-page); border-radius:var(--radius); padding:10px 12px; margin-bottom:14px; max-height:130px; overflow-y:auto; }
.sum-item { display:flex; justify-content:space-between; font-size:12px; padding:4px 0; border-bottom:0.5px solid var(--border); gap:8px; }
.sum-item:last-child { border:none; }
.modal-footer { padding:0 18px 18px; display:flex; gap:8px; justify-content:flex-end; }
.modal-success { display:flex; flex-direction:column; align-items:center; padding:32px 20px; text-align:center; gap:10px; }
.success-icon { width:54px; height:54px; background:var(--green-bg); border-radius:50%; display:flex; align-items:center; justify-content:center; }
.modal-success h3 { font-size:18px; font-weight:700; color:var(--navy); }
.modal-success p { font-size:13px; color:var(--text-muted); }

/* --- Responsive: aside переезжает в bottom-sheet --- */
@media (max-width: 900px) {
    .order-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 50vh;
        border-left: none;
        border-top: 2px solid var(--navy);
        z-index: 50;
    }
}

/* ============================================================
   Горизонтальная полоса заявки (bar-mode)
   ============================================================ */
.order-bar {
    background: #fff;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: var(--header-h);
    z-index: 40;
    box-shadow: 0 2px 8px rgba(20,45,73,0.04);
}
.order-bar-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    flex-wrap: wrap;
}
.order-bar-icon { color: var(--navy); flex-shrink: 0; }
.order-bar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.order-bar-count {
    background: var(--orange);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 20px;
    min-width: 22px;
    text-align: center;
}
.order-bar-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}
.order-bar-sum {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-left: auto;
}
.order-bar-sum-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.order-bar-sum-val {
    font-size: 17px;
    font-weight: 700;
    color: var(--navy);
    white-space: nowrap;
}
.order-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.order-bar-toggle {
    background: transparent;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--navy);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: border-color 0.15s, background 0.15s;
}
.order-bar-toggle:hover { border-color: var(--navy); background: var(--blue-light); }
.order-bar-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.order-bar-send { white-space: nowrap; padding: 8px 18px; font-size: 13px; }
.order-bar-clear {
    background: none;
    border: none;
    color: #B4B2A9;
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.order-bar-clear:hover { color: var(--red); background: #FCEBEB; }

/* Пустое состояние: скрыть счётчик/сумму/кнопки отправки/очистки/toggle */
.order-bar[data-empty="1"] .order-bar-count,
.order-bar[data-empty="1"] .order-bar-sum,
.order-bar[data-empty="1"] .order-bar-actions .order-bar-toggle,
.order-bar[data-empty="1"] .order-bar-actions .order-bar-send,
.order-bar[data-empty="1"] .order-bar-actions .order-bar-clear {
    display: none;
}
.order-bar:not([data-empty="1"]) .order-bar-empty { display: none; }

/* Раскрытое тело */
.order-bar-body {
    padding: 12px 0 14px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}
.order-bar-body #orderItems {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
}
.order-bar-body .order-item {
    background: var(--bg-page);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}
.order-bar-body-note {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    padding-top: 10px;
}

@media (max-width: 720px) {
    .order-bar-head { gap: 10px; }
    .order-bar-sum { margin-left: 0; order: 3; width: 100%; justify-content: flex-start; }
    .order-bar-actions { order: 4; width: 100%; }
    .order-bar-send { flex: 1; }
}
