/**
 * Unified Dark Theme — Izbushka Map Editor
 * 
 * Color system:
 *   Primary bg:   #1a1a2e (body), #16213e (panels)
 *   Gold accent:  #c4a265
 *   Secondary:    #939CA9
 *   Border:       #0f3460
 *   Danger:       #e94560
 */

/* ─── Reset & Base ────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', 'Vela Sans', system-ui, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
}

a { color: #c4a265; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #1a4a8a; }

/* ─── Buttons ─────────────────────────────────────────── */
button, .btn {
    padding: 8px 14px;
    border: 1px solid #0f3460;
    background: #0f3460;
    color: #eee;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}
button:hover { background: #1a4a8a; }
button:active { transform: scale(0.97); }
button.active { background: #c4a265; border-color: #c4a265; color: #1a1a2e; font-weight: 600; }
button.gold { background: #8b6914; border-color: #c4a265; }
button.gold:hover { background: #a07a1a; }
button.danger { background: #6b1a1a; border-color: #e94560; }
button.danger:hover { background: #8b2a2a; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Inputs / Selects ────────────────────────────────── */
input, select, textarea {
    padding: 7px 10px;
    background: #1a1a2e;
    border: 1px solid #0f3460;
    color: #eee;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #c4a265;
}
select { cursor: pointer; }
textarea {
    resize: vertical;
    font-family: monospace;
}

/* ─── App Header ──────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    gap: 16px;
}
.app-header .logo {
    font-size: 16px;
    font-weight: 700;
    color: #c4a265;
    letter-spacing: 0.5px;
}
.app-header .logo span { color: #939CA9; font-weight: 400; font-size: 13px; }
.app-header .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #939CA9;
}
.app-header .user-info img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #0f3460;
}
.app-header .header-actions { display: flex; gap: 8px; align-items: center; }

/* ─── Login Page ──────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: radial-gradient(ellipse at center, #16213e 0%, #1a1a2e 70%);
}
.login-card {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    padding: 48px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.login-card .brand-logo {
    font-size: 28px;
    font-weight: 700;
    color: #c4a265;
    margin-bottom: 6px;
    letter-spacing: 1px;
}
.login-card .brand-sub {
    font-size: 14px;
    color: #939CA9;
    margin-bottom: 32px;
}
.login-card .tagline {
    font-size: 11px;
    color: #555;
    margin-top: 20px;
}

/* Google Sign-In Button */
.google-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 28px;
    background: #fff;
    color: #333;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.google-btn:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.3); background: #f8f8f8; }
.google-btn:active { transform: scale(0.98); }
.google-btn svg { width: 18px; height: 18px; }

.login-error {
    color: #e94560;
    font-size: 12px;
    margin-top: 16px;
    min-height: 18px;
}

/* ─── Dashboard ───────────────────────────────────────── */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}
.dashboard-title {
    font-size: 20px;
    color: #eee;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dashboard-title h2 { font-size: 20px; }

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Project Card */
.project-card {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}
.project-card:hover { border-color: #c4a265; transform: translateY(-2px); }
.project-card .card-preview {
    width: 100%;
    height: 160px;
    background: #0d1117;
    position: relative;
    overflow: hidden;
}
.project-card .card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
}
.project-card .card-body {
    padding: 16px;
}
.project-card .card-name {
    font-size: 15px;
    font-weight: 600;
    color: #eee;
    margin-bottom: 4px;
}
.project-card .card-meta {
    font-size: 11px;
    color: #939CA9;
    margin-bottom: 12px;
}
.project-card .card-actions {
    display: flex;
    gap: 8px;
}
.project-card .card-actions button { flex: 1; font-size: 11px; }

/* New Project Card (placeholder) */
.project-card.new-project {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    border-style: dashed;
    cursor: pointer;
}
.project-card.new-project:hover { background: rgba(196,162,101,0.05); }
.project-card.new-project .plus {
    text-align: center;
    color: #939CA9;
}
.project-card.new-project .plus .icon { font-size: 36px; color: #c4a265; }
.project-card.new-project .plus .label { font-size: 13px; margin-top: 8px; }

/* ─── Modal ───────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
}
.modal-overlay.visible { opacity: 1; visibility: visible; }

.modal {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 10px;
    padding: 28px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal h3 {
    color: #c4a265;
    font-size: 16px;
    margin-bottom: 20px;
}
.modal .form-group {
    margin-bottom: 14px;
}
.modal label {
    display: block;
    font-size: 11px;
    color: #939CA9;
    margin-bottom: 4px;
}
.modal .modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ─── Editor Layout ───────────────────────────────────── */
.editor-layout {
    display: flex;
    height: calc(100vh - 49px); /* minus header */
}

#map {
    flex: 1;
    position: relative;
}

#panel {
    width: 380px;
    background: #16213e;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-left: 2px solid #0f3460;
    flex-shrink: 0;
}

/* Panel headings */
#panel h2 { color: #c4a265; font-size: 16px; margin-bottom: 4px; }
#panel h3 { color: #c4a265; font-size: 13px; margin-top: 8px; }

/* ─── Panel Sub-Sections ──────────────────────────────── */
.instructions {
    background: rgba(15,52,96,0.5);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
    color: #aaa;
}
.instructions strong { color: #c4a265; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Template Presets ────────────────────────────────── */
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-btn {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 12px;
    border: 1px solid;
}

/* ─── Color Picker Row ────────────────────────────────── */
.color-row { display: flex; gap: 6px; align-items: center; }
.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}
.color-dot.selected { border-color: white; }

/* ─── Width Slider ────────────────────────────────────── */
.width-slider {
    display: flex;
    align-items: center;
    gap: 8px;
}
.width-slider input[type=range] {
    flex: 1;
    accent-color: #c4a265;
    background: transparent;
}
.width-slider span { font-size: 11px; color: #888; min-width: 30px; }

/* ─── Callout Fields ──────────────────────────────────── */
.callout-fields {
    display: none;
    flex-direction: column;
    gap: 6px;
}
.callout-fields.visible { display: flex; }

/* ─── Feature List ────────────────────────────────────── */
.feature-item {
    background: rgba(15,52,96,0.3);
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
}
.feature-item .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.feature-item .name { font-weight: 600; color: #c4a265; }
.feature-item .type { font-size: 10px; color: #888; text-transform: uppercase; }
.feature-item .pts { font-size: 11px; color: #666; }
.feature-item button { padding: 3px 8px; font-size: 10px; }

.feature-item .feat-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.feature-item .eye-btn {
    padding: 3px 6px;
    font-size: 10px;
    background: transparent;
    border-color: transparent;
    opacity: 0.7;
}
.feature-item .eye-btn:hover { opacity: 1; }
.feature-item .eye-btn.hidden-feat { opacity: 0.3; }

/* ─── Map Overlays ────────────────────────────────────── */
#coord-display {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(22, 33, 62, 0.95);
    padding: 8px 14px;
    border-radius: 5px;
    font-size: 12px;
    color: #c4a265;
    z-index: 100;
    font-family: monospace;
}

.mode-indicator {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(196, 162, 101, 0.95);
    color: #1a1a2e;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100;
    display: none;
}
.mode-indicator.active { display: block; }

/* Save indicator */
.save-status {
    font-size: 11px;
    color: #939CA9;
    display: flex;
    align-items: center;
    gap: 4px;
}
.save-status.saved { color: #2ecc71; }
.save-status.saving { color: #c4a265; }
.save-status.error { color: #e94560; }

/* ─── Map Markers ─────────────────────────────────────── */
.elysian-marker {
    width: 20px;
    height: 20px;
    background: #c4a265;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(196,162,101,0.5);
    cursor: grab;
}

.placed-label {
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 6px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,0.9);
    white-space: nowrap;
    cursor: grab;
    pointer-events: auto;
}

.placed-callout {
    background: rgba(15, 46, 35, 0.94);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    border-left: 3px solid #c4a265;
    max-width: 200px;
    font-family: 'Segoe UI', sans-serif;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    cursor: grab;
    pointer-events: auto;
}
.placed-callout .co-title { font-weight: 600; font-size: 12px; }
.placed-callout .co-date { font-weight: 700; font-size: 13px; color: #c4a265; }
.placed-callout .co-desc { font-size: 10px; color: rgba(255,255,255,0.6); margin-top: 2px; }

/* Metro dot (for metro station markers) */
.metro-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
}

/* ─── Export Area ─────────────────────────────────────── */
#export-area {
    width: 100%;
    height: 160px;
    background: #0d1117;
    color: #58a6ff;
    border: 1px solid #0f3460;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    padding: 8px;
}

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
    .editor-layout { flex-direction: column-reverse; }
    #panel {
        width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 2px solid #0f3460;
    }
    .projects-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Loading Spinner ─────────────────────────────────── */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #939CA9;
    font-size: 14px;
}
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #0f3460;
    border-top-color: #c4a265;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Panel Divider ───────────────────────────────────── */
.panel-divider {
    border: none;
    border-top: 1px solid #0f3460;
    margin: 4px 0;
}

/* ─── District Name (header) ──────────────────────────── */
.district-name {
    font-size: 14px;
    color: #939CA9;
    font-weight: 400;
}

/* ─── Category Buttons ────────────────────────────────── */
.category-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.cat-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    background: rgba(15,52,96,0.3);
    border: 1px solid #0f3460;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.cat-btn:hover {
    background: rgba(196,162,101,0.15);
    border-color: #c4a265;
}
.cat-btn.active {
    background: rgba(196,162,101,0.2);
    border-color: #c4a265;
}
.cat-icon { font-size: 22px; }
.cat-label { font-size: 11px; color: #eee; }

/* ─── Infrastructure Form ─────────────────────────────── */
.infra-form {
    background: rgba(15,52,96,0.2);
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 16px;
}
.infra-form h4 {
    color: #c4a265;
    font-size: 14px;
    margin-bottom: 12px;
}
.infra-form .form-group {
    margin-bottom: 10px;
}
.infra-form label {
    display: block;
    font-size: 11px;
    color: #939CA9;
    margin-bottom: 3px;
}
.infra-form .form-row {
    display: flex;
    gap: 8px;
}
.infra-form textarea {
    font-family: inherit;
    font-size: 12px;
}

/* ─── Feature List v2 ─────────────────────────────────── */
#features-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feature-item {
    background: rgba(15,52,96,0.3);
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
    transition: border-color 0.2s;
}
.feature-item:hover {
    border-color: rgba(196,162,101,0.4);
}
.feature-item .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.feature-item .name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.feature-item .feat-meta {
    font-size: 10px;
    color: #888;
    margin-bottom: 6px;
}
.feature-item .feat-desc {
    font-size: 10px;
    color: #666;
    font-style: italic;
    margin-bottom: 6px;
    max-height: 28px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feature-item .feat-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.feature-item .feat-actions button {
    padding: 3px 8px;
    font-size: 10px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.status-badge.operational {
    background: rgba(46,204,113,0.2);
    color: #2ecc71;
}
.status-badge.under_construction {
    background: rgba(241,196,15,0.2);
    color: #f1c40f;
}
.status-badge.planned {
    background: rgba(52,152,219,0.2);
    color: #3498db;
}

/* ─── Station Items ───────────────────────────────────── */
#stations-section h4 {
    color: #c4a265;
    font-size: 12px;
    margin: 8px 0 6px;
}
.station-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(15,52,96,0.2);
    border-radius: 4px;
    font-size: 11px;
    margin-bottom: 4px;
}
.station-item .station-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3498db;
    border: 2px solid white;
    flex-shrink: 0;
}
.station-item .station-name {
    flex: 1;
}
.station-item input {
    flex: 1;
    font-size: 11px;
    padding: 3px 6px;
}
.station-item button {
    padding: 2px 6px;
    font-size: 9px;
}

/* ─── Metro Station Map Markers ───────────────────────── */
.metro-station-marker {
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
    cursor: default;
    white-space: nowrap;
}
.station-dot-lg {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 6px rgba(0,0,0,0.7);
    flex-shrink: 0;
}
.station-label {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: white;
    text-shadow:
        0 0 4px rgba(0,0,0,0.9),
        0 0 8px rgba(0,0,0,0.7),
        0 1px 2px rgba(0,0,0,0.9),
        1px 0 2px rgba(0,0,0,0.9);
    letter-spacing: 0.2px;
}

