/* components.css — кнопки, таблицы, вкладки, модалки, KPI */

/* ========== Кнопки ========== */

/* Строгая нейтральная (основная) */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font-weight: 500;
    font-size: 13px;
    transition: all .25s ease;
    cursor: pointer;
}
.btn:hover {
    background: var(--card-2);
    border-color: var(--line-strong);
}
.btn:active {
    transform: translateY(1px);
}
.btn svg, .btn .icon {
    transition: none;
}
.btn:hover svg, .btn:hover .icon {
    transform: none;
}

/* Золотая 3D (главное действие) */
.btn-gold {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(180deg, #5FD9AB 0%, #14B37D 50%, #0E9F6E 100%);
    color: var(--ink);
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 4px 0 #076B4A, 0 6px 12px rgba(14,159,110,0.3);
    transition: all .15s ease;
    cursor: pointer;
}
.btn-gold:hover {
    background: linear-gradient(180deg, #6FE0B5 0%, #22C58F 50%, #0C9466 100%);
}
.btn-gold:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #076B4A, 0 2px 4px rgba(14,159,110,0.2);
}

/* ========== Сегментный рельс (вкладки) ========== */
.tabs {
    display: inline-flex;
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 4px;
    gap: 2px;
    box-shadow: inset 0 1px 3px rgba(20,26,34,0.04);
}
.tab {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all .2s ease;
    position: relative;
    white-space: nowrap;
}
.tab:hover {
    color: var(--ink);
}
.tab.active {
    background: var(--card);
    color: var(--ink);
    box-shadow: 0 2px 6px rgba(20,26,34,0.08);
}
.tab.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 20%;
    right: 20%;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), #0E9F6E);
    border-radius: 2px;
}
.tab.active .tab-icon {
    color: var(--gold-ink);
}

/* ========== KPI-карточки ========== */
.kpi-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kpi-card.ok::before   { background: var(--ok); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.gold::before { background: linear-gradient(90deg, var(--gold), var(--gold-deep)); }
.kpi-card.blue::before { background: var(--info); }

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--line-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
}
.kpi-label {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

/* ========== Таблицы-реестры ========== */
.data-table {
    width: 100%;
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.data-table thead {
    background: var(--line-soft);
}
.data-table th {
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted-2);
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
    text-align: left;
    cursor: pointer;
    user-select: none;
}
.data-table th:hover {
    color: var(--ink);
}
.data-table td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--ink);
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
.data-table tbody tr:hover {
    background: var(--bg-soft);
    cursor: pointer;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Ячейка с иконкой + текст */
.cell-icon {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.cell-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--ink);
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Единицы измерения и валюта */
.cell-unit {
    color: var(--muted-2);
    font-size: 12px;
    margin-left: 4px;
}

/* ========== Модальные окна ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20,26,32,.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}
.modal-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-height: 88vh;
    max-width: 640px;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(.98);
    transition: none;
}
.modal-overlay.open .modal-card {
    transform: translateY(0) scale(1);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line-soft);
}
.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
}
.modal-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    transition: all .2s;
}
.modal-close:hover {
    background: var(--line-soft);
    color: var(--ink);
}
.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--line-soft);
    gap: 12px;
}

/* ========== Поля форм ========== */
.form-field {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    font-size: 14px;
    transition: border-color .2s, box-shadow .2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(14,159,110,0.15);
}

/* ========== Статусы ========== */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}
.status-ok    { color: var(--ok); }
.status-danger { color: var(--danger); }
.status-wait  { color: var(--muted); }
.status-draft { color: var(--muted-2); }

/* ========== Тёмная тема: точечные правки ========== */
:root[data-theme="dark"] .btn-gold { color: #ffffff; box-shadow: 0 4px 0 #054F37, 0 6px 12px rgba(14,159,110,.18); }
:root[data-theme="dark"] .modal-overlay { background: rgba(6,10,15,.62); }
:root[data-theme="dark"] .form-input:focus { box-shadow: 0 0 0 3px rgba(14,159,110,.22); }
:root[data-theme="dark"] .data-table { border: 1px solid var(--line); }
:root[data-theme="dark"] .tab.active { box-shadow: 0 2px 6px rgba(0,0,0,.4); }

/* ========== Адаптив общих компонентов ========== */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 900px) {
    .modal-card { max-height: 92vh; border-radius: var(--radius-lg); }
    .modal-header { padding: 15px 16px; }
    .modal-body { padding: 15px 16px; }
    .modal-footer { padding: 13px 16px; flex-wrap: wrap; }
    .data-table th, .data-table td { padding: 10px 11px; }
    .tabs { flex-wrap: wrap; border-radius: 13px; }
    .btn { padding: 8px 13px; }
}
@media (max-width: 480px) {
    .data-table th, .data-table td { padding: 9px 9px; font-size: 12.5px; }
    .kpi-card { padding: 15px; }
    .kpi-value { font-size: 21px; }
    .modal-footer { gap: 8px; }
    .modal-footer .btn, .modal-footer .btn-gold { flex: 1; justify-content: center; }
}
