/* Custom Scrollbar */
::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}
::-webkit-scrollbar-track {
    background: #1f2937;
}
::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Main Layout */
.tech-tree-wrapper {
    position: relative;
    overflow: auto;
    padding: 8rem 2rem 2rem 2rem; /* Top padding for fixed headers */
    background-image: radial-gradient(#374151 1px, transparent 1px);
    background-size: 20px 20px;
    display: grid;
    gap: 16px;
    width: 100%;
    height: 100%;
    /* Columns and Rows set via JS */
}

/* Headers */
.tier-headers {
    position: absolute;
    top: 0;
    left: 0;
    display: grid;
    padding-left: 2rem;
    padding-top: 0.5rem;
    gap: 16px;
    z-index: 10;
    pointer-events: none;
    grid-auto-flow: dense;
}

.tier-headers .era-header {
    grid-row: 1;
    pointer-events: auto;
}

.tier-headers .tier-header {
    grid-row: 2;
    pointer-events: auto;
}

.tier-header {
    width: 160px; /* Match cell width */
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid #4b5563;
    border-radius: 4px;
    color: #9ca3af;
    font-weight: bold;
    font-size: 1.2rem;
    outline: none;
}

/* Tree Cell */
.tree-cell {
    width: 160px;
    height: 140px;
    background: rgba(17, 24, 39, 0.4);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    padding: 4px;
    gap: 2px;
    position: relative;
    transition: background 0.2s;
    pointer-events: auto;
    outline: none;
}

.tree-cell:hover {
    background: rgba(17, 24, 39, 0.7);
    border-color: #6b7280;
}

/* BR Slot (Button Row) */
.br-slot {
    flex: 1;
    display: flex;
    align-items: stretch;
    position: relative;
    pointer-events: auto;
    outline: none;
}

/* Tank Button Styling */
.tank-btn {
    flex: 1;
    display: flex;
    gap: 4px;
    cursor: pointer;
    transition: transform 0.1s;
    position: relative;
    overflow: visible; /* Allow dropdown */
    pointer-events: auto;
    border: none;
    padding: 0;
    background: none;
    outline: none;
    box-shadow: none;
}

.tank-btn:active {
    transform: scale(0.98);
}

.tank-btn:hover {
    transform: scale(1.02);
    z-index: 20;
}

.tank-btn:focus,
.tank-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.class-strip-side {
    width: 8px;
    height: 100%;
    border-radius: 2px;
    flex-shrink: 0;
}

.btn-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 2px;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
    z-index: 5;
    pointer-events: none;
}

/* 3 Horizontal Strips */
.btn-strip {
    width: 100%;
    transition: all 0.2s;
    border: 1px solid #374151;
    box-sizing: border-box;
    pointer-events: none;
}

.btn-strip.top {
    height: 25%;
    background: #1f2937;
    border-bottom: none;
    border-radius: 2px 2px 0 0;
}

.btn-strip.mid {
    height: 50%;
    background: #1f2937;
    border-top: none;
    border-bottom: none;
    display: flex;
    align-items: center;
    padding-left: 6px;
    position: relative;
}

.btn-strip.bot {
    height: 25%;
    background: #1f2937;
    border-top: none;
    border-radius: 0 0 2px 2px;
}

/* Hover Effects */
.tank-btn:hover .btn-strip {
    background: #374151;
    border-color: #fbbf24;
}

.tank-btn.premium .btn-strip {
    border-color: #fbbf24;
}

.tank-btn.premium .tank-name {
    color: #fbbf24;
}

.tank-name {
    font-size: 0.7rem;
    font-weight: bold;
    color: #e5e7eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    line-height: 1;
    pointer-events: none;
}

.br-label {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.55rem;
    color: #6b7280;
    pointer-events: none;
}

/* Multi-Stack Dropdown */
.stack-badge {
    position: absolute;
    right: -6px;
    top: -6px;
    background: #4b5563;
    color: white;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 4px;
    border: 1px solid #9ca3af;
    z-index: 25;
    pointer-events: none;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 160px;
    background: #1f2937;
    border: 1px solid #4b5563;
    border-radius: 4px;
    z-index: 50;
    padding: 4px;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 10px 15px rgba(0,0,0,0.5);
    pointer-events: auto;
}

