/* PinSLS — Complete Redesign */
/* Sidebar + Floating Panels Layout */

/* ===================== VARIABLES ===================== */
:root {
    /* Colors */
    --primary: #E2720A;
    --primary-dark: #C4620A;
    --primary-light: #FFF3E6;
    --on-primary: #FFFFFF;

    --surface: #FAFAFA;
    --surface-bright: #FFFFFF;
    --surface-dim: #F0F0F0;
    --surface-container: #E5EEFF;
    --surface-container-low: #EFF4FF;
    --surface-container-high: #DCE9FF;

    --on-surface: #333333;
    --on-surface-light: #666666;
    --on-surface-muted: #999999;

    --outline: #E0E0E0;
    --outline-dim: #F0F0F0;

    --error: #C62828;
    --error-bg: #FFEBEE;
    --success: #2E7D32;
    --success-bg: #E8F5E9;

    /* Layout */
    --sidebar-width: 280px;
    --sls-panel-width: 340px;
    --search-panel-width: 440px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* ===================== RESET ===================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--on-surface);
    background: var(--surface);
    display: flex;
    line-height: 1.5;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface-bright);
    border-right: 1px solid var(--outline);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--outline);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-primary);
    flex-shrink: 0;
    position: relative;
}

.sidebar-logo .logo-map {
    font-size: 24px;
}

.sidebar-logo .logo-pin {
    font-size: 16px;
    position: absolute;
    top: 4px;
    right: 4px;
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.sidebar-tagline {
    font-size: 11px;
    color: var(--on-surface-muted);
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--on-surface-light);
    transition: all var(--transition-fast);
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    background: var(--surface-container-low);
    color: var(--on-surface);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    border-right: 3px solid var(--primary);
}

.nav-item .material-symbols-outlined {
    font-size: 20px;
}

.nav-item .material-symbols-outlined.fill {
    font-variation-settings: 'FILL' 1;
}

.sidebar-footer {
    padding: 12px 8px 16px;
    border-top: 1px solid var(--outline);
}

.sidebar-footer .nav-item {
    margin-bottom: 8px;
}

.sidebar-meta {
    font-size: 11px;
    color: var(--on-surface-muted);
    text-align: center;
    padding: 0 12px;
}

/* ===================== MAP AREA ===================== */
.map-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* ===================== FLOATING SEARCH PANEL ===================== */
.floating-panel {
    position: absolute;
    top: 24px;
    left: 24px;
    width: var(--search-panel-width);
    background: var(--surface-bright);
    border: 1px solid var(--outline);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 500;
    overflow: hidden;
    transition: box-shadow var(--transition-fast);
}

.floating-panel.dragging {
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
    transition: none;
}

.floating-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface-dim);
    border-bottom: 1px solid var(--outline);
    cursor: grab;
    user-select: none;
}

.panel-header:active {
    cursor: grabbing;
}

.drag-icon {
    font-size: 16px;
    color: var(--on-surface-muted);
}

.panel-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--outline);
    background: var(--surface-dim);
}

.panel-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--on-surface-light);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.panel-tab:hover {
    color: var(--on-surface);
}

.panel-tab.active {
    color: var(--primary);
    background: var(--surface-bright);
}

.panel-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.panel-content {
    padding: 16px;
}

.panel-content.hidden {
    display: none;
}

/* ===================== FORMS ===================== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    border: 1px solid var(--outline);
    border-radius: 6px;
    background: var(--surface);
    color: var(--on-surface);
    transition: all var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(226, 114, 10, 0.1);
}

.form-group input::placeholder {
    color: var(--on-surface-muted);
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary .material-symbols-outlined {
    font-size: 18px;
}

.btn-secondary {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-surface-light);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--surface-dim);
    color: var(--on-surface);
}

/* ===================== CROSSHAIR ===================== */
.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 100;
}

.crosshair.hidden {
    display: none;
}

.crosshair-ring {
    width: 24px;
    height: 24px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    position: relative;
}

.crosshair-dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.crosshair-line {
    position: absolute;
    background: var(--primary);
}

.crosshair-left {
    width: 8px;
    height: 2px;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
}

