/**
 * css/base.css - 2026 STRATEGY EDITION
 * ---------------------------------------------------------
 * Role: Full UI Styling & Layout
 * ---------------------------------------------------------
 */

/* 1. RESET & FUNDAMENTALS */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body, html { 
    width: 100%; 
    height: 100%; 
    overflow: hidden; 
    background: #0d0d0d; 
    color: #eeeeee; 
    overscroll-behavior: none; 
}

/* 2. VIEWPORT & MAP */
#viewport { 
    position: fixed; 
    inset: 0;
    cursor: grab; 
    z-index: 5;
    background: #111;
    touch-action: none; 
}

#map { 
    position: absolute; 
    width: 5000px; 
    height: 5000px; 
    background-image: 
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), 
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px),
        url('../assets/map-bg.png');
    background-size: 30px 30px, 30px 30px, 5000px 5000px;
    background-repeat: repeat, repeat, no-repeat;
    background-position: center;
    background-color: #111; 
    transform-origin: 0 0; 
    z-index: 1;
    will-change: transform;
    backface-visibility: hidden;
}

/* 3. SIDEBAR (SCROLLABLE) */
#sidebar { 
    position: fixed; 
    left: 0; top: 0; 
    width: 260px; height: 100%; 
    background: rgba(15, 15, 15, 0.98); 
    padding: 15px; 
    z-index: 1000; 
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    touch-action: pan-y;
}

#sidebar.collapsed { transform: translateX(-100%); }

#sidebar-tab {
    position: absolute;
    right: -40px; top: 20px;
    width: 40px; height: 50px;
    background: rgba(15, 15, 15, 0.98);
    border: 1px solid #333;
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: #ffcc00;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
}

#player-container { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; /* Critical for internal scrolling */
}

#scroll-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    -webkit-overflow-scrolling: touch;
}

#scroll-list::-webkit-scrollbar { width: 4px; }
#scroll-list::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }

#player-search {
    width: 100%; padding: 12px; background: #222; border: 1px solid #444;
    border-radius: 6px; color: white; margin-bottom: 15px; outline: none;
}

.sidebar-header h3 { 
    color: #ffcc00; font-size: 0.7rem; text-transform: uppercase;
    margin-top: 15px; margin-bottom: 8px; letter-spacing: 1.5px;
    border-bottom: 1px solid #333; padding-bottom: 5px;
}

/* 4. DRAGGABLE ITEMS */
.item { 
    padding: 12px; background: #1a1a1a; margin: 4px 0; 
    cursor: grab; border-radius: 4px; border: 1px solid #333; font-size: 14px;
}

.item-disabled { opacity: 0.2; filter: grayscale(1); pointer-events: none; }

/* 5. MAP MARKERS */
.marker { 
    position: absolute; 
    background-size: 100% 100%;
    background-repeat: no-repeat; 
    background-position: center; 
    z-index: 10; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    touch-action: none;
}

/* SPECIFIC BUILDING OVERRIDES */
.marker[data-type="frank"] { background-image: url('../assets/frank.png'); }
.marker[data-type="merchant"] { background-image: url('../assets/merchant.png'); }
.marker[data-type="player"] { background-image: url('../assets/player.png'); }

/* ALLIANCE CENTER (City) - 27x27 and Layered Behind */
.marker[data-type="city"] {
    background-image: url('../assets/city.png');
    border: 4px solid #0000ff;
    background-size: 90px 90px;
    background-color: rgba(0, 0, 255, 0.05);
    z-index: 1;
}

.marker.is-dragging {
    outline: 3px solid #ffcc00; outline-offset: 5px;
    filter: drop-shadow(0 0 15px #ffcc00); z-index: 1000 !important;
}

.marker span { 
    background: rgba(0, 0, 0, 0.75); color: #fff; padding: 2px 8px; 
    font-size: 11px; font-weight: bold; border-radius: 4px;
    white-space: nowrap; border: 1px solid rgba(255,255,255,0.2); pointer-events: none;
}

.ghost-preview {
    position: fixed !important; pointer-events: none; z-index: 9999;
    opacity: 0.6; width: 90px; height: 90px; border: 2px dashed #ffcc00;
    display: flex; align-items: center; justify-content: center;
}

/* 6. BUTTONS & CONTROLS */
.map-controls {
    position: fixed; bottom: 20px; right: 20px; 
    z-index: 100; display: flex; flex-direction: column; gap: 10px;
}

.map-controls button {
    width: 50px; height: 50px; border-radius: 50%; background: #222; 
    color: #ffcc00; border: 1px solid #444; cursor: pointer;
    font-size: 20px; display: flex; align-items: center; justify-content: center;
}

.map-controls button.unlocked-active {
    background: #422; color: #f66; border-color: #633;
}

.primary-btn { background: #ffcc00; color: #000; border: none; padding: 12px; border-radius: 6px; font-weight: bold; cursor: pointer; width: 100%; text-transform: uppercase; }
.secondary-btn { background: #222; color: #eee; border: 1px solid #444; padding: 10px; border-radius: 6px; cursor: pointer; }
.danger-btn { background: #311; color: #f66; border: 1px solid #522; padding: 10px; border-radius: 6px; cursor: pointer; }
.small-text { font-size: 11px; flex: 1; }

/* 7. SIDEBAR ACTIONS (Fixed at bottom) */
.sidebar-actions { 
    display: flex; 
    gap: 5px; 
    margin-top: 15px; 
    padding-top: 10px;
    border-top: 1px solid #333;
    flex-shrink: 0; 
}

/* 8. CUSTOM BOX & MODALS */
.custom-box { 
    background: #111; padding: 30px; border-radius: 12px; 
    border: 1px solid #333; width: 90%; max-width: 350px; text-align: center; 
}

.login-icon { 
    width: 60px; height: 60px; background: url('../assets/frank.png') no-repeat center; 
    background-size: contain; margin: 0 auto 15px; 
}

#login-overlay, #confirm-modal { 
    position: fixed; inset: 0; background: rgba(0,0,0,0.9); 
    z-index: 5000; display: flex; align-items: center; justify-content: center; 
    backdrop-filter: blur(4px); 
}

#pass-input {
    width: 100%; padding: 15px; background: #0a0a0a; border: 1px solid #444; 
    color: #ffcc00; border-radius: 6px; margin-bottom: 20px; text-align: center;
    font-size: 18px; outline: none;
}

#sync-status { margin-top: auto; padding: 10px; font-size: 10px; color: #444; text-align: center; text-transform: uppercase; letter-spacing: 1px; }
.hidden-ui { display: none !important; }
