/* ============================================================================
   AudioCAD Pro — css/manager.css
   Автономная таблица стилей для всех страниц менеджеров конструкций (Этап 2)
   ============================================================================ */

:root,
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-header: #1e293b;
    --bg-card: #161e2e;
    --bg-block: #0f172a;
    --bg-input: #0b1120;
    --border-color: #334155;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --accent-color: #38bdf8;
    --accent-hover: #0284c7;
    --btn-sec-bg: #273449;
    --btn-sec-hover: #334155;
}

[data-theme="light"] {
    --bg-body: #f1f5f9;
    --bg-header: #ffffff;
    --bg-card: #ffffff;
    --bg-block: #f8fafc;
    --bg-input: #ffffff;
    --border-color: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #475569;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --btn-sec-bg: #e2e8f0;
    --btn-sec-hover: #cbd5e1;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 12px;
    line-height: 1.35;
}

/* ============================================================================
   1. ШАПКА СТРАНИЦЫ МЕНЕДЖЕРА
   ============================================================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    min-height: 48px;
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-center {
    flex-wrap: wrap;
    justify-content: center;
}

.logo-block {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.3px;
    color: var(--text-main);
    white-space: nowrap;
}

.stage-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-color);
    border: 1px solid rgba(56, 189, 248, 0.45);
    white-space: nowrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-group label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Элементы форм в шапке и карточках */
select,
input[type="number"],
input[type="text"] {
    height: 26px;
    padding: 0 7px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-main);
    font-size: 11.5px;
    outline: none;
}

select:focus,
input:focus {
    border-color: var(--accent-color);
}

input:disabled,
input[readonly] {
    opacity: 0.75;
    cursor: default;
}

.select-driver {
    min-width: 210px;
    max-width: 280px;
}

.select-qtc {
    width: 135px;
}

.input-qtc {
    width: 58px;
    text-align: center;
}

/* Кнопки */
button,
.btn-back,
.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    padding: 0 10px;
    border-radius: 5px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-secondary,
.btn-back {
    background-color: var(--btn-sec-bg);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover,
.btn-back:hover {
    background-color: var(--btn-sec-hover);
}

.btn-accent {
    background-color: var(--accent-color);
    color: #0b1120;
    font-weight: 700;
}

[data-theme="light"] .btn-accent {
    color: #ffffff;
}

.btn-accent:hover {
    background-color: var(--accent-hover);
}

/* ============================================================================
   2. ОСНОВНАЯ СЕТКА НА 6 КАРТОЧЕК В ОДИН РЯД
   ============================================================================ */
.manager-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    padding: 8px 10px 14px;
    width: 100%;
    align-items: stretch;
}

.enclosure-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    padding: 8px;
    border-radius: 8px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    gap: 6px;
}

.enclosure-card.is-recommended-form {
    border-color: rgba(16, 185, 129, 0.8);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.35);
}

/* Шапка карточки */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qtc-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--bg-block);
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    white-space: nowrap;
}

/* Блоки чертежей и графиков */
.card-block {
    border-radius: 6px;
    background-color: var(--bg-block);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.block-svg {
    height: 128px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-svg svg {
    width: 100%;
    height: 100%;
    display: block;
}

.block-chart {
    height: 104px;
}

.block-chart svg {
    width: 100%;
    height: 100%;
    display: block;
}

.placeholder-box {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    color: var(--text-muted);
    text-align: center;
    padding: 6px;
}

/* ============================================================================
   3. СЕТКА 6 МОНИТОРОВ ВНУТРИ КАРТОЧКИ
   ============================================================================ */
.block-monitors {
    padding: 5px;
}

.monitors-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
}

.monitor-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 2px;
    border-radius: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    text-align: center;
    min-width: 0;
}

