/* ==========================================================================
   RhSolutions.Next — одностраничный дизайн «Подбор аналогов РЕХАУ»
   Дизайн-система по образцу prodmix-demo.rhsolutions.xyz
   ========================================================================== */

:root {
    --bg: #efefef;
    --drop-font-size: 1.15rem;
    --surface: #ffffff;
    --ink: #111111;
    --muted: #4f5b63;
    --brand: #57c7bd;
    --brand-strong: #34b2a6;
    --brand-soft: #f2fbfa;
    --line: #d8d8d8;
    --ui-border: #9eb2bf;
    --ui-border-soft: #c7d2da;
    --ui-soft: #f4f8fb;
    --ui-title: #213747;
    --control-radius: 4px;
    --control-border-width: 2px;
    --danger: #b42318;
    --status: #24526a;
    --note: #738089;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "PT Sans", sans-serif;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
}

h1, h2, h3, h4, .panel-title {
    font-family: "Manrope", sans-serif;
}

a {
    color: var(--brand-strong);
}

/* --------------------------------------------------------------------------
   Страница и панель
   -------------------------------------------------------------------------- */
.page {
    max-width: 1140px;
    margin: 0 auto;
    padding: 32px 20px 56px;
}

.panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--line);
    position: relative;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.panel-title {
    margin: 0;
    font-size: 32px;
    line-height: 1.15;
}

.panel-subtitle {
    margin: 8px 0 14px;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.4;
}

.upload-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Форма загрузки
   -------------------------------------------------------------------------- */
.upload-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.file-input {
    position: relative;
    flex: 1 1 340px;
}

.file-input input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-input span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    min-height: 64px;
    border-radius: var(--control-radius);
    background: var(--surface);
    border: 2px dashed var(--ui-border);
    color: var(--ui-title);
    font-weight: 700;
    font-size: var(--drop-font-size);
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.file-input.is-dragover span {
    border-color: var(--brand-strong);
    background: var(--brand-soft);
    color: #0e534c;
}

.btn-upload {
    min-height: 48px;
    border-radius: var(--control-radius);
    border: none;
    background: var(--brand);
    color: #ffffff;
    padding: 0 24px;
    font-size: 1rem;
    font-weight: 700;
    font-family: "PT Sans", sans-serif;
    cursor: pointer;
    transition: background-color 0.18s ease;
}

.btn-upload:hover:not(:disabled) {
    background: var(--brand-strong);
}

.btn-upload:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.panel-note {
    margin: 14px 2px 0;
    color: var(--note);
    font-size: 0.95rem;
}

.status {
    margin: 12px 2px 0;
    color: var(--status);
    font-weight: 600;
}

.status.is-error {
    color: var(--danger);
}

/* --------------------------------------------------------------------------
   Результаты
   -------------------------------------------------------------------------- */
.results-section {
    margin-top: 22px;
    animation: rise 380ms ease forwards;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: var(--brand);
    border: 1px solid var(--brand-strong);
    color: #ffffff;
    padding: 16px 20px;
    min-height: 64px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.results-info {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 18px;
}

.results-file {
    font-weight: 700;
    font-size: var(--drop-font-size);
}

.results-layout,
.results-counts {
    font-size: 0.95rem;
    opacity: 0.92;
}

.results-notice {
    font-weight: 700;
}

.toggle-deleted {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    font-size: 0.9rem;
    color: #ffffff;
    cursor: pointer;
    user-select: none;
}

.toggle-deleted input {
    accent-color: #ffffff;
    cursor: pointer;
}

.btn-export {
    min-height: 40px;
    border-radius: var(--control-radius);
    border: none;
    background: #ffffff;
    color: var(--brand-strong);
    padding: 0 18px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: "PT Sans", sans-serif;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.btn-export:hover:not(:disabled) {
    background: var(--brand-strong);
    color: #ffffff;
}

.btn-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.results-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-export-ghost {
    background: transparent;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.btn-export-ghost:hover:not(:disabled) {
    background: #ffffff;
    color: var(--brand-strong);
}

.table-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: visible;
}

/* --------------------------------------------------------------------------
   Таблица
   -------------------------------------------------------------------------- */
.analog-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 1rem;
}

.analog-table thead th {
    background: var(--ui-soft);
    color: var(--ui-title);
    font-weight: 700;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.analog-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.analog-table tbody tr:last-child td {
    border-bottom: none;
}

.analog-table .col-num {
    width: 48px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.analog-table .col-qty {
    width: 110px;
    font-variant-numeric: tabular-nums;
}

.analog-table tr.is-muted td {
    color: var(--muted);
    background: var(--ui-soft);
}

.analog-table tr.is-editing {
    position: relative;
    z-index: 10;
}

.pos-source {
    font-weight: 700;
    color: #0e0e0e;
}

/* --- ячейка «Аналог» --- */
.analog-cell {
    min-width: 300px;
}

.analog-sku {
    font-weight: 700;
    color: var(--ink);
}

.btn-row-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--ui-border-soft);
    border-radius: var(--control-radius);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.btn-row-del:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: #fdf3f2;
}

.analog-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    min-height: 38px;
}

