/**
 * Стили страницы списка предметов (items) и детальной страницы предмета.
 * Соответствует дизайн-системе components.css, поддержка светлой/тёмной темы.
 */

.page-items.page-components {
    padding-bottom: 2rem;
}

.items-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.items-filters .form-row label,
.items-filter-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--cross-text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.items-search-wrap {
    min-width: 180px;
}
.items-search-wrap .cross-table-search {
    padding-left: 0.25rem;
    padding-right: 2rem;
}
.items-search-btn-icon,
.items-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    color: var(--cross-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}
.items-search-btn-icon:hover,
.items-search-clear:hover {
    color: var(--cross-accent);
}
[data-theme="dark"] .items-search-btn-icon:hover,
[data-theme="dark"] .items-search-clear:hover {
    color: var(--cross-accent-hover);
}
.items-search-clear {
    padding-left: 0.25rem;
    padding-right: 0.75rem;
}

.items-rarity-filters {
    flex-wrap: wrap;
}

/* Кнопка «Все» редкости: белый квадрат с перечёркиванием */
.cross-table-color-btn-all {
    --filter-color: #fff;
    background: #fff;
    position: relative;
    border: 1px solid var(--cross-border);
}
.cross-table-color-btn-all::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--cross-text-muted);
    transform: translateX(-50%) rotate(-45deg);
}
[data-theme="dark"] .cross-table-color-btn-all {
    background: var(--cross-surface);
    border-color: var(--cross-border);
}
[data-theme="dark"] .cross-table-color-btn-all::after {
    background: var(--cross-text-muted);
}

.items-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.items-per-page-select {
    padding: 0.35rem 0.5rem;
    font: inherit;
    color: var(--cross-text);
    background: var(--cross-bg);
    border: 1px solid var(--cross-border);
    border-radius: 0;
    margin-left: 0.5rem;
}

.items-per-page-select:focus {
    outline: none;
    border-color: var(--cross-accent);
    box-shadow: 0 0 0 2px var(--cross-input-focus-shadow);
}

[data-theme="dark"] .items-per-page-select:hover {
    border-color: var(--cross-accent);
}

.items-sort-link {
    color: var(--cross-text);
    text-decoration: none;
}

.items-sort-link:hover {
    color: var(--cross-accent);
    text-decoration: underline;
}

.items-sort-link.is-active {
    color: var(--cross-accent);
    font-weight: 700;
}

[data-theme="dark"] .items-sort-link:hover {
    color: var(--cross-accent-hover);
}

.items-row-link {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding-left: 0.5rem;
    color: var(--cross-text);
    text-decoration: none;
}

.items-row-link:hover {
    color: var(--cross-accent);
}

.items-event-alert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    margin-left: 0.35rem;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    color: var(--cross-text-muted);
    background: var(--cross-surface);
    border: 1px solid var(--cross-border);
    border-radius: 50%;
    vertical-align: middle;
    cursor: help;
}
.items-event-alert:hover {
    color: var(--cross-accent);
    border-color: var(--cross-accent);
}
[data-theme="dark"] .items-event-alert:hover {
    color: var(--cross-accent-hover);
    border-color: var(--cross-accent-hover);
}

[data-theme="dark"] .items-row-link:hover {
    color: var(--cross-accent-hover);
}

/* Выгода: зелёный / красный */
.items-profit-positive {
    background: rgba(34, 197, 94, 0.12);
}

.items-profit-negative {
    background: rgba(239, 68, 68, 0.12);
}

[data-theme="dark"] .items-profit-positive {
    background: rgba(34, 197, 94, 0.18);
}

[data-theme="dark"] .items-profit-negative {
    background: rgba(239, 68, 68, 0.18);
}

.items-pagination {
    margin-top: 1.5rem;
}