.mon-label {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mon-value {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 1px;
}

/* Статусы мониторов */
.monitor-item.status-ok {
    border-color: rgba(16, 185, 129, 0.55);
    background: rgba(16, 185, 129, 0.12);
}
.monitor-item.status-ok .mon-value {
    color: #34d399;
}

.monitor-item.status-warn {
    border-color: rgba(245, 158, 11, 0.55);
    background: rgba(245, 158, 11, 0.12);
}
.monitor-item.status-warn .mon-value {
    color: #fbbf24;
}

.monitor-item.status-danger {
    border-color: rgba(239, 68, 68, 0.6);
    background: rgba(239, 68, 68, 0.14);
}
.monitor-item.status-danger .mon-value {
    color: #f87171;
}

[data-theme="light"] .monitor-item.status-ok .mon-value { color: #059669; }
[data-theme="light"] .monitor-item.status-warn .mon-value { color: #d97706; }
[data-theme="light"] .monitor-item.status-danger .mon-value { color: #dc2626; }

/* ============================================================================
   4. КОНТРОЛЫ ПАРАМЕТРОВ ФОРМЫ И ОЦЕНКА
   ============================================================================ */
.block-controls {
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-subblock {
    padding: 4px 5px;
    border-radius: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.dimensions-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
}

.dim-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.dim-field label {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dim-field input {
    width: 100%;
    height: 22px;
    padding: 0 3px;
    font-size: 11px;
    text-align: center;
}

.inline-pair-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
}

.inline-pair-row label {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.inline-pair-row select {
    flex: 1 1 auto;
    min-width: 0;
    height: 22px;
    font-size: 10.5px;
    padding: 0 4px;
}

.iso-vol-pair {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.iso-vol-item {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.iso-vol-item .lbl {
    font-size: 9.5px;
    color: var(--text-muted);
}

.volume-badge-val {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-color);
}

/* Блок резюме */
.block-summary {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-status {
    display: inline-block;
    align-self: flex-start;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

.summary-status.status-good {
    background: rgba(16, 185, 129, 0.16);
    color: #34d399;
}
.summary-status.status-warn {
background: rgba(245, 158, 11, 0.16);
color: #fbbf24;
}
.summary-status.status-bad {
background: rgba(239, 68, 68, 0.16);
color: #f87171;
}
.summary-status.status-neutral {
background: rgba(148, 163, 184, 0.16);
color: var(--text-muted);
}
[data-theme="light"] .summary-status.status-good { color: #059669; }
[data-theme="light"] .summary-status.status-warn { color: #d97706; }
[data-theme="light"] .summary-status.status-bad { color: #dc2626; }
.summary-text {
margin: 0;
font-size: 10.5px;
color: var(--text-muted);
line-height: 1.3;
}
/* ============================================================================
5. НИЖНИЕ КНОПКИ КАРТОЧКИ (ПРИЖАТЫ К НИЗУ)
============================================================================ */
.card-actions-bottom {
margin-top: auto;
padding-top: 6px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 5px;
}
.btn-recalc {
flex: 0 0 auto;
height: 25px;
padding: 0 8px;
font-size: 11px;
background-color: var(--btn-sec-bg);
color: var(--text-main);
border: 1px solid var(--border-color);
}
.btn-recalc:hover {
background-color: var(--btn-sec-hover);
}
.btn-link {
flex: 1 1 auto;
height: 25px;
padding: 0 8px;
font-size: 11px;
background-color: var(--accent-color);
color: #0b1120;
font-weight: 700;
}
[data-theme="light"] .btn-link {
color: #ffffff;
}
.btn-link:hover {
background-color: var(--accent-hover);
}
/* ============================================================================
   6. МОДАЛЬНЫЕ ОКНА ("СХЕМЫ" И "КОРРЕКЦИЯ 36 ПАРАМЕТРОВ") ИЗ APP.JS
   ============================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(9, 13, 22, 0.78);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-window {
    width: 100%;
    max-width: 960px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-subtitle {
    font-size: 11.5px;
    color: var(--accent-color);
    margin-top: 2px;
}

.modal-close {
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    background: var(--btn-sec-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.modal-body {
    padding: 14px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 8px;
}

.param-card {
    padding: 7px 9px;
    border-radius: 6px;
    background: var(--bg-block);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.param-card.changed {
    border-color: var(--accent-color);
}

.param-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
}

.param-unit {
    color: var(--text-muted);
    font-weight: 400;
}

.param-desc {
    display: block;
    font-size: 9.5px;
    line-height: 1.2;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.img-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.modal-img {
    margin: 0;
    padding: 8px;
    border-radius: 6px;
    background: var(--bg-block);
    border: 1px solid var(--border-color);
    text-align: center;
}

.modal-img img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 4px;
}

.modal-img figcaption {
    margin-top: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.pros-cons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.pros h4 { color: #34d399; margin: 0 0 4px; }
.cons h4 { color: #f87171; margin: 0 0 4px; }
.pros ul, .cons ul { margin: 0; padding-left: 16px; color: var(--text-muted); font-size: 11.5px; }


/* ============================================================================
   6. МОДАЛЬНЫЕ ОКНА БЕЗ СКРОЛЛА (ПО ЦЕНТРУ ЭКРАНА)
   ============================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(9, 13, 22, 0.82);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: hidden;
}

.modal-window {
    width: 94vw;
    max-width: 1360px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header > div {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.modal-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-subtitle {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
}

.modal-close {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 13px;
    background: var(--btn-sec-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.modal-body {
    padding: 10px 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Компактная матрица 6 × 6 для всех 36 параметров без скролла */
.params-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
}

.param-card {
    padding: 5px 7px;
    border-radius: 5px;
    background: var(--bg-block);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 3px;
    min-width: 0;
}

.param-card.changed {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.08);
}

.param-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.param-unit {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 9.5px;
}

.param-card input {
    width: 100%;
    height: 22px;
    padding: 0 5px;
    font-size: 11px;
}

/* Скрываем длинную строку описания внутри карточки, оно остаётся во всплывающем title */
.param-desc {
    display: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Модалка «Схемы»: все 3 изображения в один ряд без прокрутки */
.img-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.modal-img {
    margin: 0;
    padding: 6px;
    border-radius: 6px;
    background: var(--bg-block);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.modal-img img {
    width: 100%;
    max-height: 62vh;
    object-fit: contain;
    border-radius: 4px;
}

.modal-img figcaption {
    margin-top: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}
/* Строка названия и единицы измерения внутри карточки параметра */
.param-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
}

/* Слайдер схем (крупное окно + 3 миниатюры снизу без прокрутки) */
.s2-slider-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.s2-slider-caption {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
}

.s2-slider-viewport {
    width: 100%;
    height: 58vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-block);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
}

.s2-slider-viewport img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.s2-slider-thumbs {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.s2-thumb-btn {
    height: 46px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-block);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.s2-thumb-btn.active {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.14);
}

.s2-thumb-btn img {
    height: 34px;
    width: auto;
    object-fit: contain;
}
