/* ============================================
   Professional Dashboard - Forests RS
   Cool-toned, minimal design
   ============================================ */

:root {
    /* Primary Palette - Cool Blues & Teals */
    --primary-color: #0F766E;           /* Deep teal */
    --primary-dark: #0D5E57;            /* Darker teal */
    --primary-light: #14B8A6;           /* Bright teal */
    --primary-lighter: #CCFBF1;         /* Very light teal */
    
    /* Secondary Palette - Blue Grays */
    --secondary-color: #475569;         /* Slate gray */
    --secondary-dark: #334155;          /* Dark slate */
    --secondary-light: #64748B;         /* Light slate */
    
    /* Neutral Palette */
    --bg-primary: #F8FAFC;              /* Very light blue-gray */
    --bg-secondary: #FFFFFF;            /* White */
    --bg-tertiary: #F1F5F9;             /* Light blue-gray */
    
    /* Text Colors */
    --text-primary: #1E293B;            /* Almost black */
    --text-secondary: #64748B;          /* Medium gray */
    --text-muted: #94A3B8;              /* Light gray */
    
    /* Borders */
    --border-color: #E2E8F0;            /* Light border */
    --border-dark: #CBD5E1;             /* Medium border */
    
    /* Accent */
    --accent-color: #06B6D4;            /* Cyan */
    --success-color: #14B8A6;           /* Teal */
    --warning-color: #F59E0B;           /* Amber */
    --danger-color: #EF4444;            /* Red */
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

/* ============================================
   Main Layout
   ============================================ */

.container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: absolute;    /* NEW! */
    top: 0;
    left: 0;
}

/* Map page container - accounts for fixed navigation */
.container.map-page-container {
    margin-top: 60px;
    height: calc(100vh - 60px);
    max-width: 100%;
    padding: 0;
    top: 60px;            /* Changed from margin-top */
    margin: 0;            /* Explicit zero */
}

/* Map Container */
.map-container {
    flex: 0 0 50%;
    position: relative;
    background: var(--bg-tertiary);
    min-width: 300px;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Resizer */
.resizer {
    width: 1px;
    background: var(--border-dark);
    cursor: col-resize;
    position: relative;
    flex-shrink: 0;
    transition: var(--transition);
    z-index: 100;
}

.resizer:hover,
.resizer.resizing {
    background: var(--primary-color);
    width: 3px;
}

/* Dashboard Container */
.dashboard-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 400px;
    overflow: hidden;
    height: 100%;
}

/* ============================================
   Header Section
   ============================================ */

.dashboard-header-section {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Main Header */
.main-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: var(--spacing-lg) var(--spacing-xl);
}

.main-header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.025em;
    margin: 0;
}

.main-header p {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 4px;
    font-weight: 400;
}

/* Dashboard Title Section */
.dashboard-title-section {
    padding: var(--spacing-lg) var(--spacing-xl);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.dashboard-title-section.hidden {
    display: none;
}

.dashboard-title-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.025em;
}

.dashboard-title-section p {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}

.close-dashboard {
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-xl);
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-dashboard:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-dark);
    color: var(--text-primary);
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1px;
    background: var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.stat-card:nth-child(1),
.stat-card:nth-child(2),
.stat-card:nth-child(3) {
    grid-column: span 4;
}

.stat-card:nth-child(4),
.stat-card:nth-child(5),
.stat-card:nth-child(6),
.stat-card:nth-child(7) {
    grid-column: span 3;
}

.stat-card {
    background: var(--bg-secondary);
    padding: var(--spacing-lg);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.stat-card:hover {
    background: var(--bg-tertiary);
}

.stat-card.active {
    background: var(--primary-lighter);
    position: relative;
}

.stat-card.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    margin-bottom: 4px;
    letter-spacing: -0.05em;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   Tab Content Area
   ============================================ */

.tab-content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-primary);
    padding: var(--spacing-xl);
}

.tab-content-area::-webkit-scrollbar {
    width: 8px;
}

.tab-content-area::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.tab-content-area::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}

.tab-content-area::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-light);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Content Card */
.content-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.content-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-color);
    padding: var(--spacing-lg) var(--spacing-xl);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    margin: 0;
    letter-spacing: -0.01em;
}

/* Item List */
.item-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.item-list li {
    padding: var(--spacing-md) var(--spacing-xl);
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    font-size: 13px;
    line-height: 1.6;
    color: var(--primary-color);
}

.item-list li:last-child {
    border-bottom: none;
}