.tank-btn.active .dropdown-menu {
    display: flex;
}

.dropdown-item {
    padding: 4px;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-radius: 2px;
    pointer-events: auto;
    outline: none;
}

.dropdown-item:hover {
    background: #374151;
}

.dropdown-item:focus,
.dropdown-item:focus-visible {
    outline: none;
}

/* SVG Lines */
.connector-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Legend */
.legend-panel {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid #4b5563;
    border-radius: 8px;
    padding: 16px;
    z-index: 45;
    max-width: 400px;
}

/* Colors */
.bg-light { background-color: #2f6e22; }
.bg-small { background-color: #7ce65b; }
.bg-medium { background-color: #fcbc6d; }
.bg-mbt { background-color: #eb712a; }
.bg-heavy { background-color: #eb5c5c; }
.bg-superheavy { background-color: #ff0000; }
.bg-tpp { background-color: #990000; }
.bg-spg { background-color: #2689d7; }
.bg-td { background-color: #2b637d; }
.bg-ifv { background-color: #dcc5a0; }
.bg-bmpt { background-color: #9a8460; }
.bg-spaag { background-color: #ff86bc; }
.bg-ersatz { background-color: #d288ff; }
.bg-armoredcar { background-color: #666666; }
.bg-balltank { background-color: #ffffff; }
.bg-infantry { background-color: #b7b7b7; }
.bg-cavalry { background-color: #59987a; }
.bg-assault { background-color: #ffe100; }
.bg-recon { background-color: #59ffe3; }
.bg-drone { background-color: #522098; }
.bg-mlrs { background-color: #1155cc; }

/* Горизонтальная и вертикальная прокрутка */
.tech-tree-wrapper {
    overflow: auto !important;
}

/* Стилизация полос прокрутки */
::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #111827;
}

::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 6px;
    border: 2px solid #111827;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Угол (где встречаются полосы) */
::-webkit-scrollbar-corner {
    background: #111827;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #4b5563 #111827;
}

/* Tooltip для класса техники */
.class-strip-side {
    position: relative;
}

.class-strip-side::after {
    content: attr(data-class);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    background: rgba(0, 0, 0, 0.9);
    color: #e5e7eb;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
    border: 1px solid #4b5563;
}

.class-strip-side:hover::after {
    opacity: 1;
}

/* Nation Parent Cell */
.nation-parent {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    position: absolute;
    left: -174px;
    top: 0;
    width: 160px;
    height: 100%;
    z-index: 15;
    pointer-events: auto;
    outline: none;
}

.nation-parent:hover {
    background: rgba(17, 24, 39, 0.9);
    border-color: #6b7280;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 15;
}

.nation-parent:focus,
.nation-parent:focus-visible {
    outline: none;
}

.nation-flag {
    width: 32px;
    height: 20px;
    border-radius: 2px;
    object-fit: cover;
    border: 1px solid #4b5563;
    flex-shrink: 0;
    pointer-events: none;
}

.nation-label {
    font-size: 0.65rem;
    font-weight: bold;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    pointer-events: none;
}

.nation-label span {
    display: block;
    font-size: 0.6rem;
    color: #6b7280;
    margin-top: 1px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    outline: none;
}

.modal.active {
    display: flex;
}

.modal > div {
    width: 100%;
    max-width: 900px;
}

/* Штамп FAKE */
.modal-fake-stamp {
    position: absolute;
    top: 0;
    right: -10px;
    width: 200px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 50;
}

.modal-fake-stamp img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Era Headers */
.era-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 4px;
    border-bottom: 2px dashed #4b5563;
    position: relative;
    font-size: 0.7rem;
    line-height: 1.2;
    pointer-events: auto;
    outline: none;
}

.era-label {
    font-weight: bold;
    color: #9ca3af;
    text-align: center;
    white-space: nowrap;
    margin-bottom: 4px;
}

.era-line {
    width: 100%;
    height: 1px;
    background: dashed #4b5563;
}