.crosshair-right {
    width: 8px;
    height: 2px;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
}

.crosshair-top {
    width: 2px;
    height: 8px;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%);
}

.crosshair-bottom {
    width: 2px;
    height: 8px;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
}

/* ===================== MAP CONTROLS ===================== */
.map-controls {
    position: absolute;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 400;
}

.map-control-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--outline);
    background: var(--surface-bright);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-surface);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.map-control-btn:hover {
    background: var(--surface-dim);
}

.map-control-btn .material-symbols-outlined {
    font-size: 20px;
}

/* ===================== SLS PANEL (RIGHT) ===================== */
.sls-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--sls-panel-width);
    height: 100%;
    background: var(--surface-bright);
    border-left: 1px solid var(--outline);
    display: flex;
    flex-direction: column;
    z-index: 500;
    transition: all var(--transition-normal);
}

.sls-panel.hidden {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

/* ===================== HISTORY PANEL (LEFT) ===================== */
.history-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--sls-panel-width);
    height: 100%;
    background: var(--surface-bright);
    border-right: 1px solid var(--outline);
    display: flex;
    flex-direction: column;
    z-index: 500;
    transition: all var(--transition-normal);
}

.history-panel.hidden {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.history-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-item:hover {
    border-color: var(--primary);
    background: var(--surface-bright);
}

.history-item-info {
    flex: 1;
}

.history-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--on-surface);
}

.history-item-meta {
    font-size: 11px;
    color: var(--on-surface-muted);
    margin-top: 2px;
}

.history-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--on-surface-muted);
}

.history-item:hover .material-symbols-outlined {
    color: var(--primary);
}

/* ===================== LOCATION PANEL (LEFT) ===================== */
.location-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--sls-panel-width);
    height: 100%;
    background: var(--surface-bright);
    border-right: 1px solid var(--outline);
    display: flex;
    flex-direction: column;
    z-index: 500;
    transition: all var(--transition-normal);
}

.location-panel.hidden {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.location-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.location-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: 8px;
    text-align: center;
}

.location-status .material-symbols-outlined {
    font-size: 48px;
    color: var(--primary);
}

.location-status p {
    font-size: 13px;
    color: var(--on-surface-light);
}

.location-coord {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: 8px;
    padding: 12px 16px;
}

.coord-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.coord-item:not(:last-child) {
    border-bottom: 1px solid var(--outline-dim);
}

.coord-item .label {
    font-size: 12px;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coord-item .value {
    font-size: 14px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--on-surface);
}

.location-sls {
    margin-top: 8px;
}

.sls-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--outline);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sls-panel-header h2 {
    font-size: 15px;
    font-weight: 700;
}

.sls-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.sls-panel-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--outline);
}

/* ===================== SLS CARD ===================== */
.sls-card {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    position: relative;
}

.sls-card-accent {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
}

.sls-card-content {
    padding: 16px;
    padding-left: 20px;
}

.sls-main-info {
    margin-bottom: 12px;
}

.sls-main-info label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.sls-main-info strong {
    font-size: 18px;
    font-weight: 700;
    color: var(--on-surface);
}

.sls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sls-grid label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.sls-grid span {
    font-size: 13px;
    color: var(--on-surface);
}

/* ===================== SLS SECTIONS ===================== */
.sls-section {
    margin-bottom: 20px;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.section-label .material-symbols-outlined {
    font-size: 16px;
}

.coord-display {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--on-surface);
}

.coord-display strong {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

/* ===================== NEARBY LIST ===================== */
.nearby-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nearby-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nearby-item:hover {
    border-color: var(--primary);
    background: var(--surface-bright);
}

.nearby-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--on-surface);
}

.nearby-item-id {
    font-size: 10px;
    color: var(--on-surface-muted);
    font-family: 'JetBrains Mono', monospace;
}

.nearby-item .material-symbols-outlined {
    font-size: 16px;
    color: var(--on-surface-muted);
}

.nearby-item:hover .material-symbols-outlined {
    color: var(--primary);
}

.empty-state {
    font-size: 13px;
    color: var(--on-surface-muted);
    text-align: center;
    padding: 20px;
}