.items-pagination-info {
    color: var(--cross-text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.items-pagination-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.items-empty {
    color: var(--cross-text-muted);
    padding: 2rem;
    text-align: center;
}

.items-seo {
    margin-top: 2rem;
}

/* —— Детальная страница предмета (item detail) —— */
.item-detail-header {
    margin-bottom: 2rem;
}

.item-detail-main {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
    background: var(--cross-surface);
    border: 1px solid var(--cross-section-border);
    border-left: 4px solid var(--item-color, var(--cross-accent));
}

.item-detail-icon {
    flex-shrink: 0;
}

.item-detail-info h1 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

.item-detail-prices {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--cross-text-muted);
    font-size: 0.95rem;
}

.item-detail-price {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.item-detail-price .icon-coins {
    flex-shrink: 0;
}

.item-detail-orders {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--cross-text-muted);
    font-size: 0.9rem;
    margin-top: 0.35rem;
}

.item-detail-order {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.item-detail-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
}

.item-detail-filter-row .cross-table-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Табы способов производства */
.item-detail-method-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.item-detail-method-tab {
    padding: 0.5rem 1rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--cross-text);
    background: var(--cross-surface);
    border: 1px solid var(--cross-border);
    border-radius: 0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.item-detail-method-tab:hover {
    border-color: var(--cross-accent);
    color: var(--cross-accent);
}

[data-theme="dark"] .item-detail-method-tab:hover {
    border-color: var(--cross-accent);
    color: var(--cross-accent-hover);
}

.item-detail-method-tab.is-active {
    border-color: var(--cross-accent);
    color: var(--cross-accent);
    font-weight: 600;
}

.item-detail-method-tab.is-unavailable {
    opacity: 0.85;
    border-color: var(--cross-text-muted);
}

.item-detail-method-tab-badge {
    font-size: 0.8rem;
    color: var(--cross-text-muted);
    font-weight: normal;
}

/* Табы контента (Крафт | Итого | Выгода) */
.item-detail-content-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.item-detail-content-tab {
    padding: 0.5rem 1rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--cross-text);
    background: var(--cross-surface);
    border: 1px solid var(--cross-border);
    border-radius: 0;
    cursor: pointer;
}

.item-detail-content-tab:hover {
    border-color: var(--cross-accent);
    color: var(--cross-accent);
}

[data-theme="dark"] .item-detail-content-tab:hover {
    border-color: var(--cross-accent);
    color: var(--cross-accent-hover);
}

.item-detail-content-tab.is-active {
    border-color: var(--cross-accent);
    color: var(--cross-accent);
    font-weight: 600;
    background: var(--cross-bordered-block-bg);
}

.item-detail-content-tab:focus {
    outline: none;
    border-color: var(--cross-accent);
    box-shadow: 0 0 0 2px var(--cross-input-focus-shadow);
}

.item-detail-panel {
    margin-top: 0;
}

.item-detail-panel[hidden] {
    display: none;
}

.item-detail-used-in-desc {
    margin: 0 0 1rem;
    color: var(--cross-text-muted);
    font-size: 0.95rem;
}

.item-detail-used-in-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.item-detail-used-in-list li {
    margin: 0;
}

.item-detail-used-in-link {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding: 0.35rem 0.5rem;
    padding-left: 0.5rem;
    color: var(--cross-text);
    text-decoration: none;
    background: var(--cross-surface);
    border: 1px solid var(--cross-border);
    border-radius: 0;
}

.item-detail-used-in-link:hover {
    border-color: var(--cross-accent);
    color: var(--cross-accent);
}

[data-theme="dark"] .item-detail-used-in-link:hover {
    border-color: var(--cross-accent);
    color: var(--cross-accent-hover);
}

.item-detail-used-in-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--item-color, var(--cross-accent));
}

.item-detail-used-in-icon {
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.item-detail-used-in-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-detail-used-in-empty {
    margin: 0;
    color: var(--cross-text-muted);
    font-size: 0.95rem;
}

.item-detail-pack-select,
.item-detail-item-price-select,
.item-detail-resource-cost-select,
.item-detail-non-resource-cost-select {
    padding: 0.35rem 0.5rem;
    font: inherit;
    color: var(--cross-text);
    background: var(--cross-bg);
    border: 1px solid var(--cross-border);
    border-radius: 0;
}

.item-detail-pack-select:focus,
.item-detail-item-price-select:focus,
.item-detail-resource-cost-select:focus,
.item-detail-non-resource-cost-select:focus {
    outline: none;
    border-color: var(--cross-accent);
    box-shadow: 0 0 0 2px var(--cross-input-focus-shadow);
}

[data-theme="dark"] .item-detail-pack-select:hover,
[data-theme="dark"] .item-detail-item-price-select:hover,
[data-theme="dark"] .item-detail-resource-cost-select:hover,
[data-theme="dark"] .item-detail-non-resource-cost-select:hover {
    border-color: var(--cross-accent);
}

.item-craft-tree-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.item-craft-tree-btn {
    padding: 0.4rem 0.75rem;
    font: inherit;
    font-size: 0.9rem;
    color: var(--cross-text);
    background: var(--cross-surface);
    border: 1px solid var(--cross-border);
    border-radius: 0;
    cursor: pointer;
}

.item-craft-tree-btn:hover {
    border-color: var(--cross-accent);
    color: var(--cross-accent);
}

[data-theme="dark"] .item-craft-tree-btn:hover {
    border-color: var(--cross-accent);
    color: var(--cross-accent-hover);
}

.item-craft-tree-btn:focus {
    outline: none;
    border-color: var(--cross-accent);
    box-shadow: 0 0 0 2px var(--cross-input-focus-shadow);
}

.item-craft-tree {
    margin-top: 1rem;
}

.item-craft-root {
    margin-bottom: 1rem;
}

.item-craft-children-root {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.item-craft-card {
    position: relative;
    border: 2px solid var(--item-color, var(--cross-border));
    padding: 0.75rem;
    background: var(--cross-bordered-block-bg);
}

.item-craft-card-main {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    grid-template-areas: "name sell self";
    align-items: start;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .item-craft-card-main {
        grid-template-columns: 1fr;
        grid-template-areas: "name" "sell" "self";
    }
}

.item-craft-root-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.item-craft-root-block-name {
    grid-area: name;
}

.item-craft-root-block-sell {
    grid-area: sell;
}

.item-craft-root-block-self {
    grid-area: self;
}

.item-craft-block-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--cross-text-muted);
}

