/* ========== Админка — мастер-классы ========== */
.mc-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f4e5ec;
}
.mc-search-item:last-child { border-bottom: none; }
.mc-search-item:hover { background: #fff6f9; }
.mc-search-item.already-added { opacity: 0.5; cursor: not-allowed; }
.mc-search-item img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #fef0f4;
}
.mc-search-item-info { flex: 1; min-width: 0; }
.mc-search-item-name {
    font-size: 0.88rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mc-search-item-meta {
    font-size: 0.78rem;
    color: var(--muted);
}
.mc-selected-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #fef0f4;
    border-radius: 8px;
    font-size: 0.88rem;
}
.mc-selected-item img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.mc-selected-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-selected-item-remove {
    background: none;
    border: none;
    color: #e53935;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
}

.mc-admin-card {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: #fafafa;
    border-radius: 12px;
    margin-bottom: 10px;
    align-items: flex-start;
}
.mc-admin-card-thumb {
    width: 110px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--pink-light);
}
.mc-admin-card-info { flex: 1; min-width: 0; }
.mc-admin-card-info h4 {
    font-size: 0.95rem;
    margin: 0 0 4px;
}
.mc-admin-card-info .meta {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 6px;
}
.mc-admin-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.mc-admin-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    margin-right: 6px;
}
.mc-admin-badge.published { background: #d4edda; color: #155724; }
.mc-admin-badge.draft     { background: #f8d7da; color: #721c24; }
.btn-mc-small {
    padding: 5px 12px;
    font-size: 0.78rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}
.btn-mc-edit   { background: #e8f0fe; color: #1967d2; }
.btn-mc-toggle { background: #fff4e0; color: #b06b00; }
.btn-mc-delete { background: #fdecea; color: #c62828; }

@media (max-width: 560px) {
    .mc-admin-card { flex-direction: column; }
    .mc-admin-card-thumb { width: 100%; height: 180px; }
}

/* ========== Админка ========== */
.admin-form {
    max-width: 600px;
    margin: 2rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}
.admin-form input, .admin-form textarea {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 30px;
    font-family: inherit;
    font-size: 1rem;
}
.admin-form textarea {
    min-height: 120px;
    border-radius: 20px;
    resize: vertical;
}
.admin-form button {
    background: var(--pink);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 40px;
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
}
.admin-form button:hover { background: var(--pink-dark); }
.login-form {
    text-align: center;
    margin-top: 80px;
    padding: 2rem;
    background: #fff;
    max-width: 500px;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}
.login-form h2 { color: var(--pink); margin-bottom: 1rem; }
.login-form input {
    width: 100%;
    max-width: 300px;
    padding: 10px 16px;
    margin: 10px auto;
    display: block;
    border-radius: 40px;
    border: 1px solid #ddd;
    font-size: 1rem;
}
.login-form .hint { margin-top: 1rem; font-size: 0.85rem; color: #888; }
.admin-news-list {
    list-style: none;
    padding: 0;
}
.admin-news-list li {
    border-bottom: 1px solid #eee;
    padding: 0.8rem 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    cursor: grab;
    transition: background 0.15s, opacity 0.15s;
    border-radius: 8px;
    padding-left: 4px;
}
.admin-news-list li:active { cursor: grabbing; }
.admin-news-list li.drag-over {
    background: #fff0f5;
    border-color: var(--pink);
}
.admin-news-list li.dragging {
    opacity: 0.4;
    background: #fce4ec;
}
/* Индикаторы куда упадёт при drop */
.admin-news-list li.drag-over-top,
.admin-news-list li.drag-over-bottom {
    position: relative;
}
.admin-news-list li.drag-over-top::before,
.admin-news-list li.drag-over-bottom::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 4px;
    background: var(--pink);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(233,30,99,0.5);
    z-index: 5;
}
.admin-news-list li.drag-over-top::before    { top: -6px; }
.admin-news-list li.drag-over-bottom::after  { bottom: -6px; }
.admin-news-list .del-btn {
    background: #f8d7da;
    color: #721c24;
    border: none;
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.admin-news-list .del-btn:hover { background: #f5b7b1; }

/* Drag handle иконка */
.drag-handle {
    color: #ccc;
    font-size: 1.1rem;
    cursor: grab;
    flex-shrink: 0;
    padding: 0 4px;
    user-select: none;
    align-self: center;
    transition: color 0.15s;
}
.drag-handle:hover { color: var(--pink); }

/* МК карточки тоже draggable */
.mc-admin-card {
    cursor: grab;
    transition: opacity 0.15s, background 0.15s, transform 0.15s;
}
.mc-admin-card:active { cursor: grabbing; }
.mc-admin-card.dragging { opacity: 0.4; }
.mc-admin-card.drag-over {
    background: #fff0f5;
    outline: 2px solid var(--pink);
    outline-offset: 2px;
}
/* Индикаторы куда упадёт */
.mc-admin-card.drag-over-top,
.mc-admin-card.drag-over-bottom {
    position: relative;
}
.mc-admin-card.drag-over-top::before,
.mc-admin-card.drag-over-bottom::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 4px;
    background: var(--pink);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(233,30,99,0.5);
    z-index: 5;
}
.mc-admin-card.drag-over-top::before    { top: -6px; }
.mc-admin-card.drag-over-bottom::after  { bottom: -6px; }
/* Кнопка "Порядок сохранён" */
.sort-saved-msg {
    font-size: 0.8rem;
    color: #2e7d32;
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}
.sort-saved-msg.show { opacity: 1; }

.message {
    margin-top: 1rem;
    padding: 10px 16px;
    border-radius: 20px;
}
.success { background: #d4edda; color: #155724; }
.error   { background: #f8d7da; color: #721c24; }

.page-section { display: none; }
.page-section.active-section {
    display: block;
    animation: fadeInUp 0.5s ease-out;
    min-height: calc(100vh - 56px);
    width: 100%;
}
#page-admin.active-section {
    padding: 0;
}

/* Паттерн-фон для МК, Новостей и Магазина — через класс на body */
body.has-pattern {
    background: #fdf8fb;
}

/* ========== Админка: тематики ========== */
.topic-admin-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: #fafafa;
    border-radius: 12px;
    margin-bottom: 10px;
}

/* Статистика в админке тематик */
.topics-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.topic-stat {
    background: #fafafa;
    border-radius: 10px;
    padding: 14px 16px;
}
.topic-stat-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.topic-stat-val {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}
.topic-stat-alert {
    background: #fdecea;
}
.topic-stat-alert .topic-stat-val {
    color: #c62828;
}

/* Форма тематики с предпросмотром */
.topic-form-layout {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 24px;
    align-items: start;
}
.topic-form-preview {
    position: sticky;
    top: 80px;
}
.topic-preview-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
#topic-tile-preview {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
@media (max-width: 700px) {
    .topic-form-layout { grid-template-columns: 1fr; }
    .topic-form-preview { position: static; max-width: 240px; }
}

/* Список проблемных товаров */
.topics-broken {
    background: #fff8e1;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
}
.topics-broken-title {
    font-weight: 600;
    color: #b06b00;
    margin-bottom: 8px;
}
.topics-broken-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 180px;
    overflow-y: auto;
}
.topics-broken-list li {
    padding: 4px 0;
    border-bottom: 1px solid #ffe0a3;
    font-size: 0.82rem;
    color: #5d4037;
}
.topics-broken-list li:last-child { border-bottom: none; }
.topics-broken-list code {
    background: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
}
.topic-admin-card.topic-hidden { opacity: 0.55; background: #f5f0f3; }
.topic-admin-cover {
    width: 110px; height: 70px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--pink-light);
    position: relative;
}
.topic-admin-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topic-admin-cover-placeholder {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; opacity: 0.6;
}
.topic-admin-info { flex: 1; min-width: 0; }
.topic-admin-name { font-weight: 600; font-size: 0.95rem; color: var(--text); margin: 0 0 4px; }
.topic-admin-meta { font-size: 0.78rem; color: var(--muted); }
.topic-admin-meta code { background: #fff; padding: 1px 6px; border-radius: 4px; font-size: 0.76rem; }
.topic-admin-actions {
    display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0;
}
/* Кнопки как у МК */
.btn-topic-small {
    padding: 5px 12px;
    font-size: 0.78rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.btn-topic-edit   { background: #e8f0fe; color: #1967d2; }
.btn-topic-toggle { background: #fff4e0; color: #b06b00; }
.btn-topic-delete { background: #fdecea; color: #c62828; }
.topic-hidden-badge {
    font-size: 0.68rem; font-weight: 600;
    background: #999; color: #fff;
    padding: 1px 8px; border-radius: 50px;
    margin-left: 6px; vertical-align: middle;
}
@media (max-width: 560px) {
    .topic-admin-card { flex-direction: column; align-items: stretch; }
    .topic-admin-cover { width: 100%; height: 140px; }
    .topic-admin-actions { justify-content: flex-start; }
}

/* 2-колоночная строка */
.order-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 480px) {
    .order-row-2 { grid-template-columns: 1fr; }
}

/* Подсказка под полем */
.field-hint {
    font-size: 0.75rem;
    color: #bbb;
    margin-top: 4px;
}
.field-hint.ok  { color: #4caf50; }
.field-hint.err { color: #e57373; }

/* Блок ошибок валидации */
.b2b-errors {
    background: #fff0f0;
    border: 1px solid #ffcdd2;
    border-radius: 10px;
    padding: 12px 14px;
    margin: 12px 0;
    font-size: 0.85rem;
    color: #c62828;
}
.b2b-errors ul { margin: 6px 0 0; padding-left: 18px; }
.b2b-errors li { margin-bottom: 3px; }

/* readonly поля — чуть темнее */
.order-field input[readonly] {
    background: #f5f0f3 !important;
    color: var(--muted);
}

/* Список сохранённых организаций в форме заказа */
.b2b-companies-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.b2b-company-card {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border: 1.5px solid #e0d0d8; border-radius: 10px;
    cursor: pointer; transition: all 0.2s; background: #fefcfd;
}
.b2b-company-card:hover { border-color: var(--pink-light); background: #fff0f5; }
.b2b-company-card.selected { border-color: var(--pink); background: #fff0f5; }
.b2b-company-card-icon { font-size: 1.3rem; flex-shrink: 0; }
.b2b-company-card-info { flex: 1; min-width: 0; }
.b2b-company-card-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.b2b-company-card-meta { font-size: 0.78rem; color: var(--muted); margin-top: 1px; }
.b2b-company-card-default { font-size: 0.68rem; color: var(--pink); font-weight: 700; letter-spacing: 0.5px; }
.b2b-add-company-btn {
    width: 100%; padding: 10px; border: 1.5px dashed #d0c0cc; border-radius: 10px;
    background: transparent; color: var(--muted); font-family: 'Raleway', sans-serif;
    font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
    margin-bottom: 4px;
}
.b2b-add-company-btn:hover { border-color: var(--pink); color: var(--pink); background: #fff0f5; }

/* Подписанты — radio-список */
.b2b-sig-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.b2b-sig-radio {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border: 1.5px solid #e0d0d8; border-radius: 10px;
    cursor: pointer; transition: all 0.2s; background: #fefcfd;
}
.b2b-sig-radio:has(input:checked) { border-color: var(--pink); background: #fff0f5; }
.b2b-sig-radio input[type="radio"] { accent-color: var(--pink); flex-shrink: 0; }
.b2b-sig-info { display: flex; flex-direction: column; gap: 1px; }
.b2b-sig-fio  { font-weight: 700; font-size: 0.88rem; color: var(--text); }
.b2b-sig-pos  { font-size: 0.78rem; color: var(--muted); }
.b2b-sig-new  { border-style: dashed; }
.b2b-sig-new:has(input:checked) { border-color: var(--pink); border-style: solid; }

/* B2B поля — приглушённый фокус вместо яркого розового */
#order-legal-fields .order-field input:focus,
#order-legal-fields .order-field textarea:focus,
#order-legal-fields .order-field select:focus {
    border-color: #b0a0b0;
    box-shadow: 0 0 0 3px rgba(100,80,100,0.08);
}
#order-legal-fields .order-field input:not(:placeholder-shown):valid,
#order-legal-fields .order-field input.filled {
    border-color: #c8bfc8;
}
.order-field label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 4px;
    font-weight: 600;
}
.order-field input,
.order-field textarea,
.order-field select {
    width: 100%;
    padding: 10px 16px;
    border: 1.5px solid #e0d0d8;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: 'Raleway', sans-serif;
    transition: border-color 0.2s;
    background: #fefcfd;
}
.order-field input:focus,
.order-field textarea:focus,
.order-field select:focus {
    outline: none;
    border-color: var(--pink);
}
.order-field textarea { resize: vertical; min-height: 80px; }

.order-summary {
    background: var(--pink-light);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 16px 0;
    font-size: 0.9rem;
}
.order-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}
.order-summary-row:last-child { margin-bottom: 0; font-weight: 700; font-size: 1rem; }

.order-btns {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.btn-back {
    flex: 1;
    padding: 12px;
    border: 1.5px solid #ddd;
    background: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Raleway', sans-serif;
    font-size: 0.95rem;
    transition: all 0.2s;
}
.btn-back:hover { border-color: var(--pink); color: var(--pink); }
.btn-submit-order {
    flex: 2;
    padding: 12px;
    background: var(--pink);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-submit-order:hover { background: var(--pink-dark); }
.btn-submit-order:disabled { background: #ccc; cursor: not-allowed; }

/* Статус заказа */
.order-status {
    text-align: center;
    padding: 20px 0;
}
.order-status .status-icon { font-size: 3rem; margin-bottom: 12px; }
.order-status h4 { font-size: 1.2rem; margin-bottom: 8px; }
.order-status p { color: var(--muted); font-size: 0.9rem; }
