/* ===== DATABASE PAGE STYLES ===== */

/* Search bar */
.db-search-bar {
    display: flex;
    gap: 14px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.db-search-input {
    flex: 1;
    min-width: 280px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.3s;
}

.db-search-input:focus-within {
    border-color: var(--gold-dark);
}

.db-search-input svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.db-search-input input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    width: 100%;
}

.db-search-input input::placeholder {
    color: var(--text-muted);
}

.db-chronicle-select {
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    cursor: pointer;
    min-width: 180px;
    transition: border-color 0.3s;
}

.db-chronicle-select:focus {
    border-color: var(--gold-dark);
}

/* Categories grid */
.db-categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.db-category {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.db-category::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.db-category:hover {
    transform: translateY(-6px);
    border-color: rgba(201, 168, 76, 0.4);
    box-shadow: 0 16px 40px rgba(0,0,0,0.3);
}

.db-category:hover::before {
    opacity: 1;
}

.db-cat-icon {
    font-size: 3rem;
    margin-bottom: 14px;
    filter: drop-shadow(0 4px 12px rgba(201, 168, 76, 0.2));
}

.db-category h3 {
    font-family: 'Inter', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.db-category p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
}

.db-cat-count {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--gold);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ===== INTERNAL DATABASE PAGE LAYOUT ===== */
.db-page-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    align-items: start;
}

.db-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    position: sticky;
    top: 90px;
}

.db-sidebar h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.db-filter-group {
    margin-bottom: 22px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.db-filter-group:last-child {
    border: none;
    margin: 0;
    padding: 0;
}

.db-filter-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.db-filter-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.db-filter-list label:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.db-filter-list input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}

.db-filter-list input[type="checkbox"]:checked {
    background: var(--gold);
    border-color: var(--gold);
}

.db-filter-list input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: #0a0a0f;
    font-size: 11px;
    font-weight: 800;
}

/* Main area */
.db-main {
    min-width: 0;
}

.db-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.db-toolbar input,
.db-toolbar select {
    padding: 11px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.3s;
}

.db-toolbar input { flex: 1; min-width: 220px; }
.db-toolbar input:focus, .db-toolbar select:focus { border-color: var(--gold-dark); }

.db-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