/* ===================== MODAL ===================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface-bright);
    border: 1px solid var(--outline);
    border-radius: 12px;
    width: 420px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin-bottom: 12px;
    color: var(--on-surface);
    font-size: 14px;
}

.modal-body ul {
    margin-bottom: 12px;
    padding-left: 20px;
}

.modal-body li {
    margin-bottom: 4px;
    color: var(--on-surface-light);
    font-size: 13px;
}

/* ===================== CONTEXT MENU ===================== */
.ctx-menu {
    position: absolute;
    background: var(--surface-bright);
    border: 1px solid var(--outline);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 4px 0;
    z-index: 2000;
    min-width: 180px;
}

.ctx-menu.hidden {
    display: none;
}

.ctx-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--on-surface);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: all var(--transition-fast);
}

.ctx-menu-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.ctx-menu-item .material-symbols-outlined {
    font-size: 18px;
}

/* ===================== MAP POPUP ===================== */
.map-popup {
    font-size: 13px;
    line-height: 1.6;
}

.map-popup strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.map-popup a {
    color: var(--primary);
    text-decoration: none;
    font-size: 12px;
}

.map-popup a:hover {
    text-decoration: underline;
}

/* ===================== LOADING ===================== */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--outline);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* ===================== UTILITY ===================== */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--on-surface-muted);
    font-size: 12px;
}

.mt-16 {
    margin-top: 16px;
}

/* ===================== MOBILE HEADER ===================== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface-bright);
    border-bottom: 1px solid var(--outline);
    z-index: 900;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
}

.mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-header-brand .material-symbols-outlined {
    font-size: 24px;
    color: var(--primary);
}

.mobile-header-brand h1 {
    font-size: 16px;
    font-weight: 700;
    color: var(--on-surface);
}

/* ===================== HAMBURGER BUTTON ===================== */
.hamburger {
    display: none;
    position: fixed;
    top: 6px;
    right: 12px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--surface-bright);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--on-surface);
}

.hamburger:hover {
    background: var(--surface-dim);
}

.hamburger .material-symbols-outlined {
    font-size: 24px;
}

/* ===================== RESPONSIVE — TABLET (max-width: 1024px) ===================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
        --sls-panel-width: 300px;
        --search-panel-width: 360px;
    }
}

/* ===================== RESPONSIVE — MOBILE (max-width: 768px) ===================== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --sls-panel-width: 100%;
        --search-panel-width: calc(100% - 32px);
    }

    body {
        flex-direction: column;
    }

    /* Sidebar — overlay on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        z-index: 1000;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
    }

    .sidebar-backdrop.active {
        display: block;
    }

    /* Mobile header */
    .mobile-header {
        display: flex;
    }

    /* Hamburger button */
    .hamburger {
        display: flex;
    }

    /* Map area */
    .map-area {
        width: 100%;
        height: calc(100vh - 56px);
        margin-top: 56px;
    }

    /* Floating panel adjustments */
    .floating-panel {
        top: 12px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }

    /* SLS panel — full width bottom sheet */
    .sls-panel {
        width: 100%;
        height: 60vh;
        top: auto;
        bottom: 0;
        right: 0;
        border-left: none;
        border-top: 1px solid var(--outline);
        border-radius: 16px 16px 0 0;
    }

    .sls-panel.hidden {
        transform: translateY(100%);
    }

    /* History panel — full screen */
    .history-panel {
        width: 100%;
        border-right: none;
    }

    .history-panel.hidden {
        transform: translateX(-100%);
    }

    /* Location panel — full screen */
    .location-panel {
        width: 100%;
        border-right: none;
    }

    .location-panel.hidden {
        transform: translateX(-100%);
    }

    /* Modal — full screen */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    /* Map controls */
    .map-controls {
        bottom: 16px;
        right: 16px;
    }

    /* Crosshair */
    .crosshair {
        top: 45%;
    }

    /* SLS grid */
    .sls-grid {
        grid-template-columns: 1fr;
    }

    /* Coord display */
    .coord-display {
        flex-direction: column;
        gap: 4px;
    }
}
