/* Enhanced styling for Air Curtains GUI v3 -- shared design tokens +
   components, inspired by the BEZA reference (green accent, clean cards,
   rounded fields) but adapted to this app's own pages/navigation, not a
   literal copy. Every template below already links this file -- updating
   components here uplifts all of them at once.

   Цвета берутся из static/cdw-palette.css, своих больше нет: две палитры в
   одном проекте — это то, с чего начиналась вся расходимость. */

/* AIR-CURTAINS-QUICK-SELECTION-UX-01: reserve the scrollbar's own width
   whether or not the current page is tall enough to need one, so navigating
   between a short page and a tall one doesn't change the available content
   width by a scrollbar's worth of pixels. */
html {
    scrollbar-gutter: stable;
}

/* Shared top bar: logo left, page nav center/left, icons right. Opt-in --
   only pages that add <div class="app-header">...</div> to their markup
   get it; existing plain <header><h1> blocks keep working untouched. */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 24px;
}

.app-header .app-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.02em;
    /* Логотип не сжимается и не переносится. Без этого на 1440px ему не
       хватало места под восемь пунктов меню, и «Air Curtains GUI» вставало
       в две строки, растягивая шапку. */
    flex: 0 0 auto;
    white-space: nowrap;
}

.app-header .app-nav {
    display: flex;
    /* Меню переносится по строкам внутри шапки, а не распирает её. Пунктов
       уже восемь, и на ноутбучной ширине они в один ряд не помещаются. */
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 24px;
    flex: 1;
    margin-left: 40px;
}

.app-header .app-nav a {
    white-space: nowrap;
}

/* На узком экране шапка складывается в колонку: логотип сверху, меню под ним
   слева. Иначе меню жмётся к правому краю в четыре ряда по одному пункту. */
@media (max-width: 820px) {
    .app-header {
        flex-direction: column;
        align-items: stretch;
    }

    .app-header .app-nav {
        margin-left: 0;
        justify-content: flex-start;
    }
}

.app-header .app-nav a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
}

.app-header .app-nav a:hover,
.app-header .app-nav a.active {
    color: var(--accent);
}

/* Nav dropdown groups (Инструменты/База знаний) -- plain <details>/<summary>,
   no JS, but the browser's own inline disclosure look (triangle, content
   pushed down in place) reads as broken in a top nav. This turns it into a
   conventional floating panel: only .nav-group-panel is repositioned,
   <summary> stays exactly where it already sits in the row. */
.app-header .app-nav details {
    position: relative;
}

.app-header .app-nav summary {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.app-header .app-nav summary::-webkit-details-marker {
    display: none;
}

.app-header .app-nav summary::after {
    content: "\25be";
    font-size: 0.7em;
}

.app-header .app-nav details[open] summary,
.app-header .app-nav details.has-active summary {
    color: var(--accent);
}

.app-header .app-nav .nav-group-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 200px;
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.app-header .app-nav .nav-group-panel a {
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

.app-header .app-nav .nav-group-panel a:hover {
    background: var(--bg);
}

.app-header .app-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.card {
    background: var(--card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--line);
}

.card-header {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.status-ready {
    background: var(--ok-bg);
    color: var(--ok);
}

.status-partial {
    background: var(--warn-bg);
    color: var(--warn);
}

.status-failed {
    background: var(--bad-bg);
    color: var(--bad);
}

/* start, а не stretch по умолчанию: в сетке ячейка тянется под высоту соседа,
   и пустое поле рядом с полем, у которого три строки подсказки, вырастает
   вдвое. Пустая коробка двойной высоты читается как большое текстовое поле,
   хотя это обычная строка ввода. */
.data-grid,
.file-links,
.field-grid {
    align-items: start;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.data-item {
    background: var(--surface);
    padding: 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
}

.data-label {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.data-value {
    font-weight: 600;
    color: var(--ink);
}

.table-container {
    overflow-x: auto;
    margin: 15px 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--line);
}

.data-table th {
    background: var(--surface);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border: 1px solid var(--line);
}

.data-table td {
    padding: 12px;
    border: 1px solid var(--line);
    vertical-align: top;
}

.data-table tr:nth-child(even) {
    background: var(--surface);
}

.data-table tr:hover {
    background: var(--surface-2);
}

/* Radio-select variant rows (e.g. the curtain-combination picker) --
   matches the reference's table-of-options-with-radio-select pattern. */
.data-table tr.selectable {
    cursor: pointer;
}

.data-table tr.selected {
    background: var(--brand-tint);
}

.warning-box {
    padding: 15px;
    border-radius: var(--radius-sm);
    margin: 10px 0;
    border: 1px solid var(--amber-200);
    background: var(--amber-50);
}

.warning-box.critical {
    border-color: var(--bad-line);
    background: var(--bad-bg);
    color: var(--bad);
}

.warning-box.review {
    border-color: var(--orange-300);
    background: var(--orange-100);
    color: var(--orange-800);
}

.file-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.file-link-card {
    background: var(--surface);
    padding: 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    text-align: center;
}

.file-link-card h4 {
    margin-bottom: 10px;
    color: var(--ink);
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    margin: 5px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--line);
    color: var(--ink-2);
}

.btn-secondary:hover {
    background: var(--line-2);
}

.btn-success {
    background: var(--emerald-500);
    color: white;
}

.btn-success:hover {
    background: var(--emerald-600);
}

.btn-danger {
    background: var(--red-500);
    color: white;
}

.btn-danger:hover {
    background: var(--red-600);
}

.no-data {
    color: var(--muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Shared form field style (rounded box, label above, green focus ring) --
   matches the reference's input styling. Opt-in via .field-styled on the
   wrapping div; existing per-page field CSS is untouched otherwise. */
.field-styled {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.field-styled label {
    font-size: 0.85rem;
    color: var(--muted);
}

.field-styled input,
.field-styled select,
.field-styled textarea {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: var(--font-sans);
    color: var(--ink);
}

.field-styled input:focus,
.field-styled select:focus,
.field-styled textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Хлебные крошки рабочего контура заказа: Проект / Заявка / Проём.
   Ставятся сразу под .app-header на всех экранах, где у пользователя
   есть текущий объект. До этого контекст был виден по-разному на каждом
   экране (баннер, заголовок, ничего), а вернуться на уровень выше можно
   было далеко не отовсюду -- см. аудит 2026-08-07. Заполняются
   acRenderBreadcrumbs() из static/air_curtains_context.js. */
.app-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: -12px 0 20px;
    padding: 10px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 13.5px;
}

.app-breadcrumbs .crumb {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.app-breadcrumbs .crumb:hover {
    text-decoration: underline;
}

.app-breadcrumbs .crumb-current {
    color: var(--text);
    font-weight: 600;
}

/* «Проект:» / «Заявка:» / «Проём:» -- подпись уровня, чтобы цепочка
   читалась без догадок, какой сегмент что означает. */
.app-breadcrumbs .crumb-kind {
    color: var(--muted);
    font-weight: 400;
    margin-right: 4px;
}

.app-breadcrumbs .crumb-sep {
    color: var(--muted);
}

/* Выбор проекта/заказчика/сотрудника (acEntityPickerHtml, ex-acProjectPickerHtml). */
.ac-entity-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin: 10px 0;
}

.ac-entity-picker label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--muted);
}

.ac-entity-picker select,
.ac-entity-picker input {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    min-width: 220px;
}