.item-list li:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

.item-list a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.item-list a:hover {
    color: var(--primary-color);
}

.item-list strong {
    font-weight: 600;
    color: var(--text-primary);
}

.item-list em {
    font-style: italic;
    color: var(--text-primary);
}

.text-muted {
    color: var(--text-muted);
    font-size: 12px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    letter-spacing: 0.025em;
}

.badge-priority {
    background: #FEF3C7;
    color: #92400E;
}

.badge-info {
    background: var(--primary-lighter);
    color: var(--primary-dark);
}

.badge-redlist {
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-CO { background: #1F2937; color: #fff; }
.badge-CR { background: #DC2626; color: #fff; }
.badge-EN { background: #F59E0B; color: #fff; }
.badge-VU { background: #FCD34D; color: #92400E; }
.badge-NT { background: #A3E635; color: #365314; }
.badge-LC { background: #10B981; color: #fff; }
.badge-DD { background: #6B7280; color: #fff; }
.badge-NE { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border-color); }

.no-data {
    padding: var(--spacing-xl);
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================
   Footer
   ============================================ */

.footer {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    margin-top: var(--spacing-2xl);
    padding: var(--spacing-xl) 0;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-xl);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-2xl);
    margin-bottom: var(--spacing-sm);
}

.footer-section h3,
.footer-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.025em;
}

.footer-section p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li {
    margin-bottom: var(--spacing-sm);
}

.footer-links a {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
}

.footer-bottom p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

.footer-social {
    display: flex;
    gap: var(--spacing-md);
}

.footer-social a {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: var(--transition);
}

.footer-social a:hover {
    background: var(--primary-color);
    color: white;
}


/* ============================================
   Loading & Errors
   ============================================ */

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    z-index: 2000;
    min-width: 280px;
    border: 1px solid var(--border-color);
}

.loading > div:first-child {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

#progress {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.05em;
}

#progressBar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

#progressBarFill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 3px;
}

.loading::before {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 0 auto var(--spacing-md);
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    display: none;
    background: #FEE2E2;
    color: #991B1B;
    padding: var(--spacing-md) var(--spacing-lg);
    margin: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--danger-color);
    font-size: 13px;
}

/* ============================================
   Map Popup
   ============================================ */

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.popup-content {
    padding: var(--spacing-md);
    min-width: 200px;
}

.popup-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

/* Map Controls */
.leaflet-control-zoom {
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: var(--radius-sm) !important;
}

.leaflet-control-zoom a {
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 16px !important;
    border: none !important;
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--primary-color) !important;
    color: white !important;
}

.leaflet-bar {
    border: none !important;
}

/* ============================================
   MOBILE FIX - Dashboard Flow
   Replace the mobile section in map-styles.css with this
   ============================================ */

@media (max-width: 968px) {
    .container.map-page-container {
        flex-direction: column;
        top: 60px;
        height: calc(100vh - 60px);
    }
    
    .map-container {
        flex: 0 0 35vh;
        width: 100%;
        min-width: unset;
    }
    
    .resizer {
        width: 100%;
        height: 1px;
        cursor: row-resize;
    }
    
    .resizer:hover,
    .resizer.resizing {
        height: 3px;
    }
    
    /* CRITICAL FIX: Make dashboard flow naturally */
    .dashboard-container {
        flex: 1;
        min-width: unset;
        overflow-y: auto; /* Single scroll for entire dashboard */
        overflow-x: hidden;
        display: block; /* Change from flex to block */
        height: auto; /* Let it flow naturally */
    }
    
    /* CRITICAL FIX: Header is no longer fixed */
    .dashboard-header-section {
        position: static; /* Not fixed */
        flex-shrink: 1; /* Allow to scroll */
    }
    
    /* CRITICAL FIX: Tab content area flows naturally */
    .tab-content-area {
        flex: none; /* Don't flex, just flow */
        overflow: visible; /* No separate scroll */
        padding: var(--spacing-md);
        -webkit-overflow-scrolling: touch;
    }
    
    /* CRITICAL FIX: Footer flows at the end */
    .footer {
        position: static; /* Not fixed */
        margin-top: 0;
        flex-shrink: 1;
    }
    
   /* KEEP the 3+4 layout, just adjust sizes */
    .stats-grid {
        grid-template-columns: repeat(12, 1fr); /* Keep 12 columns */
        /* Layout stays the same! */
    }
    
    /* First row still 3 cards */
    .stat-card:nth-child(1),
    .stat-card:nth-child(2),
    .stat-card:nth-child(3) {
        grid-column: span 4; /* Keep same */
    }
    
    /* Second row still 4 cards */
    .stat-card:nth-child(4),
    .stat-card:nth-child(5),
    .stat-card:nth-child(6),
    .stat-card:nth-child(7) {
        grid-column: span 3; /* Keep same */
    }
    
    /* Just make content smaller */
    .stat-card {
        padding: var(--spacing-sm); /* Smaller padding */
        min-height: 60px; /* Touch-friendly */
    }
    
    .stat-value {
        font-size: 16px; /* Smaller numbers */
        margin-bottom: 2px;
    }
    
    .stat-label {
        font-size: 9px; /* Smaller labels */
        line-height: 1.2;
        letter-spacing: 0.03em;
    }
    
    /* Touch targets */
    .stat-card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    /* Smaller header on mobile */
    .main-header {
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    .main-header h1 {
        font-size: 18px;
    }
    
    .main-header p {
        font-size: 12px;
    }
    
    /* Dashboard title section more compact */
    .dashboard-title-section {
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    .dashboard-title-section h2 {
        font-size: 16px;
    }
    
    .dashboard-title-section p {
        font-size: 12px;
    }
    
    /* Smaller close button */
    .close-dashboard {
        width: 24px;
        height: 24px;
        font-size: 12px;
        top: var(--spacing-sm);
        right: var(--spacing-sm);
    }
    
    /* Smaller content card headers */
    .content-card h3 {
        font-size: 13px;
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    /* Compact item list */
    .item-list li {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 12px;
        line-height: 1.5;
    }
    
    .item-list a {
        font-size: 12px;
    }
    
    /* Smaller badges */
    .badge {
        font-size: 10px;
        padding: 2px 6px;
        margin-left: 4px;
    }
    
    .badge-redlist {
        font-size: 10px;
        padding: 2px 8px;
    }
    
    /* No-data message smaller */
    .no-data {
        padding: var(--spacing-lg);
        font-size: 12px;
    }
    
    /* Footer more compact */
    .footer {
        padding: var(--spacing-lg) 0;
    }
    
    .footer-container {
        padding: 0 var(--spacing-md);
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .footer-section h3 {
        font-size: 13px;
        margin-bottom: var(--spacing-sm);
    }
    
    .footer-section p {
        font-size: 12px;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: var(--spacing-sm);
        padding-top: var(--spacing-sm);
    }
    
    .footer-bottom p {
        font-size: 11px;
        text-align: center;
    }
    
    /* Touch targets */
    .stat-card {
        min-height: 60px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
   
    /* Prevent text selection on tap */
    .stat-card,
    .close-dashboard,
    .content-card h3 {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* ============================================
   EXTRA SMALL MOBILE (< 480px)
   ============================================ */

@media (max-width: 480px) {
    /* Even smaller map on tiny screens */
    .map-container {
        flex: 0 0 30vh;
    }
    
    /* Very compact header */
    .main-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .main-header h1 {
        font-size: 16px;
    }
    
    .main-header p {
        font-size: 11px;
    }
    
   /* KEEP the 3+4 layout, just adjust sizes */
    .stats-grid {
        grid-template-columns: repeat(12, 1fr); /* Keep 12 columns */
        /* Layout stays the same! */
    }
    
    /* First row still 3 cards */
    .stat-card:nth-child(1),
    .stat-card:nth-child(2),
    .stat-card:nth-child(3) {
        grid-column: span 4; /* Keep same */
    }
    
    /* Second row still 4 cards */
    .stat-card:nth-child(4),
    .stat-card:nth-child(5),
    .stat-card:nth-child(6),
    .stat-card:nth-child(7) {
        grid-column: span 3; /* Keep same */
    }
    
    /* Just make content smaller */
    .stat-card {
        padding: var(--spacing-sm); /* Smaller padding */
        min-height: 60px; /* Touch-friendly */
    }
    
    .stat-value {
        font-size: 16px; /* Smaller numbers */
        margin-bottom: 2px;
    }
    
    .stat-label {
        font-size: 9px; /* Smaller labels */
        line-height: 1.2;
        letter-spacing: 0.03em;
    }
    
    /* Touch targets */
    .stat-card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    /* Very compact content */
    .tab-content-area {
        padding: var(--spacing-sm);
    }
    
    .content-card h3 {
        font-size: 12px;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    /* Very compact list items */
    .item-list li {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 11px;
    }
    
    .item-list a {
        font-size: 11px;
    }
    
    .item-list strong {
        font-size: 11px;
    }
    
    /* Tiny badges */
    .badge {
        font-size: 9px;
        padding: 1px 4px;
    }
    
    .badge-redlist {
        font-size: 9px;
        padding: 2px 6px;
    }
    
    /* Very compact footer */
    .footer {
        padding: var(--spacing-md) 0;
    }
    
    .footer-container {
        padding: 0 var(--spacing-sm);
    }
    
    .footer-section h3 {
        font-size: 12px;
    }
    
    .footer-section p {
        font-size: 11px;
    }
    
    .footer-bottom p {
        font-size: 10px;
    }
}

/* ============================================
   LANDSCAPE MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 968px) and (orientation: landscape) {
    /* In landscape, give more space to map */
    .map-container {
        flex: 0 0 50vh;
    }
    
    /* Reduce header size in landscape */
    .main-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .main-header h1 {
        font-size: 16px;
    }
    
    .main-header p {
        font-size: 11px;
    }
    
    /* Compact stats in landscape */
    .stat-card {
        padding: var(--spacing-sm);
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 10px;
    }
}

/* ============================================
   LOADING INDICATOR MOBILE
   ============================================ */

@media (max-width: 968px) {
    .loading {
        min-width: 240px;
        padding: var(--spacing-lg);
    }
    
    .loading > div:first-child {
        font-size: 13px;
    }
    
    #progress {
        font-size: 20px;
    }
    
    .loading::before {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 480px) {
    .loading {
        min-width: 200px;
        padding: var(--spacing-md);
    }
    
    .loading > div:first-child {
        font-size: 12px;
    }
    
    #progress {
        font-size: 18px;
    }
    
    .loading::before {
        width: 28px;
        height: 28px;
    }
}

/* ============================================
   ERROR MESSAGE MOBILE
   ============================================ */

@media (max-width: 968px) {
    .error-message {
        margin: var(--spacing-sm) var(--spacing-md);
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 12px;
    }
}

/* ============================================
   MAP CONTROLS MOBILE
   ============================================ */

/* ============================================
   MOBILE MAP CONTROLS - Smaller Elements
   Add to map-styles.css
   ============================================ */

@media (max-width: 968px) {
    
    /* ============================================
       Zoom Controls - Smaller
       ============================================ */
    
    .leaflet-control-zoom {
        border: 1px solid var(--border-color) !important;
        box-shadow: var(--shadow-sm) !important;
        border-radius: var(--radius-sm) !important;
    }
    
    .leaflet-control-zoom a {
        width: 32px !important;       /* Smaller from 40px */
        height: 32px !important;
        line-height: 32px !important;
        font-size: 16px !important;   /* Smaller icon */
        border: none !important;
        background: var(--bg-secondary) !important;
        color: var(--text-primary) !important;
    }
    
    .leaflet-control-zoom a:hover {
        background: var(--primary-color) !important;
        color: white !important;
    }
    
    /* ============================================
       Scale Control - Smaller
       ============================================ */
    
    .leaflet-control-scale {
        font-size: 10px !important;   /* Smaller text */
        line-height: 1.2 !important;
    }
    
    .leaflet-control-scale-line {
        border: 1px solid #333 !important;
        border-top: none !important;
        padding: 1px 4px !important;  /* Tighter padding */
        background: rgba(255, 255, 255, 0.7) !important;
        font-size: 10px !important;
    }
    
    /* ============================================
       Attribution - Smaller
       ============================================ */
    
    .leaflet-control-attribution {
        font-size: 9px !important;    /* Very small */
        padding: 2px 4px !important;
        background: rgba(255, 255, 255, 0.8) !important;
        line-height: 1.2 !important;
    }
    
    .leaflet-control-attribution a {
        font-size: 9px !important;
    }
    
    /* ============================================
       Popup - Smaller
       ============================================ */
    
    .leaflet-popup {
        margin-bottom: 15px !important; /* Closer to point */
    }
    
    .leaflet-popup-content-wrapper {
        border-radius: var(--radius-sm) !important;
        padding: 0 !important;
        box-shadow: var(--shadow-md) !important;
        border: 1px solid var(--border-color) !important;
    }
    
    .leaflet-popup-content {
        margin: 8px 10px !important;  /* Smaller margin */
        font-size: 12px !important;   /* Smaller text */
        line-height: 1.4 !important;
        min-width: 140px !important;  /* Narrower */
    }
    
    .popup-content {
        padding: 6px !important;      /* Tighter padding */
    }
    
    .popup-title {
        font-size: 12px !important;   /* Smaller title */
        font-weight: 600;
        color: var(--primary-color);
        padding-bottom: 4px !important;
        border-bottom: 1px solid var(--border-color);
        line-height: 1.3 !important;
    }
    
    /* Popup close button */
    .leaflet-popup-close-button {
        width: 20px !important;       /* Smaller close button */
        height: 20px !important;
        font-size: 16px !important;
        line-height: 20px !important;
        padding: 0 !important;
        top: 4px !important;
        right: 4px !important;
    }
    
    /* Popup tip (arrow) */
    .leaflet-popup-tip {
        width: 12px !important;       /* Smaller arrow */
        height: 12px !important;
    }
    
    /* ============================================
       Loading Indicator - Adjusted for Map
       ============================================ */
    
    .loading {
        min-width: 200px !important;
        padding: var(--spacing-md) !important;
        font-size: 12px !important;
    }
    
    .loading::before {
        width: 28px !important;
        height: 28px !important;
        margin-bottom: 8px !important;
    }
    
    #progress {
        font-size: 18px !important;
        margin-bottom: 8px !important;
    }
    
    #progressBar {
        height: 4px !important;       /* Thinner progress bar */
    }
    
    /* ============================================
       Map Container Adjustments
       ============================================ */
    
    .map-container {
        /* Ensure map takes proper space */
        position: relative;
        overflow: hidden;
    }
    
    #map {
        /* Ensure map fills container */
        width: 100%;
        height: 100%;
        touch-action: manipulation; /* Better touch handling */
    }
    
    /* ============================================
       SVG Boundaries - Thinner lines on mobile
       ============================================ */
    
    /* This affects the ŠPP boundary lines */
    .leaflet-overlay-pane svg {
        /* No changes needed, but you could add if desired */
    }
    
    .leaflet-overlay-pane path {
        /* Boundaries already set in your JS, but could override here */
        stroke-width: 1.5px !important; /* Slightly thinner on mobile */
    }
}

/* ============================================
   EXTRA SMALL MOBILE - Even Smaller Controls
   ============================================ */

@media (max-width: 480px) {
    
    /* Even smaller zoom controls */
    .leaflet-control-zoom a {
        width: 28px !important;
        height: 28px !important;
        line-height: 28px !important;
        font-size: 14px !important;
    }
    
    /* Tiny scale */
    .leaflet-control-scale {
        font-size: 9px !important;
    }
    
    .leaflet-control-scale-line {
        font-size: 9px !important;
        padding: 1px 3px !important;
    }
    
    /* Tiny attribution */
    .leaflet-control-attribution {
        font-size: 8px !important;
        padding: 1px 3px !important;
    }
    
    /* Compact popup */
    .leaflet-popup-content {
        margin: 6px 8px !important;
        font-size: 11px !important;
        min-width: 120px !important;
    }
    
    .popup-title {
        font-size: 11px !important;
    }
    
    .leaflet-popup-close-button {
        width: 18px !important;
        height: 18px !important;
        font-size: 14px !important;
    }
}

/* ============================================
   LANDSCAPE MODE - Compact controls
   ============================================ */

@media (max-width: 968px) and (orientation: landscape) {
    
    /* Keep controls small in landscape too */
    .leaflet-control-zoom a {
        width: 28px !important;
        height: 28px !important;
        line-height: 28px !important;
        font-size: 14px !important;
    }
    
    .leaflet-control-scale,
    .leaflet-control-scale-line {
        font-size: 9px !important;
    }
    
    .leaflet-popup-content {
        margin: 6px 8px !important;
        font-size: 11px !important;
    }
}

/* ============================================
   TOUCH IMPROVEMENTS
   ============================================ */

@media (max-width: 968px) {
    
    /* Better tap targets for zoom */
    .leaflet-control-zoom {
        margin-top: 8px !important;
        margin-left: 8px !important;
    }
    
    /* Disable double-tap zoom (can interfere) */
    .leaflet-container {
        -webkit-tap-highlight-color: transparent;
        tap-highlight-color: transparent;
    }
    
    /* Better popup interaction */
    .leaflet-popup {
        pointer-events: auto !important;
    }
    
    .leaflet-popup-content-wrapper {
        pointer-events: auto !important;
    }
}