/* ============================================ */
/* GAME-MENUS.CSS - DOM Menus (Building &     */
/* Research), Menu Headers, Building Grid,    */
/* Research Columns, Progress Bars            */
/* ============================================ */

/* ============================================ */
/* DOM MENUS - Building & Research             */
/* ============================================ */
.menu-overlay {
    pointer-events: auto !important;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100 !important;
}

.menu-overlay * {
    pointer-events: auto !important;
}

.dom-menu {
    width: 950px;
    background: rgba(20, 25, 40, 0.98);
    border-radius: 16px;
    overflow: hidden;
}

.dom-menu.research {
    width: 1030px;
}

.dom-menu.building {
    box-shadow: 0 0 0 3px #44ff44, 0 0 30px rgba(68, 255, 68, 0.3);
}

.dom-menu.research {
    box-shadow: 0 0 0 3px #aa44ff, 0 0 30px rgba(170, 68, 255, 0.3);
}

/* Menu Header */
.dom-menu-header {
    display: flex;
    align-items: center;
    padding: 20px 25px;
    position: relative;
}

.dom-menu.building .dom-menu-header {
    background: rgba(68, 255, 68, 0.1);
    border-bottom: 2px solid rgba(68, 255, 68, 0.3);
}

.dom-menu.research .dom-menu-header {
    background: rgba(170, 68, 255, 0.1);
    border-bottom: 2px solid rgba(170, 68, 255, 0.3);
}

.dom-advisor-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 30px;
}

.dom-advisor-portrait {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(180deg, #2a2a3a 0%, #1a1a2a 100%);
    border: 3px solid #44ff44;
    position: relative;
    overflow: hidden;
}

.dom-menu.research .dom-advisor-portrait {
    border-color: #00aaff;
}

.dom-advisor-name {
    margin-top: 8px;
    font-size: 14px;
    color: #44ff44;
}

.dom-menu.research .dom-advisor-name {
    color: #00ccff;
}

.dom-menu-title-section {
    flex: 1;
}

.dom-menu-title {
    font-size: 30px;
    font-weight: bold;
    margin: 0 0 5px 0;
    text-shadow: 0 0 10px currentColor;
}

.dom-menu.building .dom-menu-title {
    color: #44ff44;
}

.dom-menu.research .dom-menu-title {
    color: #aa44ff;
}

.dom-menu-subtitle {
    font-size: 16px;
    color: #888;
    margin: 0;
}

.dom-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 85, 85, 0.2);
    border: 2px solid #ff5555;
    border-radius: 8px;
    color: #ff5555;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: Arial, sans-serif;
}

.dom-close-btn:hover {
    background: rgba(255, 85, 85, 0.4);
    box-shadow: 0 0 15px rgba(255, 85, 85, 0.5);
}

/* Menu Content */
.dom-menu-content {
    padding: 20px;
}

