/* Bambeo-flash: клиентский модуль расчёта. Палитра bambeo (zinc + amber). */

:root {
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-soft: #fffbeb;
    --bg: #f4f4f5;
    --card-bg: #ffffff;
    --border: #e4e4e7;
    --text: #27272a;
    --text-muted: #71717a;
    --danger: #dc2626;
    --success-bg: #ecfdf5;
    --success-fg: #065f46;
    --error-bg: #fef2f2;
    --error-fg: #991b1b;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

h1 { font-size: 20px; margin: 0; }
h1, h2 { color: var(--text); }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }

/* --- Шапка --- */
.topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); }
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; gap: 20px;
}
.brand { font-weight: 700; color: var(--text); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    padding: 8px 12px; border-radius: 8px; color: var(--text-muted); text-decoration: none;
}
.nav a.active, .nav a:hover { background: var(--accent-soft); color: var(--text); }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--text-muted); font-size: 13px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-form { display: inline; margin: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }

/* --- Карточки, шапка страницы --- */
.card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; margin-bottom: 16px;
}
.page-header-actions { display: flex; gap: 10px; flex-shrink: 0; }
.page-title { font-size: 20px; margin: 0 0 4px; }
.page-subtitle { margin: 0; color: var(--text-muted); font-size: 13px; }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 16px; }

/* --- Формы --- */
.form-card .fieldset { border: none; padding: 0; margin: 0 0 20px; }
.form-card legend { font-weight: 600; padding: 0 0 10px; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }
.field { grid-column: span 12; }

/* Визуальные строки формы: несколько .grid подряд внутри fieldset.
 * Перенос строки задаёт сам HTML, отступ между .grid равен внутреннему gap сетки. */
.card .grid + .grid { margin-top: 14px; }

.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--text-muted); font-size: 12px; margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font: inherit; color: var(--text); background: var(--card-bg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.actions-bar { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

/* Строка чекбокса постоперации */
.check-row {
    display: flex; align-items: center; gap: 8px; font-weight: 400;
    background: var(--bg); border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.check-row input { width: auto; }

/* Стандартные форматы (пресеты размеров изделия).
 * Высота и скругление — как у полей ввода. */
.size-presets { display: flex; gap: 6px; }
.preset-chip {
    padding: 9px 12px; font: inherit; white-space: nowrap;
    color: var(--text); background: var(--card-bg);
    border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.preset-chip:hover { border-color: var(--accent); }
.preset-chip.active { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }

/* Центрированные колонки формы: 12-колоночная сетка, блоки по центру экрана */
.col-mid   { grid-column: 4 / span 6; }
.col-mid-l { grid-column: 4 / span 3; }
.col-mid-r { grid-column: 7 / span 3; }

/* Кнопки расчёта/сохранения — строкой по центру.
 * Отступы сверху и снизу больше межстрочного, чтобы блок кнопок
 * визуально отделялся от тиража и от строк стоимости. */
.calc-actions { display: flex; justify-content: center; gap: 10px; margin: 18px 0; }

/* «Сохранить»: активная — чёрная (как «Рассчитать»),
   неактивная (disabled) — белая с серой надписью. */
.btn-save { background: var(--text); color: #fff; }
.btn-save:not(:disabled):hover { background: #3f3f46; }
.btn-save:disabled {
    background: var(--card-bg); color: var(--text-muted);
    border: 1px solid var(--border); cursor: not-allowed;
}

/* Строки стоимости после расчёта */
.price-row {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 9px 12px; background: var(--bg); border-radius: 8px;
}
.price-label { color: var(--text-muted); }
.price-value { font-weight: 700; }

/* --- Кнопки --- */
.btn {
    display: inline-block; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
    font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { background: #3f3f46; }
.btn-secondary { background: var(--card-bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--card-bg); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--error-bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }

/* --- Flash-сообщения --- */
.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: var(--success-bg); color: var(--success-fg); }
.flash-error   { background: var(--error-bg); color: var(--error-fg); }
.flash-info    { background: var(--accent-soft); color: var(--text); }

/* --- Бейджи этапов заказа (те же st-*, что в bambeo) --- */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    background: var(--bg); color: var(--text-muted);
}
.st-new { background: #eff6ff; color: #1d4ed8; }
.st-design { background: #fdf2f8; color: #be185d; }
.st-prepress { background: #f0f9ff; color: #0369a1; }
.st-inwork { background: #fffbeb; color: #b45309; }
.st-calculated { background: #f5f3ff; color: #6d28d9; }
.st-confirmed { background: #ecfeff; color: #0e7490; }
.st-ready { background: #ecfdf5; color: #047857; }
.st-closed { background: #f4f4f5; color: #52525b; }
.st-cancelled { background: #fef2f2; color: #b91c1c; }

/* --- Список расчётов --- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search-form { display: flex; align-items: stretch; }
.search-form input[type="text"] {
    width: 260px; height: 38px; padding: 8px 12px;
    border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none;
}
.search-form .icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 38px; flex-shrink: 0;
    border: 1px solid var(--border); border-radius: 0; background: var(--card-bg); color: var(--text-muted);
}
.search-form .icon-btn + .icon-btn { border-left: none; }
.search-form .icon-btn:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.search-form .icon-btn:hover { background: var(--accent-soft); color: var(--accent-hover); }
.search-form .icon-btn.icon-reset:hover { background: #fee2e2; color: var(--danger); }
.search-form:focus-within { box-shadow: 0 0 0 3px rgba(245, 158, 11, .25); }
.search-form:focus-within input[type="text"],
.search-form:focus-within .icon-btn { border-color: var(--accent); outline: none; }

.table-wrap { padding: 0; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-muted); font-size: 11px; font-weight: 700; text-align: center; }
.data-table tr[data-href] { cursor: pointer; }
.data-table tr[data-href]:hover { background: var(--accent-soft); }
.data-table td.num { text-align: right; }
.data-table th.num, .data-table th.qty { text-align: center; }
.data-table td.qty { text-align: center; }
.nowrap { white-space: nowrap; }

/* Сортируемые заголовки (как в bambeo-php) */
.th-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--accent-hover, #b45309); }

/* Колонка действий и иконка удаления (30×30, красная подкраска при hover) */
.col-actions { width: 40px; text-align: center; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    color: var(--text-muted); transition: background .15s, color .15s;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.icon-delete:hover { background: #fee2e2; color: #b91c1c; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- Карточка расчёта --- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.info-cell { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.info-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.info-value { font-weight: 600; }
.calc-table { border-top: 1px solid var(--border); padding-top: 12px; }
.calc-row { display: flex; justify-content: space-between; padding: 6px 0; }
.calc-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 16px; }
.comment-quote { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 16px 0 0; }

/* --- Страница входа --- */
.login-page { background: var(--bg); }
.login-card {
    max-width: 380px; margin: 10vh auto; background: var(--card-bg);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 28px;
}
.login-card h1 { margin-bottom: 4px; font-size: 18px; }
.login-card p.muted { margin-top: 0; }
.login-card label { margin-top: 14px; }

@media (max-width: 720px) {
    .col-2, .col-3, .col-4, .col-6, .col-mid, .col-mid-l, .col-mid-r { grid-column: span 12; }
    .size-presets { flex-wrap: wrap; }
    .user-name { display: none; }
}
