/**
 * 🏮 Sovereign Nexus UI v1.0.0
 * 實施規範：SOVEREIGN_ARCH_GUIDELINE.md
 * 職責：管理全域地圖介面、側邊欄插槽（Cabinet Sockets）與主權視覺語彙。
 */

:root {
    --primary-bg: #121212;
    --accent-gold: #d4af37;
    --panel-bg: rgba(18, 18, 18, 0.9);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --sidebar-width: 320px;
    --sidebar-width-mobile: 280px;
    --transition: cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}

body, html {
    margin: 0; padding: 0;
    height: 100%; width: 100%;
    overflow: hidden;
    background-color: var(--primary-bg);
    font-family: -apple-system, "微軟正黑體", "Inter", sans-serif;
    color: #fff;
}

#sovereign-host { height: 100%; width: 100%; position: relative; display: flex; overflow: hidden; }
#map-container { flex: 1; height: 100%; position: relative; z-index: 1; }

/* --------------------------------------------------------- */
/* 1. 右側主權選單 (Sovereign Sidebar) */
/* --------------------------------------------------------- */
#sidebar-toggle { display: none; }
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--panel-bg);
    border-left: 1px solid rgba(212, 175, 55, 0.3);
    backdrop-filter: blur(12px);
    z-index: 2000;
    position: absolute;
    right: 0;
    top: 0;
    transform: translateX(0);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

#sidebar-toggle:checked ~ .sidebar { transform: translateX(100%); }

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; align-items: center;
}
.sidebar-header h2 { margin: 0; font-size: 18px; color: var(--accent-gold); letter-spacing: 1px; }

.sidebar-pin {
    flex-shrink: 0;
    padding: 12px 15px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--panel-bg);
}

.sidebar-pin .cabinet-socket {
    margin-bottom: 0;
}

.sidebar-content {
    flex: 1; overflow-y: auto; padding: 12px 15px 15px;
    scrollbar-width: thin;
    min-height: 0;
}

.toggle-btn {
    position: absolute; left: -44px; top: 20px;
    width: 44px; height: 44px;
    background: var(--panel-bg);
    border: 1px solid rgba(212,175,55,0.3);
    border-right: none;
    border-radius: 8px 0 0 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; pointer-events: auto;
    color: var(--accent-gold);
    backdrop-filter: blur(12px);
}

/* --------------------------------------------------------- */
/* 2. 插槽系統 (Cabinet Sockets) */
/* --------------------------------------------------------- */
.cabinet-socket { 
    margin-bottom: 8px; 
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 8px;
    overflow: visible;
    background: rgba(255, 255, 255, 0.03);
    transition: var(--transition);
}

.cabinet-header {
    padding: 10px 15px;
    background: rgba(212, 175, 55, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.cabinet-header:hover {
    background: rgba(212, 175, 55, 0.15);
}

.cabinet-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-gold);
    letter-spacing: 0.5px;
    line-height: 1.35;
}

.cabinet-header h3 .consultant-header-firm {
    font-weight: 500;
    letter-spacing: 0.3px;
    font-size: 12px;
}

.cabinet-header .toggle-icon {
    font-size: 10px;
    transition: transform 0.3s;
}

.cabinet-socket.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.cabinet-socket.collapsed {
    overflow: hidden;
}

.cabinet-socket.collapsed .cabinet-body {
    display: none;
}

.cabinet-socket-fixed {
    overflow: visible;
}

.cabinet-socket-fixed .cabinet-header {
    cursor: default;
}

.cabinet-socket-fixed .cabinet-body {
    display: block;
}

.cabinet-body {
    padding: 5px;
    border-top: 1px solid rgba(212, 175, 55, 0.1);
}

/* --------------------------------------------------------- */
/* 3. 主權語彙標籤 (Sovereign Labeling) */
/* --------------------------------------------------------- */
.v-tag {
    display: inline-block;
    padding: 1px 4px;
    font-size: 10px;
    font-weight: 800;
    border-radius: 4px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}
.v-tag.verified {
    background: rgba(0, 200, 81, 0.2);
    color: #00c851;
    border-color: rgba(0, 200, 81, 0.4);
}
.v-tag.source {
    background: rgba(51, 181, 229, 0.15);
    color: #33b5e5;
    border-color: rgba(51, 181, 229, 0.3);
}

/* --------------------------------------------------------- */
/* 4. 地圖控制與彈出視窗 (Map Controls & Popups) */
/* --------------------------------------------------------- */
.leaflet-popup-content-wrapper {
    background: rgba(20, 25, 35, 0.95);
    color: #fff;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
}
.leaflet-popup-tip {
    background: rgba(20, 25, 35, 0.95);
}

.sovereign-indicator {
    position: fixed;
    bottom: 12px; left: 12px;
    background: rgba(0,0,0,0.85);
    color: var(--accent-gold);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 10px;
    z-index: 3000;
    border: 1px solid rgba(212, 175, 55, 0.2);
    letter-spacing: 1px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-width-mobile); }
}

/* --------------------------------------------------------- */
/* 5. 主權組件擴展 (Sovereign Component Extensions) */
/* --------------------------------------------------------- */
.sovereign-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 4px;
    color: #fff;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}
.sovereign-input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.2);
}

.status-text {
    font-size: 11px;
    color: #999;
    margin-top: 8px;
    font-style: italic;
    letter-spacing: 0.5px;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-row:hover {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

.grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

/* 截圖模式特殊遮罩 */
.screenshot-clean-mode .leaflet-control-container,
.screenshot-clean-mode #sovereign-indicator,
.screenshot-clean-mode .sidebar {
    display: none !important;
}

.leaflet-control-mylocation a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 16px;
    line-height: 1;
    text-decoration: none;
    color: #1e293b;
    background: #fff;
}
.leaflet-control-mylocation a.is-on {
    background: #2563eb;
    color: #fff;
}
.my-location-marker {
    background: transparent;
    border: 0;
}
.my-location-dot {
    display: block;
    width: 16px;
    height: 16px;
    margin: 3px;
    border-radius: 50%;
    background: #2563eb;
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

#map-overlay-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5000;
    display: none;
    text-align: center;
    width: 100%;
}
.overlay-title {
    font-size: 48px;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.15);
    letter-spacing: 12px;
    text-transform: uppercase;
}