/* Items grid */
.db-items-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.db-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 14px;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.db-item:hover {
    border-color: rgba(201, 168, 76, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.db-item-icon {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(107, 63, 160, 0.2), rgba(42, 74, 138, 0.2));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
    font-size: 1.6rem;
    overflow: hidden;
}

.db-item-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.db-item-body {
    flex: 1;
    min-width: 0;
}

.db-item-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.db-item-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.db-item-tag {
    padding: 2px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.db-item-tag.grade-d { color: #9ca3af; border-color: rgba(156, 163, 175, 0.3); }
.db-item-tag.grade-c { color: #60a5fa; border-color: rgba(96, 165, 250, 0.3); }
.db-item-tag.grade-b { color: #34d399; border-color: rgba(52, 211, 153, 0.3); }
.db-item-tag.grade-a { color: #c9a84c; border-color: rgba(201, 168, 76, 0.3); }
.db-item-tag.grade-s { color: #f87171; border-color: rgba(248, 113, 113, 0.3); }
.db-item-tag.grade-r { color: #b794f4; border-color: rgba(183, 148, 244, 0.3); }

/* Empty state */
.db-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.db-empty span { font-size: 2.5rem; display: block; margin-bottom: 12px; }

/* Detail modal */
.db-modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow: auto;
}

.db-modal-bg.show { display: flex; }

.db-modal {
    max-width: 760px;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    animation: dbModalIn 0.3s ease;
}

@keyframes dbModalIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.db-modal-close {
    position: absolute;
    top: 14px; right: 14px;
    width: 36px; height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    z-index: 5;
    transition: all 0.2s;
}

.db-modal-close:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.db-modal-header {
    padding: 28px;
    display: flex;
    gap: 20px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.db-modal-icon {
    width: 80px; height: 80px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(107, 63, 160, 0.3), rgba(42, 74, 138, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
    font-size: 2.2rem;
    overflow: hidden;
}

.db-modal-icon img {
    width: 100%; height: 100%;
    object-fit: contain;
}

.db-modal-header h2 {
    font-family: 'Inter', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.db-modal-body {
    padding: 28px;
}

.db-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
    font-size: 0.9rem;
}

.db-stat-row:last-child { border-bottom: none; }

.db-stat-row .stat-key {
    color: var(--text-muted);
}

.db-stat-row .stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

.db-section-h3 {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold);
    margin: 24px 0 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.db-section-h3:first-child {
    border: none;
    margin-top: 0;
    padding-top: 0;
}

.db-desc {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

/* Drop list */
.db-drop-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.db-drop-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.88rem;
}

.db-drop-name { color: var(--text-primary); }
.db-drop-chance { color: var(--gold); font-weight: 600; }

/* ===== WIKI / LINEDIA-STYLE DB PAGES ===== */
.db-wiki-page {
    padding-top: 100px;
    padding-bottom: 60px;
    position: relative;
    z-index: 2;
}

.db-breadcrumbs {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.db-breadcrumbs a {
    color: var(--gold);
    text-decoration: none;
}

.db-breadcrumbs a:hover {
    text-decoration: underline;
}

.db-wiki-title {
    margin-bottom: 24px;
}

.db-wiki-title h1 {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    margin-bottom: 6px;
}

.db-wiki-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.db-wiki-nav h3 {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 18px 0 10px;
}

.db-wiki-nav h3:first-child {
    margin-top: 0;
}

.db-wiki-nav a {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.db-wiki-nav a:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.db-wiki-nav a.active {
    background: rgba(201, 168, 76, 0.12);
    color: var(--gold);
    font-weight: 700;
}

.db-wiki-nav a.type-link {
    font-size: 0.8rem;
    padding: 6px 10px;
}

.db-grade-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.db-grade-tab {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.db-grade-tab:hover {
    border-color: rgba(201, 168, 76, 0.4);
    color: var(--text-primary);
}

.db-grade-tab.active {
    background: rgba(201, 168, 76, 0.15);
    border-color: rgba(201, 168, 76, 0.45);
    color: var(--gold);
}

.db-grade-section {
    margin-bottom: 36px;
    scroll-margin-top: 100px;
}

.db-grade-section-title {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    color: var(--gold);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(201, 168, 76, 0.2);
}

.db-type-section {
    margin-bottom: 24px;
    scroll-margin-top: 110px;
}

.db-type-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.db-type-section-title span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}

.db-l2-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.db-l2-table th {
    background: rgba(201, 168, 76, 0.08);
    color: var(--gold);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.db-l2-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
    vertical-align: middle;
}

.db-l2-table tr:last-child td {
    border-bottom: none;
}

.db-l2-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.db-l2-table tbody tr:hover {
    background: rgba(201, 168, 76, 0.04);
}

.db-l2-icon {
    width: 40px;
    padding: 6px 8px !important;
}

.db-l2-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    display: block;
}

.db-l2-name {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 140px;
}

.db-l2-stat {
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
}

.db-l2-desc {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.4;
    max-width: 360px;
}

.grade-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 800;
    margin-right: 4px;
}

.grade-NG { background: rgba(150, 150, 150, 0.15); color: #aaa; }
.grade-D { background: rgba(180, 180, 180, 0.15); color: #ccc; }
.grade-C { background: rgba(52, 211, 153, 0.12); color: #34d399; }
.grade-B { background: rgba(96, 165, 250, 0.12); color: #60a5fa; }
.grade-A { background: rgba(167, 139, 250, 0.12); color: #a78bfa; }
.grade-S { background: rgba(251, 146, 60, 0.12); color: #fb923c; }

.db-nav-matrix-wrap {
    overflow-x: auto;
    margin-bottom: 20px;
}

.db-nav-matrix {
    display: grid;
    grid-template-columns: 110px repeat(6, 1fr);
    gap: 2px;
    min-width: 640px;
    font-size: 0.72rem;
}

.db-nav-matrix a,
.db-nav-matrix span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    min-height: 34px;
}

.db-nav-matrix a:hover {
    border-color: rgba(201, 168, 76, 0.45);
    color: var(--gold);
    background: rgba(201, 168, 76, 0.06);
}

.db-nav-matrix a.active {
    background: rgba(201, 168, 76, 0.15);
    border-color: rgba(201, 168, 76, 0.45);
    color: var(--gold);
}

.db-nav-matrix .mx-h {
    background: rgba(201, 168, 76, 0.1);
    color: var(--gold);
    font-weight: 800;
}

.db-nav-matrix .mx-r {
    justify-content: flex-start;
    padding-left: 10px;
    color: var(--text-primary);
}

.db-nav-matrix .mx-empty {
    opacity: 0.25;
    pointer-events: none;
}

/* Calculator styles */
.db-calc-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.db-calc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.db-calc-card:hover {
    transform: translateY(-4px);
    border-color: rgba(201, 168, 76, 0.3);
}

.db-calc-card-icon {
    font-size: 2.5rem;
    margin-bottom: 14px;
}

.db-calc-card h3 {
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.db-calc-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1024px) {
    .db-categories-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .db-page-layout {
        grid-template-columns: 220px 1fr;
    }
}

@media (max-width: 768px) {
    .db-categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .db-items-grid {
        grid-template-columns: 1fr;
    }
    .db-page-layout {
        grid-template-columns: 1fr;
    }
    .db-sidebar {
        position: static;
    }
    .db-calc-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .db-categories-grid {
        grid-template-columns: 1fr;
    }
    .db-search-bar {
        flex-direction: column;
    }
    .db-chronicle-select {
        width: 100%;
    }
}

/* ===== СТАТИЧНОЕ ЛЕВЫЕ МЕНЮ С ТРЕЯМИ (LINEDIA STYLE) ===== */

.db-sidebar {
    position: sticky;
    top: 90px;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}

.db-sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.db-sidebar-item {
    position: relative;
}

.db-sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid transparent;
}

.db-sidebar-link .chevron-icon {
    color: var(--text-muted);
    transition: transform 0.25s, color 0.25s;
}

/* Эффект наведения на основной пункт */
.db-sidebar-link:hover,
.db-sidebar-item:hover .db-sidebar-link {
    background: rgba(201, 168, 76, 0.08);
    color: var(--text-primary);
    border-color: rgba(201, 168, 76, 0.2);
    box-shadow: inset 0 0 12px rgba(201, 168, 76, 0.05);
}

.db-sidebar-item:hover .chevron-icon {
    transform: translateX(3px);
    color: var(--gold);
}

/* Всплывающий боковой трей подкатегорий (Submenu) */
.db-sidebar-tray {
    position: absolute;
    left: 100%;
    top: -6px;
    width: 260px;
    background: rgba(13, 13, 18, 0.94);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    margin-left: 14px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-12px);
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(201, 168, 76, 0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 120;
}

/* Декоративная стрелочка трея */
.db-sidebar-tray::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 20px;
    border: 6px solid transparent;
    border-right-color: var(--border);
}

/* Активация трея при наведении */
.db-sidebar-item:hover .db-sidebar-tray {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.tray-title {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 6px 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 6px;
}

.db-tray-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.db-tray-link span {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.db-tray-link:hover {
    background: rgba(201, 168, 76, 0.12);
    color: var(--gold);
    padding-left: 16px;
}

.db-tray-link:hover span {
    color: var(--gold);
    background: rgba(201, 168, 76, 0.15);
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ (АДАПТИВ РЕШЕНИЕ) ===== */
@media (max-width: 768px) {
    .db-sidebar {
        position: static;
        padding: 10px;
        margin-bottom: 20px;
    }
    
    /* На мобильных трей плавно раскрывается вниз (аккордеон), а не вбок */
    .db-sidebar-tray {
        position: relative;
        left: 0;
        top: 0;
        width: 100%;
        margin-left: 0;
        margin-top: 6px;
        box-shadow: none;
        backdrop-filter: none;
        display: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        border-left: 2px solid var(--gold-dark);
        background: rgba(0, 0, 0, 0.15);
    }
    
    .db-sidebar-tray::before { display: none; }
    
    .db-sidebar-item:hover .db-sidebar-tray {
        display: block;
    }
    
    .db-sidebar-item:hover .chevron-icon {
        transform: rotate(90deg);
    }
}

/* ===== СТАТИЧНОЕ ЛЕВЫЕ МЕНЮ С ТРЕЯМИ ПО НАВЕДЕНИЮ ===== */

.db-sidebar {
    position: sticky;
    top: 90px;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.db-sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.db-sidebar-item {
    position: relative;
}

.db-sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.db-sidebar-link .chevron-icon {
    color: var(--text-muted);
    transition: transform 0.2s, color 0.2s;
}

/* Наведение на основную категорию */
.db-sidebar-link:hover,
.db-sidebar-item:hover .db-sidebar-link {
    background: rgba(201, 168, 76, 0.07);
    color: var(--text-primary);
    border-color: rgba(201, 168, 76, 0.18);
}

.db-sidebar-item:hover .chevron-icon {
    transform: translateX(4px);
    color: var(--gold);
}

/* Всплывающий боковой трей подкатегорий */
.db-sidebar-tray {
    position: absolute;
    left: 100%;
    top: -8px;
    width: 270px;
    background: rgba(13, 13, 19, 0.96);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 10px;
    margin-left: 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 30px rgba(201, 168, 76, 0.04);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 200;
}

/* Треугольная стрелочка-указатель */
.db-sidebar-tray::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 22px;
    border: 6px solid transparent;
    border-right-color: var(--border);
}

/* Отображение трея */
.db-sidebar-item:hover .db-sidebar-tray {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.tray-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 4px 10px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 8px;
}

.db-tray-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.18s ease;
}

.db-tray-link span {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    padding: 2px 7px;
    border-radius: 5px;
    transition: all 0.18s;
}

.db-tray-link:hover {
    background: rgba(201, 168, 76, 0.12);
    color: var(--gold);
    padding-left: 16px;
}

.db-tray-link:hover span {
    color: var(--gold);
    background: rgba(201, 168, 76, 0.16);
}

/* Мобильная адаптация: перевод треев в аккордеон раскрывающийся вниз */
@media (max-width: 768px) {
    .db-sidebar {
        position: static;
        margin-bottom: 24px;
    }
    .db-sidebar-tray {
        position: relative;
        left: 0; top: 0;
        width: 100%;
        margin-left: 0; margin-top: 6px;
        box-shadow: none; backdrop-filter: none;
        display: none; opacity: 1; visibility: visible; transform: none;
        border-left: 2px solid var(--gold-dark);
        background: rgba(0, 0, 0, 0.2);
    }
    .db-sidebar-tray::before { display: none; }
    .db-sidebar-item:hover .db-sidebar-tray { display: block; }
    .db-sidebar-item:hover .chevron-icon { transform: rotate(90deg); }
}


/* ==========================================================================
   ГЛОБАЛЬНЫЙ САЙДБАР БАЗЫ ЗНАНИЙ — ЭТАЛОННЫЙ ДИЗАЙН
   ========================================================================== */

/* Обёртка сайдбара */
.db-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    position: sticky;
    top: 90px;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Список меню */
.db-sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Элемент списка (родитель) */
.db-sidebar-item {
    position: relative;
}

/* Ссылка-категория (Кнопка-пилюля) */
.db-sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid transparent;
    cursor: pointer;
}

.db-sidebar-link .chevron-icon {
    color: var(--text-muted);
    transition: transform 0.25s, color 0.25s;
}

/* Состояние наведения на категорию */
.db-sidebar-link:hover,
.db-sidebar-item:hover .db-sidebar-link,
.db-sidebar-link.active {
    background: rgba(201, 168, 76, 0.08);
    color: var(--text-primary);
    border-color: rgba(201, 168, 76, 0.2);
    box-shadow: inset 0 0 12px rgba(201, 168, 76, 0.05);
}

.db-sidebar-link.active {
    color: var(--gold);
    border-color: rgba(201, 168, 76, 0.4);
}

.db-sidebar-item:hover .chevron-icon {
    transform: translateX(3px);
    color: var(--gold);
}

/* Всплывающий трей подкатегорий */
.db-sidebar-tray {
    position: absolute;
    left: 100%;
    top: -6px;
    width: 260px;
    background: rgba(13, 13, 18, 0.96);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    margin-left: 14px; /* Тот самый разрыв */
    opacity: 0;
    visibility: hidden;
    transform: translateX(-12px);
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(201, 168, 76, 0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 120;
}

/* МОСТ (решает проблему закрытия трея при переходе мыши) */
.db-sidebar-tray::after {
    content: '';
    position: absolute;
    right: 100%; /* Прижимаем к левому краю трея */
    top: 0;
    width: 16px; /* Перекрываем margin-left: 14px */
    height: 100%;
    background: transparent;
    z-index: -1;
}

/* Декоративная стрелочка трея */
.db-sidebar-tray::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 20px;
    border: 6px solid transparent;
    border-right-color: var(--border);
}

/* Активация трея при наведении на родителя */
.db-sidebar-item:hover .db-sidebar-tray,
.db-sidebar-item.open .db-sidebar-tray {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Заголовок трея */
.tray-title {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 6px 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 6px;
}

/* Ссылки внутри трея */
.db-tray-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.db-tray-link:hover {
    background: rgba(201, 168, 76, 0.12);
    color: var(--gold);
    padding-left: 16px;
}

/* Активная ссылка в трее */
.db-tray-link.active {
    background: rgba(201, 168, 76, 0.15);
    color: var(--gold);
    font-weight: 700;
}

/* МОБИЛЬНАЯ ВЕРСИЯ (Аккордеон) */
@media (max-width: 768px) {
    .db-sidebar {
        position: static;
        padding: 10px;
    }
    
    .db-sidebar-tray {
        position: relative;
        left: 0;
        top: 0;
        width: 100%;
        margin-left: 0;
        margin-top: 6px;
        box-shadow: none;
        backdrop-filter: none;
        display: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        border-left: 2px solid var(--gold-dark);
        background: rgba(0, 0, 0, 0.15);
    }
    
    .db-sidebar-tray::before, .db-sidebar-tray::after { display: none; }
    
    .db-sidebar-item.open .db-sidebar-tray {
        display: block;
    }
    
    .db-sidebar-item.open .chevron-icon {
        transform: rotate(90deg);
    }
}

/* ===== СЕТКА ОРУЖИЯ (CARD VIEW) ===== */
.db-weapons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.db-weapon-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.db-weapon-card:hover {
    border-color: var(--gold);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(201, 168, 76, 0.2);
    background: var(--bg-card-hover);
}

.db-weapon-card .weapon-icon-wrap {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    transition: transform 0.3s ease;
}

.db-weapon-card:hover .weapon-icon-wrap {
    transform: scale(1.1);
}

.db-weapon-card img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.db-weapon-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 8px;
    height: 2.6em; /* Ограничение в 2 строки для ровности */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; 
    -webkit-box-orient: vertical;
}

.db-weapon-stats {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.db-weapon-stat {
    font-size: 0.75rem;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    color: var(--gold);
    font-weight: 600;
    border: 1px solid rgba(201, 168, 76, 0.2);
}

/* ===== ФИЛЬТРЫ-ПИЛЮЛИ ТИПОВ ОРУЖИЯ (СЕТКА) ===== */
.db-type-pills {
    display: flex;
    flex-wrap: wrap;       /* Позволяет кнопкам переноситься на новую строку */
    justify-content: center; /* Центрирует кнопки для красоты */
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 20px;
    overflow: visible;     /* Убираем скролл */
}

/* Удаляем старые стили скроллбара (теперь они не нужны) */
.db-type-pills::-webkit-scrollbar {
    display: none;
}

.type-pill {
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.type-pill:hover {
    border-color: var(--gold);
    color: var(--gold-light);
    background: rgba(201, 168, 76, 0.05);
}

.type-pill.active {
    background: rgba(201, 168, 76, 0.15);
    border-color: var(--gold);
    color: var(--gold);
    font-weight: 700;
    box-shadow: 0 0 10px rgba(201, 168, 76, 0.2);
}

/* ==========================================================================
   WIKI LIGHT THEME SPECIFIC OVERRIDES (Стабилизация контрастности)
   ========================================================================== */
html[data-theme="light"] .db-sidebar-tray {
    background: rgba(255, 255, 255, 0.98) !important;
    border-color: var(--border) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1), 0 0 20px rgba(0, 0, 0, 0.04) !important;
}
html[data-theme="light"] .db-sidebar-tray::before {
    border-right-color: var(--border) !important;
}
html[data-theme="light"] .tray-title {
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
    color: var(--text-muted) !important;
}
html[data-theme="light"] .db-tray-link {
    color: var(--text-secondary) !important;
}
html[data-theme="light"] .db-tray-link:hover {
    background: rgba(201, 168, 76, 0.12) !important;
    color: var(--gold-dark) !important;
}
html[data-theme="light"] .db-tray-link.active {
    background: rgba(201, 168, 76, 0.18) !important;
    color: var(--gold-dark) !important;
    font-weight: 700;
}
html[data-theme="light"] .db-grade-section-title {
    color: var(--gold-dark) !important;
    border-bottom-color: rgba(201, 168, 76, 0.3) !important;
}
html[data-theme="light"] .db-item-name {
    color: var(--text-primary) !important;
}
html[data-theme="light"] .db-l2-table {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
}
html[data-theme="light"] .db-l2-table th {
    background: rgba(201, 168, 76, 0.1) !important;
    color: var(--gold-dark) !important;
    border-bottom-color: var(--border) !important;
}
html[data-theme="light"] .db-l2-name {
    color: var(--text-primary) !important;
}
html[data-theme="light"] .db-l2-stat {
    color: var(--text-primary) !important;
}
html[data-theme="light"] .db-l2-table tbody tr:hover {
    background: rgba(201, 168, 76, 0.05) !important;
}
html[data-theme="light"] .db-nav-matrix a,
html[data-theme="light"] .db-nav-matrix span {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}
html[data-theme="light"] .db-nav-matrix .mx-h {
    background: rgba(201, 168, 76, 0.12) !important;
    color: var(--gold-dark) !important;
}
html[data-theme="light"] .db-nav-matrix .mx-r {
    color: var(--text-primary) !important;
}
html[data-theme="light"] .db-weapon-stat {
    background: var(--bg-secondary) !important;
    color: var(--gold-dark) !important;
    border-color: rgba(201, 168, 76, 0.3) !important;
}

/* Премиальная глянцевая строка поиска для светлой темы */
html[data-theme="light"] .db-search-input {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 2px 8px rgba(18, 18, 26, 0.04) !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Мягкое золотое свечение при фокусе */
html[data-theme="light"] .db-search-input:focus-within {
    border-color: var(--gold-dark) !important;
    box-shadow: 0 0 12px var(--glow-gold), 0 2px 8px rgba(160, 124, 42, 0.06) !important;
}

/* Защита текста инпута от браузерных дефолтов */
html[data-theme="light"] .db-search-input input {
    background: transparent !important;
    color: var(--text-primary) !important;
}

/* Смягчение контраста иконки лупы */
html[data-theme="light"] .db-search-input svg {
    color: var(--text-muted) !important;
    opacity: 0.8;
}

@media (max-width: 768px) {
    html[data-theme="light"] .db-sidebar-tray {
        background: rgba(0, 0, 0, 0.03) !important;
        border-left-color: var(--gold) !important;
        border-top: none !important;
        border-right: none !important;
        border-bottom: none !important;
    }
}

/* Премиальный тюнинг вложенной таблицы дропа/спойла */
.inline-drop-container {
    animation: fadeIn 0.2s ease-out;
}

.db-inline-drop-table-wrapper {
    max-height: 220px;
    overflow-y: auto;
    margin: 6px 0 12px 0;
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
}

/* Тонкий кастомный скроллбар для таблицы, чтобы не портить дизайн */
.db-inline-drop-table-wrapper::-webkit-scrollbar {
    width: 4px;
}
.db-inline-drop-table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}
.db-inline-drop-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.2);
    border-radius: 4px;
}
.db-inline-drop-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.4);
}

.db-inline-drop-table th {
    position: sticky;
    top: 0;
    background: #111116;
    z-index: 2;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Премиальный тюнинг вложенной таблицы дропа/спойла */
.inline-drop-container {
    animation: fadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.db-inline-drop-table-wrapper {
    max-height: 240px;
    overflow-y: auto;
    margin: 8px 0 14px 0;
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.45);
}

/* Тонкий кастомный скроллбар для таблицы, чтобы не раздувать карточку */
.db-inline-drop-table-wrapper::-webkit-scrollbar {
    width: 4px;
}
.db-inline-drop-table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}
.db-inline-drop-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.25);
    border-radius: 4px;
}
.db-inline-drop-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.45);
}

.db-inline-drop-table th {
    position: sticky;
    top: 0;
    background: #121216;
    z-index: 10;
    box-shadow: inset 0 -1px 0 rgba(201, 168, 76, 0.15);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}