/* style.css - Premium Design System */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    /* Theme - Obsidian Dark (Default) */
    --bg-primary: rgba(18, 18, 24, 0.75);
    --bg-surface: rgba(30, 30, 40, 0.65);
    --bg-hover: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.4);
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-slow: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Theme Variant - Neon Cyberpunk */
[data-theme="cyberpunk"] {
    --bg-primary: rgba(10, 6, 22, 0.85);
    --bg-surface: rgba(26, 12, 48, 0.7);
    --bg-hover: rgba(244, 63, 94, 0.15);
    --border-color: rgba(244, 63, 94, 0.2);
    --border-glow: rgba(244, 63, 94, 0.4);
    --text-primary: #00f0ff;
    --text-secondary: #ff007f;
    --text-muted: #7045b5;
    --accent: #ff007f;
    --accent-glow: rgba(255, 0, 127, 0.5);
    --accent-success: #00ff66;
    --accent-danger: #ff0055;
    --accent-warning: #ffea00;
}

/* Theme Variant - Classic Light Acrylic */
[data-theme="acrylic"] {
    --bg-primary: rgba(255, 255, 255, 0.8);
    --bg-surface: rgba(248, 250, 252, 0.75);
    --bg-hover: rgba(15, 23, 42, 0.05);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-glow: rgba(15, 23, 42, 0.15);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #0f172a;
    --accent-glow: rgba(15, 23, 42, 0.2);
    --accent-success: #16a34a;
    --accent-danger: #dc2626;
    --accent-warning: #d97706;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    background-color: #0f172a;
    color: var(--text-primary);
}

/* ── Leaflet Custom Styling ────────────────────────────────────────── */
#map {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Remove default Leaflet style shadows and borders */
.leaflet-bar {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

.leaflet-bar a {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    backdrop-filter: blur(12px);
    transition: background-color var(--transition-fast);
}

.leaflet-bar a:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.leaflet-control-layers {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-md) !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(12px);
    font-family: var(--font-sans) !important;
    padding: 6px 10px !important;
}

.leaflet-control-scale-line {
    background: var(--bg-primary) !important;
    border: 2px solid var(--text-secondary) !important;
    border-top: none !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(12px);
    font-size: 11px !important;
    font-family: var(--font-mono) !important;
}

.leaflet-bottom.leaflet-left {
    left: 350px !important;
    bottom: 15px !important;
    transition: left var(--transition-slow);
}

body.sidebar-collapsed .leaflet-bottom.leaflet-left {
    left: 10px !important;
}

/* ── Glassmorphism Utility ─────────────────────────────────────────── */
.glass-panel {
    background: var(--bg-primary);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-panel:hover {
    border-color: var(--border-glow);
}

/* ── Sidebar Dashboard Layout ──────────────────────────────────────── */
.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    bottom: 20px;
    width: 320px;
    z-index: 100;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition-slow);
}

.sidebar.collapsed {
    transform: translateX(-350px);
}

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

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

.logo-icon {
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
    animation: pulse-glow 3s infinite ease-in-out;
}

.logo-section h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.toggle-sidebar-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.toggle-sidebar-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Sidebar Toggle Trigger (Visible when collapsed) */
.sidebar-trigger {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    z-index: 99;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.sidebar-trigger.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.sidebar-trigger:hover {
    border-color: var(--border-glow);
    background-color: var(--bg-surface);
}

/* Tabs System */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 14px 0;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--text-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 15%;
    width: 70%;
    height: 2px;
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    border-radius: 2px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Scrollbar Customization */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}
.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sidebar Modules */
.tab-pane {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.module-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.module-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── UI Details & Typography ───────────────────────────────────────── */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.info-value {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: 600;
}

/* ── Search Input Box ──────────────────────────────────────────────── */
.search-wrapper {
    position: relative;
    display: flex;
    gap: 8px;
}

.search-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 14px;
    padding-left: 36px;
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition-fast);
}

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

.search-icon-inline {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0 16px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.search-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.search-results-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    display: none;
}

