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

:root {
    --accent-primary: #00a0e3;
    --accent-gradient: linear-gradient(135deg, #00a0e3 0%, #0088cc 100%);
    --accent-glow: rgba(0, 160, 227, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sidebar-width: 420px;
    --font: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* Light Mode variables (default) */
    --bg-primary: #f8fafc;
    --bg-sidebar: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.65);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --border-color: rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.05);
    --shadow-glow: 0 0 15px rgba(0, 160, 227, 0.15);
}

body.dark-theme {
    /* Dark Mode variables */
    --bg-primary: #0f172a;
    --bg-sidebar: #0b0f19;
    --bg-glass: rgba(30, 41, 59, 0.6);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #22d3ee;
    --accent-gradient: linear-gradient(135deg, #22d3ee 0%, #00a0e3 100%);
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 15px rgba(34, 211, 238, 0.15);
}

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

body {
    font-family: var(--font);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

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

.sidebar-header-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.sidebar-header-left p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Theme Toggle Button */
.btn-theme-toggle {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, background-color 0.2s ease;
    color: var(--text-primary);
}

.btn-theme-toggle:hover {
    transform: scale(1.05);
    background: var(--border-color);
}

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

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

/* Card layout */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.card ol {
    margin-left: 18px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Info Stats Banner */
.stats-banner {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.stat-item {
    flex: 1;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.stat-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-lbl {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* Address List Area */
.address-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 600;
}

.address-list-container {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px;
    box-shadow: var(--shadow-md);
}

.address-list-container::-webkit-scrollbar {
    width: 6px;
}

.address-list-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

/* Empty list state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 150px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    padding: 20px;
}

.empty-state svg {
    margin-bottom: 12px;
    stroke: var(--text-secondary);
    opacity: 0.5;
}

/* Address Items */
.address-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.address-item:hover {
    background-color: var(--border-color);
}

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

.address-main {
    font-weight: 500;
    color: var(--text-primary);
}

.address-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 160, 227, 0.12);
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
}

/* Export Buttons & Actions */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Map Window Container */
.map-container {
    flex: 1;
    position: relative;
    height: 100%;
}

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

/* Custom Overrides for Leaflet Dark & Light Theme */
.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
}

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

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

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-left-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Session Lists styling */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.list-item:hover {
    transform: translateY(-1px);
    background: var(--border-color);
}

.list-item.active {
    background: rgba(0, 160, 227, 0.08);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.list-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.list-name-txt {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.list-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.list-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.list-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    opacity: 0.5;
    transition: opacity 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.list-actions button:hover:not(:disabled) {
    opacity: 1;
    background: rgba(0, 160, 227, 0.12);
}

.list-actions button:disabled {
    opacity: 0.15;
    cursor: not-allowed;
}

.list-actions button svg {
    stroke: var(--text-primary);
}

.list-actions .btn-delete-list:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.12);
}

.list-actions .btn-delete-list svg {
    stroke: var(--danger);
}

.list-actions .btn-rename-list svg {
    stroke: var(--accent-primary);
}

/* Custom Geoman Polygon icon override to prevent SVG mask rendering bugs (squares) */
.leaflet-pm-toolbar .leaflet-pm-icon-polygon {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%230f172a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2L2 9l4 11h12l4-11z"/></svg>') !important;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px;
}

body.dark-theme .leaflet-pm-toolbar .leaflet-pm-icon-polygon {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23f8fafc" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2L2 9l4 11h12l4-11z"/></svg>') !important;
}