.analog-name {
    cursor: pointer;
    color: var(--brand-strong);
    text-decoration: underline dotted;
    font-size: 0.9rem;
    background: none;
    border: none;
    padding: 0;
    font-family: "PT Sans", sans-serif;
}

.analog-name:hover {
    color: var(--ui-title);
}

.cand-select {
    width: 100%;
    max-width: 380px;
    min-height: 40px;
    border: var(--control-border-width) solid var(--ui-border-soft);
    border-radius: var(--control-radius);
    padding: 4px 10px;
    font-family: "PT Sans", sans-serif;
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--ink);
}

.cand-select:focus {
    outline: none;
    border-color: var(--brand);
}

.edit-wrap {
    position: relative;
}

.edit-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.edit-input {
    flex: 1 1 200px;
    min-height: 38px;
    border: var(--control-border-width) solid var(--ui-border-soft);
    border-radius: var(--control-radius);
    padding: 4px 10px;
    font-family: "PT Sans", sans-serif;
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--surface);
}

.edit-input:focus {
    outline: none;
    border-color: var(--brand);
}

.btn-ghost {
    min-height: 36px;
    border: 1px solid var(--ui-border);
    border-radius: var(--control-radius);
    background: var(--surface);
    color: var(--ui-title);
    font-weight: 600;
    font-family: "PT Sans", sans-serif;
    font-size: 0.9rem;
    padding: 0 14px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-ghost:hover {
    border-color: var(--brand-strong);
    color: var(--brand-strong);
}

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    z-index: 30;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--ui-border-soft);
    border-radius: var(--control-radius);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    max-height: 260px;
    overflow-y: auto;
}

.search-results a {
    color: var(--ink);
    text-decoration: none;
    font-size: 0.9rem;
    display: block;
    padding: 5px 8px;
    border-radius: var(--control-radius);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-results a:hover {
    background: var(--ui-soft);
    color: var(--brand-strong);
}

.search-error {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    margin: 0;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--ui-border-soft);
    border-radius: var(--control-radius);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    color: var(--danger);
    font-size: 0.85rem;
    z-index: 30;
}

/* --- «Возможный аналог» --- */
.possible-row td {
    background: var(--ui-soft);
}

.possible-label {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.possible-row ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.possible-row li {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.possible-sku {
    font-weight: 700;
}

.possible-score {
    color: var(--muted);
    font-size: 0.85rem;
}

/* --------------------------------------------------------------------------
   Анимации
   -------------------------------------------------------------------------- */
@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --------------------------------------------------------------------------
   Ошибки Blazor
   -------------------------------------------------------------------------- */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

#blazor-error-ui[data-nosnippet] {
    display: none;
}

/* --------------------------------------------------------------------------
   Адаптив
   -------------------------------------------------------------------------- */
@media (max-width: 820px) {
    .page {
        padding: 18px 12px 44px;
    }

    .panel {
        padding: 16px;
    }

    .table-card {
        overflow-x: auto;
    }

    .panel-title {
        font-size: 26px;
    }

    .upload-form {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-upload {
        width: 100%;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-export {
        width: 100%;
    }
}