/* Building Grid */
.building-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.build-item {
    background: rgba(40, 60, 80, 0.8);
    border: 2px solid #4488ff;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.build-item.green { background: rgba(42, 68, 40, 0.8); border-color: #88ff44; }
.build-item.purple { background: rgba(56, 40, 80, 0.8); border-color: #aa44ff; }
.build-item.orange { background: rgba(68, 56, 40, 0.8); border-color: #ffaa44; }
.build-item.cyan { background: rgba(40, 40, 80, 0.8); border-color: #4466aa; }
.build-item.teal { background: rgba(40, 56, 56, 0.8); border-color: #66aaaa; }
.build-item.gray { background: rgba(56, 56, 56, 0.8); border-color: #888888; }
.build-item.red { background: rgba(80, 40, 40, 0.8); border-color: #ff4444; }

.build-item:hover {
    background: rgba(60, 80, 100, 0.9);
    border-color: #44ff44;
    box-shadow: 0 0 20px rgba(68, 255, 68, 0.3);
}

.build-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.build-item.locked:hover {
    border-color: inherit;
    box-shadow: none;
    background: inherit;
}

.build-item.built {
    opacity: 0.5;
}

.build-item.built .item-checkmark {
    display: inline;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.item-title {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

.item-cost {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 17px;
    font-weight: bold;
    color: #ffd700;
}

.item-cost.research {
    color: #aa44ff;
}

.dom-coin-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: radial-gradient(circle at 35% 30%, #ffec80 0%, #ffd700 40%, #b8860b 100%);
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px #daa520;
}

.item-desc {
    font-size: 14px;
    color: #888;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.item-info {
    font-size: 14px;
    color: #88ff88;
}

.item-info.blue { color: #88aaff; }
.item-info.green { color: #88ff88; }
.item-info.purple { color: #cc88ff; }
.item-info.orange { color: #ffaa66; }
.item-info.cyan { color: #88ddff; }
.item-info.teal { color: #66dddd; }
.item-info.gray { color: #aaaaaa; }
.item-info.red { color: #ff8888; }

.item-checkmark {
    font-size: 24px;
    color: #44ff44;
    display: none;
}

/* Research Columns */
.research-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.research-columns.two-columns {
    grid-template-columns: repeat(2, 1fr);
}

.research-column h4 {
    font-size: 18px;
    color: #aaa;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
}

.research-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 340px;
    min-height: 340px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    padding-bottom: 10px;
}

.research-items::-webkit-scrollbar {
    width: 8px;
}

.research-items::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.research-items::-webkit-scrollbar-thumb {
    background: rgba(170, 68, 255, 0.5);
    border-radius: 4px;
}

.research-items::-webkit-scrollbar-thumb:hover {
    background: rgba(170, 68, 255, 0.7);
}

.research-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 380px;
}

.research-item {
    background: rgba(40, 40, 60, 0.8);
    border: 2px solid #666;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}

.research-item:hover {
    background: rgba(60, 60, 80, 0.9);
    border-color: #aa44ff;
    box-shadow: 0 0 20px rgba(170, 68, 255, 0.3);
}

.research-item.completed {
    opacity: 0.5;
}

.research-item.completed .item-checkmark {
    display: inline;
}

.research-item.completed .item-cost {
    display: none;
}

.research-item.active {
    border-color: #44ff44;
    background: rgba(40, 60, 40, 0.8);
}

.research-item.queued {
    opacity: 0.8;
}

.research-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.research-item.locked:hover {
    border-color: #666;
    box-shadow: none;
    background: rgba(40, 40, 60, 0.8);
}

.research-item.completed:hover {
    border-color: #444;
    box-shadow: none;
    background: rgba(40, 40, 60, 0.8);
}

.queue-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 12px;
    font-weight: bold;
    color: #ffaa00;
    background: #443300;
    padding: 2px 8px;
    border-radius: 4px;
}

.queue-badge.active {
    color: #44ff44;
    background: #224422;
}

.queue-badge-next {
    position: absolute;
    bottom: 8px;
    right: 70px;
    font-size: 11px;
    color: #ffaa00;
    background: #332200;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Progress Bar */
.research-progress-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(170, 68, 255, 0.2);
}

.progress-label {
    font-size: 15px;
    color: #888;
}

.progress-name {
    font-size: 15px;
    font-weight: bold;
    color: #aa44ff;
    min-width: 140px;
}

.progress-track {
    flex: 1;
    height: 16px;
    background: #222;
    border-radius: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #aa44ff, #ff44aa);
    border-radius: 8px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 15px;
    font-weight: bold;
    color: #aa44ff;
    min-width: 100px;
    text-align: right;
}

.no-research-hint {
    color: #ff8888;
    font-size: 15px;
    font-weight: bold;
    margin: 5px 0 0 0;
}

/* ============================================ */
/* RESEARCH TREE (Design 9)                    */
/* ============================================ */
.research-tree-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 10px;
    overflow-y: auto;
    max-height: 420px;
}

.research-tree-container::-webkit-scrollbar {
    width: 8px;
}

.research-tree-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.research-tree-container::-webkit-scrollbar-thumb {
    background: rgba(170, 68, 255, 0.5);
    border-radius: 4px;
}

.research-branch {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.research-branch[data-category="command"] { background: rgba(50, 100, 255, 0.12); }
.research-branch[data-category="defense"] { background: rgba(0, 200, 255, 0.12); }
.research-branch[data-category="turrets"] { background: rgba(255, 100, 50, 0.12); }
.research-branch[data-category="economy"] { background: rgba(255, 200, 0, 0.12); }

.branch-root {
    min-width: 90px;
    max-width: 90px;
    padding: 12px 8px;
    background: linear-gradient(135deg, #2a3a4a, #1a2a3a);
    border: 2px solid #00aaff;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

.branch-root-name {
    font-size: 13px;
    font-weight: bold;
    line-height: 1.2;
    word-break: break-word;
    hyphens: auto;
}

.branch-connector {
    width: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    align-self: stretch;
    position: relative;
}

.branch-connector::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    background: #444;
}

.branch-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.branch-chain {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 4px 0;
}

.branch-chain::-webkit-scrollbar {
    height: 4px;
}

.branch-chain::-webkit-scrollbar-thumb {
    background: rgba(170, 68, 255, 0.3);
    border-radius: 2px;
}

.tree-node {
    min-width: 60px;
    width: 60px;
    height: 60px;
    margin-left: 3px;
    background: #1a1a2a;
    border: 2px solid #444;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

/* Canvas building background */
.tree-node-bg {
    position: absolute;
    inset: 0;
    width: 60px;
    height: 60px;
    opacity: 0.45;
    pointer-events: none;
    transition: all 0.2s ease;
}

.tree-node:hover .tree-node-bg {
    opacity: 0.7;
    filter: brightness(1.3) drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
    animation: icon-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes icon-pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}

.tree-node:hover {
    transform: scale(1.03);
    z-index: 10;
    border-color: transparent;
    background:
        linear-gradient(#2a2a4a, #2a2a4a) padding-box,
        conic-gradient(from var(--border-angle), #ff00ff, #00ffff, #00ff88, #ffaa00, #ff00ff) border-box;
    animation: border-spin 1.5s linear infinite;
}

@keyframes border-spin {
    from { --border-angle: 0deg; }
    to { --border-angle: 360deg; }
}

@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.tree-node.completed {
    border-color: #00ff88;
    background: #0a2a1a;
}

.tree-node.completed::after {
    content: '✓';
    position: absolute;
    top: -4px;
    right: -4px;
    background: #00ff88;
    color: #000;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 2;
}

.tree-node.active {
    border-color: #ffaa00;
    background: #2a2a0a;
    animation: tree-node-pulse 1.5s ease-in-out infinite;
}

.tree-node.queued {
    border-color: #aa44ff;
    background: #1a1a2a;
}

.tree-node.queued::after {
    content: attr(data-queue);
    position: absolute;
    top: -4px;
    right: -4px;
    background: #aa44ff;
    color: #fff;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 2;
}

.tree-node.locked {
    opacity: 0.35;
    cursor: not-allowed;
}

.tree-node.locked:hover {
    transform: none;
    border-color: #444;
    background: #1a1a2a;
}

.tree-node-tier {
    font-size: 22px;
    line-height: 1;
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6), 0 0 15px rgba(255, 255, 255, 0.4), 1px 1px 3px #000;
    z-index: 1;
}

.tree-node-cost {
    font-size: 14px;
    color: #ddd;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.4), 1px 1px 2px #000;
    z-index: 1;
}

.tree-connector {
    width: 18px;
    height: 2px;
    background: #444;
    flex-shrink: 0;
}

.tree-connector.completed {
    background: #00ff88;
}

.tree-connector.active {
    background: linear-gradient(90deg, #00ff88, #ffaa00);
}

@keyframes tree-node-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 170, 0, 0.4); }
    50% { box-shadow: 0 0 15px rgba(255, 170, 0, 0.7); }
}

/* Research Tooltip */
.research-tooltip {
    position: absolute;
    background: rgba(10, 10, 20, 0.98);
    border: 2px solid #aa44ff;
    border-radius: 8px;
    padding: 12px 15px;
    min-width: 200px;
    max-width: 280px;
    z-index: 10001;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(170, 68, 255, 0.4);
}

.research-tooltip-title {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 6px;
    border-bottom: 1px solid #444;
    padding-bottom: 6px;
}

.research-tooltip-desc {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 8px;
    line-height: 1.4;
}

.research-tooltip-cost {
    font-size: 12px;
    color: #aa44ff;
    font-weight: bold;
}

.research-tooltip-status {
    font-size: 11px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #333;
}

.research-tooltip-status.completed { color: #00ff88; }
.research-tooltip-status.active { color: #ffaa00; }
.research-tooltip-status.queued { color: #aa44ff; }
.research-tooltip-status.locked { color: #ff6666; }
