/* ==========================================================================
   GTC Portal World Grid - Theme & Layout Stylesheet
   Modern Cyber-Cartography Design System
   ========================================================================== */

:root {
    --bg-base: #060911;
    --bg-surface: #0c1220;
    --bg-card: rgba(14, 21, 37, 0.75);
    --bg-card-hover: rgba(22, 33, 56, 0.9);
    --bg-input: rgba(6, 10, 20, 0.85);

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.15);
    --border-focus: rgba(56, 189, 248, 0.5);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --accent-cyan: #38bdf8;
    --accent-blue: #3b82f6;
    --accent-purple: #a855f7;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    --glow-cyan: 0 0 20px rgba(56, 189, 248, 0.35);
    --glow-purple: 0 0 20px rgba(168, 85, 247, 0.35);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.06) 0%, transparent 60%),
        radial-gradient(circle at 90% 100%, rgba(168, 85, 247, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 10% 100%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.app-header {
    background: rgba(12, 18, 32, 0.85);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #0284c7, #9333ea);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: var(--glow-cyan);
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version-badge {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-cyan);
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.map-source-credit {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.28);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.map-source-credit:hover {
    background: rgba(56, 189, 248, 0.18);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
    color: #ffffff;
    transform: translateY(-1px);
}

.map-source-credit .credit-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.map-source-credit .credit-name {
    color: var(--accent-cyan);
    font-weight: 700;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

/* ==========================================================================
   Sub-Header Control Bar (Coordinate Indexer & Toolbar)
   ========================================================================== */
.control-bar {
    background: rgba(14, 21, 37, 0.7);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.slot-selector-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.select-input, .text-input {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-medium);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    outline: none;
    transition: all 0.2s ease;
}

.select-input:focus, .text-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.coord-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.coord-field {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 0 8px;
}

.coord-field span {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-right: 4px;
}

.coord-field input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    width: 65px;
    padding: 7px 0;
    outline: none;
}

.btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border: 1px solid var(--border-medium);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--text-muted);
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7, #2563eb);
    border-color: rgba(56, 189, 248, 0.5);
    color: #ffffff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0369a1, #1d4ed8);
    box-shadow: var(--glow-cyan);
}

.btn-icon {
    padding: 7px 10px;
    font-size: 0.95rem;
}

.btn.active {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.search-box {
    position: relative;
    width: 240px;
}

.search-box input {
    width: 100%;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 320px;
    max-height: 300px;
    overflow-y: auto;
    background: #0f172a;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: none;
}

.dropdown-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: rgba(56, 189, 248, 0.12);
}

.dropdown-item.empty {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-align: center;
    padding: 16px;
}

.item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.item-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.item-badge.territory { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid #a855f7; }
.item-badge.capital { background: rgba(244, 63, 94, 0.2); color: #fb7185; border: 1px solid #f43f5e; }
.item-badge.town { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid #f59e0b; }
.item-badge.river { background: rgba(6, 182, 212, 0.2); color: #22d3ee; border: 1px solid #06b6d4; }
.item-badge.street { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid #ef4444; }
.item-badge.poi_marker { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #10b981; }

.item-id {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-main);
}

.item-name {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.item-details {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
}

/* ==========================================================================
   Main Application Layout (80% Canvas / 20% Sidebar)
   ========================================================================== */
.main-workspace {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 340px;
    height: calc(100vh - 180px);
    min-height: 550px;
    position: relative;
}

@media (max-width: 1024px) {
    .main-workspace {
        grid-template-columns: 1fr 280px;
    }
}

@media (max-width: 768px) {
    .main-workspace {
        grid-template-columns: 1fr;
        height: auto;
    }
}

/* ==========================================================================
   Left Canvas Workspace
   ========================================================================== */
.canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #090e17;
    overflow: hidden;
}

.canvas-container.drag-over {
    box-shadow: inset 0 0 0 3px var(--accent-cyan);
}

#dxfCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.floating-hud {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(15, 23, 42, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 10;
}

.hud-pill {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-pill strong {
    color: var(--accent-cyan);
}

.canvas-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(6, 9, 17, 0.75);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 50;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(56, 189, 248, 0.2);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-text {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Right Panel: Layer Control Bar (20% Width Gutter)
   ========================================================================== */
.layer-sidebar {
    background: rgba(12, 18, 32, 0.95);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.sidebar-tools {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.layer-search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    outline: none;
}

.layer-search-input:focus {
    border-color: var(--accent-cyan);
}

.layer-bulk-actions {
    display: flex;
    gap: 6px;
}

.btn-mini {
    flex: 1;
    padding: 4px 6px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.btn-mini:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.layer-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.layer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.layer-row:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-subtle);
}

.layer-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

.layer-name {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.04);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Custom Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .25s;
    border-radius: 18px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .25s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

input:checked + .slider:before {
    transform: translateX(14px);
}

/* ==========================================================================
   Footer & Community Links
   ========================================================================== */
.app-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: #080c16;
}

.footer-brand {
    margin-bottom: 12px;
}

.footer-brand a {
    color: var(--accent-cyan);
    text-decoration: none;
    font-weight: 600;
}

.footer-community-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.footer-links-grid {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.82rem;
}

.footer-card-link {
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.link-slideshow {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.2);
}
.link-slideshow:hover {
    background: rgba(56, 189, 248, 0.16);
}

.link-alibi {
    color: #34d399;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.2);
}
.link-alibi:hover {
    background: rgba(52, 211, 153, 0.16);
}

.link-sequencer {
    color: #c084fc;
    background: rgba(192, 132, 252, 0.08);
    border: 1px solid rgba(192, 132, 252, 0.2);
}
.link-sequencer:hover {
    background: rgba(192, 132, 252, 0.16);
}

.link-current {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

/* ==========================================================================
   Toast Notification & Modal
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(15, 23, 42, 0.9);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-medium);
    color: var(--text-main);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: opacity 0.3s ease;
    display: none;
}

.toast.success { border-color: var(--accent-emerald); }
.toast.error { border-color: var(--accent-rose); }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    width: 440px;
    max-width: 90vw;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input, .form-group select {
    width: 100%;
}