.item-craft-profit-badge {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--cross-accent);
    background: rgba(184, 134, 11, 0.2);
    cursor: help;
}

[data-theme="dark"] .item-craft-profit-badge {
    color: var(--cross-accent);
    background: rgba(232, 184, 0, 0.2);
}

.item-craft-profit-badge:hover {
    background: rgba(184, 134, 11, 0.35);
}

[data-theme="dark"] .item-craft-profit-badge:hover {
    background: rgba(232, 184, 0, 0.35);
}

.item-craft-main-formula {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
    color: var(--cross-text-muted);
}

.item-craft-result-badge {
    padding: 0.1rem 0.6rem;
    font-weight: 600;    font-size: 1.25rem;
}

.item-craft-result-profit {
    border: 2px solid #22c55e;
    color: #16a34a;
}

[data-theme="dark"] .item-craft-result-profit {
    border-color: #22c55e;
    color: #4ade80;
}

.item-craft-result-loss {
    border: 2px solid var(--cross-negative);
    color: var(--cross-negative);
}

.item-craft-node {
    margin-bottom: 0.5rem;
}

.item-craft-node.has-children .item-craft-children {
    margin-left: 0;
    margin-top: 0.75rem;
    padding-left: 0;
    border-left: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.item-craft-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    min-height: 2rem;
}

.item-craft-toggle,
.item-craft-toggle-placeholder {
    width: 1.5rem;
    flex-shrink: 0;
    text-align: center;
}

.item-craft-toggle {
    padding: 0;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    color: var(--cross-accent);
    background: none;
    border: none;
    cursor: pointer;
}

.item-craft-toggle:hover {
    color: var(--cross-accent-hover);
}

.item-craft-toggle:focus {
    outline: 2px solid var(--cross-accent);
    outline-offset: 2px;
}

.item-craft-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    color: var(--cross-text);
    text-decoration: none;
}

.item-craft-item:hover {
    color: var(--cross-accent);
}

[data-theme="dark"] .item-craft-item:hover {
    color: var(--cross-accent-hover);
}

.item-craft-item::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1em;
    background: var(--item-color, transparent);
    margin-right: 0.25rem;
}

.item-craft-icon {
    flex-shrink: 0;
}

.item-craft-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-craft-qty {
    flex-shrink: 0;
    color: var(--cross-text-muted);
    font-size: 0.9rem;
}

.item-craft-cost {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.item-craft-cost .icon-coins {
    flex-shrink: 0;
}

.item-craft-formula {
    color: var(--cross-text-muted);
    font-size: 0.9rem;
}

.item-craft-formula-result, .item-craft-formula-result-self {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0.1rem 0.6rem;
}

.item-craft-formula-result.item-craft-result-profit {
    color: #22c55e;
}

[data-theme="dark"] .item-craft-formula-result.item-craft-result-profit {
    color: #4ade80;
}

.item-craft-formula-result.item-craft-result-loss {
    color: var(--cross-negative);
}


.item-totals-table-wrap {
    overflow-x: auto;
}

.item-totals-table .item-totals-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--cross-text);
    text-decoration: none;
}

.item-totals-table .item-totals-link:hover {
    color: var(--cross-accent);
}

[data-theme="dark"] .item-totals-table .item-totals-link:hover {
    color: var(--cross-accent-hover);
}

.item-totals-table .item-totals-link img {
    flex-shrink: 0;
}

.item-totals-table .item-totals-total-row td {
    font-weight: 700;
    border-top: 2px solid var(--cross-border);
    padding-top: 0.75rem;
}

.item-profit-formula p {
    margin: 0 0 1rem;
    color: var(--cross-text-muted);
}

.item-profit-calc {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item-profit-line {
    display: block;
}

.item-profit-minus {
    color: var(--cross-text-muted);
}

.item-profit-result {
    font-size: 1.1rem;
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--cross-section-border);
}

.item-detail-back {
    margin-top: 2rem;
}
