/* --- GLOBAL STYLES & FONT IMPORT --- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700&family=Oswald:wght@500&family=Roboto:wght@400;700&display=swap');
:root {
    --primary-bg: #121212; --secondary-bg: #1a1a1a; --border-color: #333; --text-color: #e0e0e0;
    --header-font: 'Cinzel', serif; --nav-font: 'Oswald', sans-serif; --body-font: 'Roboto', sans-serif;
    --accent-color: #B22222; --energy-color: #2E8B57; --grit-color: #4682B4;
    --hp-color: #b30000; --influence-color: #6A5ACD; --player-territory-color: #2E8B57;
    --sidebar-width: 260px; --top-bar-height: 50px;
}
html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; }
body { 
    font-family: var(--body-font); margin: 0; font-size: 16px; overflow: hidden; 
    background-color: var(--primary-bg); color: var(--text-color);
    background-image: url('assets/images/background_texture.png');
}

/* --- UTILITY & LOGIN --- */
.hidden { display: none !important; }
.placeholder-text { color: #666; font-style: italic; text-align: center; }
#login-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 2000; background-image: url('assets/images/background_texture.png'); display: flex; justify-content: center; align-items: center; }
#login-box { width: 90%; max-width: 450px; background-color: rgba(26, 26, 26, 0.95); border: 2px solid var(--border-color); padding: 30px; box-shadow: 0 0 20px rgba(0,0,0,0.7); text-align: center; }
#login-box h1 { font-family: var(--header-font); color: var(--accent-color); font-size: 3em; margin: 0 0 10px; }
#login-box p { color: #aaa; margin-bottom: 25px; }
#login-form label { display: block; margin-bottom: 10px; font-family: var(--nav-font); text-transform: uppercase; }
#login-form input { width: 100%; padding: 12px; background-color: #111; border: 1px solid var(--border-color); color: var(--text-color); font-size: 1.2em; text-align: center; margin-bottom: 20px; }
.login-actions { display: flex; gap: 15px; justify-content: center; }
#login-error-message { margin-top: 15px; color: var(--accent-color); font-weight: bold; min-height: 1.2em; }

/* --- LAYOUT & SIDEBAR --- */
#game-container { display: flex; }
#sidebar { width: var(--sidebar-width); height: 100vh; background-color: rgba(13,13,13,0.95); border-right: 2px solid var(--border-color); display: flex; flex-direction: column; position: fixed; padding: 0; }
#main-wrapper { margin-left: var(--sidebar-width); width: calc(100% - var(--sidebar-width)); height: 100vh; display: flex; flex-direction: column; }
#top-bar { height: var(--top-bar-height); background-color: var(--secondary-bg); border-bottom: 2px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; padding: 0 20px; flex-shrink: 0; }
#main-content { background-color: rgba(31,31,31,0.9); flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
#views { padding: 20px; flex-grow: 1; overflow-y: auto; }
#logo { padding: 10px; border-bottom: 2px solid var(--accent-color); flex-shrink: 0; }
#logo img { display: block; width: 80%; margin: 0 auto; }
#status-container { padding: 15px; flex-shrink: 0; }
#status-container #player-info { font-size: 0.9em; margin-bottom: 20px; background-color: #111; padding: 10px; border: 1px solid var(--border-color); }
#status-container #player-info p { display: flex; justify-content: space-between; margin: 5px 0; }
#status-container #player-info p span:first-child { color: #aaa; }
.resource-bar { margin-bottom: 20px; } .resource-bar label { display: block; margin-bottom: 5px; font-weight: bold; } .bar-container { width: 100%; height: 20px; background-color: var(--primary-bg); border: 1px solid var(--border-color); }
.bar { height: 100%; transition: width 0.3s ease-in-out; } 
#energy-bar { background-color: var(--energy-color); } #grit-bar { background-color: var(--grit-color); } #health-bar { background-color: var(--hp-color); }
.resource-bar span { display: block; text-align: center; margin-top: -19px; color: white; font-size: 0.8em; text-shadow: 1px 1px 2px #000; }
#main-nav { flex-grow: 1; overflow-y: auto; padding: 15px; } #main-nav ul { list-style: none; padding: 0; margin: 0; } #main-nav li { margin-bottom: 5px; }
.nav-link { display: block; text-decoration: none; color: var(--text-color); padding: 12px 15px; background-color: #222; border-left: 3px solid transparent; text-transform: uppercase; font-family: var(--nav-font); font-size: 1.1em; transition: all 0.2s; }
.nav-link:hover { background-color: #2a2a2a; border-left: 3px solid var(--accent-color); color: white; }
.nav-link.active { border-left-color: var(--accent-color); }
.nav-link[disabled] { color: #666; background-color: #1a1a1a; cursor: not-allowed; }
.nav-divider { height: 1px; background-color: var(--border-color); margin: 15px 0; }
.top-link { color: #aaa; text-decoration: none; margin-left: 20px; font-family: var(--nav-font); text-transform: uppercase; transition: color 0.2s; cursor: pointer; } .top-link:hover { color: #fff; }

/* --- DEV MENU --- */
#header-dev-menu { display: flex; align-items: center; gap: 10px; }
#header-dev-menu span { font-family: var(--nav-font); color: var(--accent-color); }
.dev-btn { padding: 4px 8px; font-size: 0.8em; background-color: #333; border: 1px solid #555; color: #ccc; cursor: pointer; }
.dev-btn:hover { background-color: #444; }

/* --- DASHBOARD GRID STYLES --- */
#dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
#dashboard-grid .full-width { grid-column: 1 / -1; }
.dashboard-panel { background-color: var(--secondary-bg); border: 1px solid var(--border-color); padding: 20px; }
.dashboard-panel h3 { font-family: var(--nav-font); text-transform: uppercase; color: var(--accent-color); border-bottom: 1px solid var(--border-color); padding-bottom: 10px; margin-top: 0; margin-bottom: 15px; }
#player-info-dashboard p, #player-stats p { display: flex; justify-content: space-between; padding: 8px 0; margin: 0; border-bottom: 1px solid #222; }
#player-info-dashboard p:last-child, #player-stats p:last-child { border-bottom: none; }
#player-info-dashboard p span:first-child, #player-stats p span:first-child { font-weight: bold; color: #aaa; }

/* --- LOG PANEL & COMBAT --- */
#log-panel { height: 15vh; min-height: 100px; background-color: rgba(17,17,17,0.95); border-top: 2px solid var(--border-color); padding: 10px; flex-shrink: 0; }
#log-entries { height: 100%; overflow-y: auto; display: flex; flex-direction: column-reverse; }
.log-entry { padding: 5px 8px; margin: 0; border-bottom: 1px solid #282828; animation: logFadeIn 0.3s; }
.log-entry.success { color: #5cb85c; } .log-entry.failure { color: #d9534f; } .log-entry.info { color: #5bc0de; } .log-entry.combat-result { font-style: italic; color: #f0ad4e; }
@keyframes logFadeIn { from { background-color: rgba(255,215,0,0.1); } to { background-color: transparent; } }
#combat-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1000; background: rgba(10, 10, 10, 0.9); display: flex; flex-direction: column; justify-content: center; align-items: center; transition: opacity 0.3s ease-in-out; backdrop-filter: blur(5px); }
#combat-arena { display: flex; justify-content: space-around; align-items: center; width: 90%; max-width: 1200px; }
.combatant-panel { flex-basis: 40%; background: var(--secondary-bg); border: 2px solid var(--border-color); padding: 20px; text-align: center; }
.combatant-image { width: 100%; max-width: 250px; aspect-ratio: 1 / 1; margin: 0 auto 15px; border: 1px solid var(--border-color); object-fit: cover; background-color: #111; }
.combatant-panel h3 { margin: 0 0 10px; font-family: var(--header-font); font-size: 1.8em; color: var(--accent-color); }
#combat-vs { font-size: 4em; font-family: var(--header-font); color: #666; }
#combat-actions { margin-top: 20px; display: flex; justify-content: center; gap: 10px; }
.combat-health-bar { margin: 10px 0; } .combat-health-bar .bar-container { width: 100%; height: 25px; } .combat-health-bar span { margin-top: -24px; font-size: 0.9em; text-shadow: 1px 1px 2px #000; }
#player-combat-hp-bar, #enemy-combat-hp-bar { background-color: var(--hp-color); }
#combat-log-display { margin-top: 30px; height: 100px; width: 80%; max-width: 900px; background: rgba(0,0,0,0.4); border: 1px dashed var(--border-color); padding: 10px; overflow-y: auto; display: flex; flex-direction: column-reverse; }
#combat-log-display p { margin: 0; padding: 4px; border-bottom: 1px solid #222; }

/* --- GENERIC & VIEW STYLES --- */
.view { display: none; } .view.active { display: block; animation: fadeIn 0.5s; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.item-list { list-style: none; padding: 0; } .item-list li { background: #252525; padding: 15px; margin-bottom: 10px; border-left: 3px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.action-btn { background-color: #1a1a1a; color: var(--text-color); border: 1px solid var(--accent-color); padding: 8px 15px; cursor: pointer; font-family: var(--body-font); transition: all 0.2s; text-transform: uppercase; }
.action-btn:hover { background-color: var(--accent-color); color: #fff; border-color: #ff4545; } .action-btn:disabled { background-color: #333; color: #777; border-color: #555; cursor: not-allowed; }
#map-view-container { display: flex; gap: 20px; align-items: flex-start; }
#city-map-container { flex-basis: 60%; position: relative; border: 2px solid var(--border-color); line-height: 0; }
#city-map-image { display: block; width: 100%; height: auto; }
#city-map-overlays { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
#city-map-container svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
#city-map-container svg polygon { fill: rgba(70, 130, 180, 0.2); stroke: #a2d2ff; stroke-width: 2px; transition: fill 0.2s ease-in-out; cursor: pointer; pointer-events: all; }
#city-map-container svg polygon:hover { fill: rgba(70, 130, 180, 0.5); }
#city-map-container svg polygon.player_controlled { fill: rgba(46, 139, 87, 0.4); }
#city-map-container svg polygon.locked { fill: rgba(0, 0, 0, 0.5); pointer-events: none; cursor: default; }
#city-map-container svg polygon.current-location { fill: rgba(178, 34, 34, 0.5); stroke: #ff4545; }
#territory-details { flex-basis: 40%; padding: 15px; border: 1px solid var(--border-color); background-color: var(--primary-bg); min-height: 400px; }
.territory-image { width: 100%; height: 150px; object-fit: cover; margin-bottom: 15px; border: 1px solid var(--border-color); }
#territory-details .travel-button { width: 100%; padding: 12px; margin-top: 15px; font-size: 1.1em; }
#territory-influence-bar { background-color: var(--influence-color); }

/* --- INVENTORY STYLES --- */
#inventory-tabs { display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 20px; }
.tab-link { background-color: transparent; border: none; border-bottom: 3px solid transparent; color: #aaa; padding: 10px 20px; font-family: var(--nav-font); font-size: 1.1em; text-transform: uppercase; cursor: pointer; transition: all 0.2s; }
.tab-link:hover { background-color: #222; }
.tab-link.active { color: var(--text-color); border-bottom-color: var(--accent-color); }
#inventory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; margin-bottom: 20px; }
.inventory-item { background-color: var(--secondary-bg); border: 1px solid var(--border-color); padding: 15px; text-align: center; }
.inventory-item .item-name { font-family: var(--nav-font); font-size: 1.1em; color: var(--text-color); margin-bottom: 5px; }
.inventory-item .item-quantity { display: inline-block; background-color: var(--primary-bg); border-radius: 50%; width: 24px; height: 24px; line-height: 24px; font-size: 0.8em; font-weight: bold; margin-bottom: 10px; }
.inventory-item .item-description { font-size: 0.8em; color: #aaa; margin-bottom: 15px; min-height: 40px; }
#dev-tools { margin-top: 30px; display: flex; align-items: center; gap: 15px; }
#dev-tools select { flex-grow: 1; padding: 8px; background-color: var(--primary-bg); color: var(--text-color); border: 1px solid var(--border-color); }
#dev-tools optgroup { font-style: italic; background-color: #111; }
#dev-tools option { background-color: var(--primary-bg); }

/* --- SKILL TREE STYLES --- */
#skill-points-header { text-align: center; font-size: 1.2em; font-family: var(--nav-font); padding: 10px; background-color: #111; border: 1px solid var(--border-color); margin-bottom: 20px; }
#skill-points-display { color: var(--accent-color); font-weight: bold; font-size: 1.3em; }
#skill-tree-visual-container { position: relative; border: 2px solid var(--border-color); line-height: 0; }
#skill-tree-image { display: block; width: 100%; height: auto; }
#skill-node-container { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.skill-node { position: absolute; width: 60px; height: 60px; background-color: var(--secondary-bg); border: 2px solid var(--border-color); border-radius: 50%; transform: translate(-50%, -50%); cursor: pointer; transition: all 0.2s ease-in-out; }
.skill-node.locked { background-color: #111; border-color: #222; opacity: 0.5; cursor: not-allowed; }
.skill-node.unlockable:hover { border-color: var(--accent-color); transform: translate(-50%, -50%) scale(1.1); box-shadow: 0 0 15px var(--accent-color); }
.skill-node.unlocked { border-color: var(--energy-color); background-color: #1c3d2a; box-shadow: 0 0 10px var(--energy-color); cursor: default; }
.skill-node::after { content: attr(data-tooltip); position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%); background-color: #111; color: white; padding: 10px; border-radius: 4px; border: 1px solid var(--border-color); width: 250px; text-align: center; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; pointer-events: none; font-size: 0.9em; line-height: 1.4; }
.skill-node:hover::after { opacity: 1; visibility: visible; }

/* --- OBJECTIVES STYLES --- */
#objective-container { display: flex; gap: 20px; align-items: flex-start; }
#npc-grid { flex-basis: 30%; min-width: 200px; display: grid; grid-template-columns: 1fr; gap: 10px; }
.npc-card { background-color: var(--secondary-bg); border: 1px solid var(--border-color); padding: 15px; cursor: pointer; transition: all 0.2s; }
.npc-card:hover { border-color: var(--accent-color); }
.npc-card.active { border-color: var(--accent-color); box-shadow: 0 0 10px var(--accent-color); }
.npc-card.locked { opacity: 0.4; cursor: not-allowed; background-color: #111; }
.npc-name { font-family: var(--nav-font); font-size: 1.2em; }
.npc-location { font-size: 0.8em; color: #aaa; }
#quest-details { flex-grow: 1; }
.quest-item { margin-bottom: 20px; }
.questline-title { font-size: 1.3em; font-family: var(--nav-font); color: var(--accent-color); margin-bottom: 10px; }
.questline-description { color: #aaa; margin-bottom: 20px; font-style: italic; }
.quest-step { padding: 10px; background-color: #111; margin-bottom: 5px; border-left: 3px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.quest-step.completed { border-left-color: var(--energy-color); text-decoration: line-through; color: #888; }
#active-objectives-list .quest-item { margin-bottom: 15px; }
#active-objectives-list .questline-title { font-size: 1.2em; margin-bottom: 8px; color: var(--accent-color); font-family: var(--nav-font); }
#active-objectives-list .quest-step { padding: 8px; background-color: #111; margin-bottom: 4px; border-left: 3px solid var(--border-color); }
#active-objectives-list .quest-step.completed { border-left-color: var(--energy-color); text-decoration: line-through; color: #888; }
.quest-item.completed .questline-title { color: #666; text-decoration: line-through; }
.quest-item.completed { opacity: 0.6; }
.completed-quests-header { margin-top: 30px; font-family: var(--nav-font); text-transform: uppercase; color: #888; border-top: 1px solid var(--border-color); padding-top: 15px; }


/* --- LOCATION VIEW STYLES --- */
#location-name { color: var(--accent-color); font-style: italic; }
#location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    grid-auto-flow: dense;
    gap: 20px;
}
.location-panel.full-width {
    grid-column: 1 / -1;
}
#location-crimes {
    grid-column: span 1;
}
#location-shop-panel, #location-dealership-panel {
    grid-column: span 2;
}
.location-panel {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    padding: 20px;
}
.location-panel h3 {
    font-family: var(--nav-font);
    text-transform: uppercase;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 15px;
}
#location-uptown-panel .uptown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* --- SHOP & DEALERSHIP STYLES --- */
.shop-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.shop-panel h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-family: var(--nav-font);
    font-size: 1.2em;
    color: #ccc;
}
.shop-item-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.shop-item-list li {
    background: #111;
    padding: 10px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 2px solid var(--border-color);
}
.shop-item-list .item-name {
    font-weight: bold;
}
.shop-item-list .item-price {
    color: #aaa;
    font-style: italic;
    margin-right: 10px;
}
.vehicle-description {
    font-size: 0.9em;
    color: var(--energy-color);
    margin-left: 10px;
}

/* --- PROPERTIES VIEW STYLES --- */
#properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}
.property-separator {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 25px 0;
}
.property-box {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 20px; /* Add some space between property boxes */
}
.property-box h4 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--nav-font);
    text-transform: uppercase;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 15px;
}
.upgrade-btn {
    padding: 5px 10px;
    font-size: 0.9em;
    /* Specific styles for the upgrade button icon */
    color: #fff;
    background-color: var(--energy-color);
    border: 1px solid var(--energy-color);
    border-radius: 3px;
}
.upgrade-btn:hover {
    background-color: #3cb371; /* A slightly lighter green on hover */
    border-color: #3cb371;
}

/* --- CONFIRMATION DIALOG STYLES --- */
.confirm-dialog-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}
.confirm-dialog {
    background: var(--secondary-bg);
    border: 2px solid var(--border-color);
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.9);
}
.confirm-dialog p {
    margin-bottom: 20px;
    font-size: 1.1em;
    color: var(--text-color);
}
.confirm-dialog button {
    margin: 0 10px;
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.2s;
}
.confirm-dialog button:hover {
    background-color: #ff4545;
}
.confirm-dialog #confirm-no {
    background-color: #555;
}
.confirm-dialog #confirm-no:hover {
    background-color: #777;
}