.search-result-item {
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-item:hover {
    background-color: var(--bg-hover);
}

/* ── Bookmark Manager ──────────────────────────────────────────────── */
.waypoint-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.waypoint-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.waypoint-item:hover {
    border-color: var(--text-muted);
}

.waypoint-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.waypoint-name {
    font-size: 13px;
    font-weight: 600;
}

.waypoint-coords {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.delete-waypoint-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.delete-waypoint-btn:hover {
    color: var(--accent-danger);
    background-color: var(--bg-hover);
}

/* Add Waypoint Button Wrapper */
.add-waypoint-wrapper {
    display: flex;
    gap: 8px;
}

.waypoint-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-family: var(--font-sans);
    font-size: 12px;
    outline: none;
}

/* ── Floating Compass Display Panels ────────────────────────────────── */
.floating-overlay-panel {
    position: absolute;
    z-index: 100;
    pointer-events: auto;
}

/* Top Center HUD Display */
.coords-hud {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    text-align: center;
    min-width: 280px;
}

.coords-hud-latlng {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.coords-hud-sun {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Floating Bearing Display (Attached above the compass normally or overlay) */
.bearing-badge {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1.5px solid var(--border-glow);
    color: var(--text-primary);
    padding: 6px 16px;
    border-radius: 30px;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    z-index: 1005;
    pointer-events: none;
}

/* ── Compass Styling ────────────────────────────────────────────────── */
#tool-box {
    position: absolute;
    width: calc(260px * var(--compass-scale, 1));
    height: calc(500px * var(--compass-scale, 1));
    z-index: 1000;
    touch-action: none;
    user-select: none;
    pointer-events: none;
    transform-origin: calc(130px * var(--compass-scale, 1)) calc(310px * var(--compass-scale, 1));
    filter: drop-shadow(var(--shadow-lg));
}

#compass-svg {
    width: calc(260px * var(--compass-scale, 1));
    height: calc(500px * var(--compass-scale, 1));
    display: block;
    overflow: visible;
    cursor: grab;
    pointer-events: none;
}

#compass-baseplate, #capsule-counter, #rotate-handle {
    pointer-events: auto;
}

#compass-svg:active {
    cursor: grabbing;
}

/* Rotate handle */
#rotate-handle {
    position: absolute;
    bottom: 25px;
    right: 95px; /* Aligns with handle area */
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, #ec4899, #be185d 80%);
    border: 3px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    z-index: 1003;
    user-select: none;
    transition: transform var(--transition-fast);
}

#rotate-handle:hover {
    transform: scale(1.05);
}

#rotate-handle:active {
    cursor: grabbing;
    transform: scale(0.95);
}

#rotate-handle svg {
    color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Bezel Customizations */
#bezel-ticks line {
    stroke: var(--text-primary);
}
#bezel-labels text {
    fill: var(--text-primary);
}

/* Custom Themes inside SVG */
[data-theme="cyberpunk"] #compass-svg path {
    fill: rgba(10, 6, 22, 0.4);
    stroke: #ff007f;
}
[data-theme="cyberpunk"] #bezel-ticks line {
    stroke: #00f0ff;
}
[data-theme="cyberpunk"] #bezel-labels text {
    fill: #00f0ff;
}
[data-theme="cyberpunk"] #rotate-handle {
    background: radial-gradient(circle at 38% 35%, #00ffff, #0088cc 80%);
    border-color: #00ffff;
}

/* ── Bottom Measurement Action Bar ──────────────────────────────────── */
.action-bar-container {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 90vw;
    max-width: 800px;
}

.action-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 40px;
    flex-wrap: wrap;
    justify-content: center;
    pointer-events: auto;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: 30px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.action-btn.active {
    background-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 12px var(--accent-glow);
}

.action-btn-danger {
    color: var(--accent-danger);
}
.action-btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
}

.action-btn-warning {
    color: var(--accent-warning);
}
.action-btn-warning:hover {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
}

/* Measurement Info Box */
.measure-info {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 20px;
    display: none;
    animation: fade-in 0.25s var(--transition-fast);
}

/* ── Map Mode Trigger/Helper ────────────────────────────────────────── */
body.measuring #map {
    cursor: crosshair !important;
}

/* Theme Options Styling */
.theme-selector {
    display: flex;
    gap: 8px;
}

.theme-opt {
    flex: 1;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    padding: 10px 0;
    text-align: center;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-opt:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.theme-opt.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Animations */
@keyframes pulse-glow {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
        filter: drop-shadow(0 0 12px var(--accent-glow));
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        width: calc(100vw - 40px);
        left: 20px;
        bottom: auto;
        height: 60%;
    }
    
    .sidebar.collapsed {
        transform: translateY(-110%);
    }
    
    .sidebar-trigger {
        top: 20px;
        left: 20px;
    }
    
    .coords-hud {
        display: none; /* Hide coordinate HUD on small screens to save space */
    }
    
    .action-bar-container {
        width: 90%;
        bottom: 16px;
    }
    
    .action-bar {
        width: 100%;
        justify-content: space-around;
        padding: 6px;
    }
    
    .action-btn span {
        display: none; /* Hide button text on mobile, icons only */
    }
}
