/* --- Global Inventory Window Styles --- */
#global-inventory-window-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(10, 20, 30, 0.8); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 1500; opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}
#global-inventory-window-overlay.visible { opacity: 1; pointer-events: auto; }

#global-inventory-window {
    background: linear-gradient(145deg, #2c3e50, #212f3c); color: #ecf0f1;
    border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    width: 95%; max-width: 1800px; height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
    border: 1px solid #4a627a;
    transform: translateY(-20px) scale(0.98);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease-out;
}
#global-inventory-window-overlay.visible #global-inventory-window { transform: translateY(0) scale(1); }

.inventory-header {
    padding: 15px 25px; background-color: rgba(0,0,0,0.2);
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #4a627a; flex-shrink: 0;
}
.inventory-header h2 { margin: 0; font-size: 1.5em; font-weight: 600; text-shadow: 1px 1px 3px rgba(0,0,0,0.4); }

.inventory-close-btn {
    background: none; border: none; color: #ecf0f1; font-size: 2.2em;
    cursor: pointer; line-height: 1; transition: transform 0.2s, color 0.2s;
}
.inventory-close-btn:hover { transform: rotate(90deg) scale(1.1); color: #e74c3c; }

.inventory-body { padding: 20px 25px; overflow: hidden; flex-grow: 1; display: flex; flex-direction: column; }

/* --- Controls --- */
.inventory-controls {
    display: flex; gap: 15px; align-items: flex-end;
    margin-bottom: 15px; padding-bottom: 15px;
    border-bottom: 1px solid #4a627a; flex-shrink: 0; flex-wrap: wrap;
}
.control-group { display: flex; flex-direction: column; gap: 5px; flex: 1 1 300px; }
.control-group label { font-size: 0.9em; color: #bdc3c7; font-weight: bold; }
.control-group select {
    width: 100%; background-color: #34495e; border: 1px solid #4a627a;
    color: #ecf0f1; padding: 10px 12px; border-radius: 5px;
    font-size: 1em; box-sizing: border-box; height: 44px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.control-group select:focus { border-color: #1abc9c; outline: none; box-shadow: 0 0 8px rgba(26, 188, 156, 0.4); }
.faction-select-option { font-weight: bold; color: #1abc9c; background-color: #212f3c; }
option { background-color: #34495e; }

/* --- Main Content & Layouts --- */
#inventory-results-container { flex-grow: 1; overflow: hidden; display: flex; flex-direction: column; }

.inventory-summary {
    background-color: rgba(0,0,0,0.2); border-radius: 6px; padding: 10px 15px;
    margin-bottom: 15px; display: flex; justify-content: space-around;
    align-items: center; font-size: 1.1em; color: #bdc3c7;
    flex-shrink: 0; flex-wrap: wrap; gap: 20px;
}
.inventory-summary.detail-summary { justify-content: center; gap: 25px; }
.inventory-summary strong { color: #ecf0f1; }
.inventory-summary img { height: 1.1em; width: 1.1em; margin-left: 8px; vertical-align: middle; }

.inventory-split-view, .faction-view-container { display: flex; gap: 15px; flex-grow: 1; overflow: hidden; }
.resource-list-panel, #faction-resource-panel { flex: 1.2; }
.player-detail-panel, #faction-player-panel { flex: 2.5; }
#faction-detail-panel { flex: 1; }

.resource-list-panel, .faction-panel, .player-detail-panel {
    display: flex; flex-direction: column; overflow: hidden;
    background-color: rgba(0,0,0,0.1); border-radius: 8px;
    border: 1px solid #4a627a; min-width: 0;
}
.faction-panel .detail-table-container, .player-detail-panel .detail-table-container {
    border: none; border-radius: 0; background-color: transparent;
}
.faction-panel .detail-panel-header, .player-detail-panel .detail-panel-header { padding: 0 10px; margin-top: 10px; margin-bottom: 10px; }
.faction-panel .inventory-summary, .player-detail-panel .inventory-summary { margin: 0 10px 10px 10px; padding: 8px 12px; }

.panel-header { padding: 10px; background-color: rgba(0,0,0,0.1); border-bottom: 1px solid #4a627a; flex-shrink: 0; }
.panel-header h3 { margin: 0; font-size: 1.1em; color: #bdc3c7; text-align: center; font-weight: 600; }
.panel-search-input {
    width: 100%; background-color: #2c3e50; border: 1px solid #4a627a;
    color: #ecf0f1; padding: 10px 12px; font-size: 1em;
    box-sizing: border-box; border-radius: 4px;
}
.panel-header > .panel-search-input { border-radius: 5px; width: 100%; margin: 0; }
.panel-search-input.player-search { flex-grow: 1; }
.panel-search-input:focus { border-color: #1abc9c; outline: none; }

.list-items-container { overflow-y: auto; flex-grow: 1; }
.detail-table-container { flex-grow: 1; overflow-y: auto; }

/* --- List Items (Left & Middle Panels) --- */
.list-item {
    padding: 8px 15px; border-bottom: 1px solid #3a5067;
    cursor: pointer; transition: background-color 0.2s;
    display: flex; align-items: center; gap: 15px;
}
.list-item:hover { background-color: rgba(74, 98, 122, 0.5); }
.list-item.active { background-color: rgba(26, 188, 156, 0.15); border-left: 4px solid #1abc9c; padding-left: 11px; }
.list-item.active .list-item-name { color: #1abc9c; }
.list-item-icon { width: 48px; height: 48px; flex-shrink: 0; border-radius: 4px; }
.list-item-details { flex-grow: 1; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.list-item-details.no-icon { padding-left: 4px; }
.list-item-name { font-size: 1.1em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.list-item-subtext { font-size: 0.85em; color: #bdc3c7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.list-item-values { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* --- Table Styles --- */
.inventory-table { width: 100%; border-collapse: collapse; }
.inventory-table th, .inventory-table td { padding: 12px 15px; border-bottom: 1px solid #4a627a; text-align: center; }
.inventory-table th {
    background-color: #34495e; font-weight: bold; color: #1abc9c;
    position: sticky; top: 0; cursor: pointer; user-select: none;
}
.inventory-table th.sort-asc::after, .inventory-table th.sort-desc::after {
    content: ''; display: inline-block; margin-left: 8px; width: 0; height: 0;
    border-left: 5px solid transparent; border-right: 5px solid transparent;
}
.inventory-table th.sort-asc::after { border-bottom: 5px solid #1abc9c; }
.inventory-table th.sort-desc::after { border-top: 5px solid #1abc9c; }
.inventory-table td { vertical-align: middle; }
.inventory-table .player-name-cell { max-width: 250px; text-align: left; }
.inventory-table .player-name-cell div { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.inventory-table.wide .player-name-cell { text-align: center; }
.inventory-table th.player-name-cell { text-align: center; }
.inventory-table tbody tr:nth-child(even) { background-color: rgba(58, 80, 103, 0.5); }
.inventory-table tbody tr.player-row:hover { background-color: #526f8c; }

/* --- Cell Content Styles --- */
.value-cell div { display: flex; justify-content: center; align-items: center; gap: 8px; }
.value-atlas, .value-usd { font-family: 'Courier New', Courier, monospace; display: flex; align-items: center; gap: 8px; }
.value-atlas { color: #F4D03F; font-weight: bold; font-size: 1em; }
.value-usd { color: #58D68D; font-size: 0.9em; }
.value-cell img, .list-item-values img, .focus-resource-total-values img { height: 1.1em; width: 1.1em; vertical-align: middle; }

/* --- Tier Colors & Legend --- */
.inventory-legend { display: flex; justify-content: center; gap: 10px; padding: 8px; background-color: rgba(0,0,0,0.1); border-radius: 6px; }
.legend-item { display: flex; align-items: center; font-size: 0.8em; color: #bdc3c7; }
.legend-color-box { width: 14px; height: 14px; border-radius: 3px; margin-right: 6px; border: 1px solid rgba(255,255,255,0.2); }
.legend-color-box.tier-1 { background-color: #5DADE2; } .amount-cell.tier-1 { color: #5DADE2; }
.legend-color-box.tier-2 { background-color: #48C9B0; } .amount-cell.tier-2 { color: #48C9B0; }
.legend-color-box.tier-3 { background-color: #AF7AC5; } .amount-cell.tier-3 { color: #AF7AC5; }
.legend-color-box.tier-4 { background-color: #F4D03F; } .amount-cell.tier-4 { color: #F4D03F; font-weight: bold; }
.legend-color-box.tier-5 { background-color: #E67E22; } .amount-cell.tier-5 { color: #E67E22; font-weight: bold; }
.legend-color-box.tier-6 { background-color: #EC7063; } .amount-cell.tier-6 { color: #EC7063; font-weight: bold; text-shadow: 0 0 5px rgba(236, 112, 99, 0.5); }

/* --- Faction View & Focus Mode Styles --- */
.faction-global-controls { padding-bottom: 20px; border-bottom: 1px solid #4a627a; margin-bottom: 20px; }
.focus-view-wrapper { display: none; flex-direction: column; flex-grow: 1; min-height: 0; }
.detail-panel-header { display: flex; gap: 10px; margin-bottom: 15px; flex-shrink: 0; align-items: center; }
.detail-panel-header.focus-header { justify-content: flex-start; }
.detail-panel-header.focus-header h3 { margin: 0; flex-grow: 1; text-align: center; color: #F4D03F; }
.back-to-list-btn {
    background: none; border: 1px solid #4a627a; color: #bdc3c7; padding: 6px 12px;
    border-radius: 5px; cursor: pointer; font-size: 0.9em;
    transition: background-color 0.2s, color 0.2s;
}
.back-to-list-btn:hover { background-color: #4a627a; color: white; }

.focus-view-content {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
    align-content: flex-start;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
}
.focus-resource-group {
    background-color: rgba(0,0,0,0.15); border: 1px solid #4a627a;
    border-radius: 8px;
    flex: 1 1 480px;
    max-width: calc(33.333% - 14px);
    display: flex;
    flex-direction: column;
}
@media (max-width: 1700px) {
    .focus-resource-group { max-width: calc(50% - 10px); }
}
@media (max-width: 1100px) {
    .focus-resource-group { max-width: 100%; min-width: 300px; }
}

.focus-resource-header { display: flex; align-items: center; gap: 15px; padding: 12px 15px; background-color: rgba(0,0,0,0.2); }
.focus-resource-icon { width: 40px; height: 40px; border-radius: 4px; flex-shrink: 0; }
.focus-resource-name { flex-grow: 1; font-size: 1.3em; font-weight: 600; color: #1abc9c; text-align: left; }
.focus-resource-total-amount { text-align: center; font-size: 1.1em; color: #bdc3c7; flex-shrink: 0; padding: 0 10px; }
.focus-resource-total-values { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; flex-shrink: 0; }
.focus-resource-total-values img { width: 1em; height: 1em; }
.focus-resource-body { padding: 5px 15px 10px 15px; }
.focus-location-item { display: flex; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid #3a5067; }
.focus-location-item:last-child { border-bottom: none; }
.focus-location-name { color: #bdc3c7; }
.focus-location-amount { font-weight: 500; font-family: 'Courier New', Courier, monospace; }

.placeholder-text.nested {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}
.tab-switcher {
    display: flex;
    width: 100%;
    border-bottom: 1px solid #4a627a;
}
.tab-button {
    flex: 1;
    background: none;
    border: none;
    color: #bdc3c7;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1.1em;
    border-bottom: 3px solid transparent;
    transition: background-color 0.2s, border-color 0.2s;
}
.tab-button:hover {
    background-color: rgba(255,255,255,0.05);
}
.tab-button.active {
    color: #1abc9c;
    font-weight: bold;
    border-bottom-color: #1abc9c;
}