:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --accent: #0ea5e9;
    --text: #1e293b;
    --text-light: #64748b;
    --text-lighter: #94a3b8;
    --bg: #f8fafc;
    --bg-alt: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);
    --radius: 16px;
    --radius-sm: 12px;
    --status-bar-height: 56px;
    --bottom-nav-height: 64px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100%;
    overflow: hidden;
    overscroll-behavior-y: contain;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-lighter);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-alt);
}

/* Hide scrollbar for about and info tabs */
#about-tab::-webkit-scrollbar,
#info-tab::-webkit-scrollbar {
    width: 4px;
}

#about-tab::-webkit-scrollbar-thumb,
#info-tab::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100px;
}

/* Safe Area Support for iOS */
@supports (padding-top: env(safe-area-inset-top)) {
    .status-bar {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--status-bar-height) + env(safe-area-inset-top));
    }

    .app-shell {
        padding-top: calc(var(--status-bar-height) + env(safe-area-inset-top));
    }

    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }

    .app-shell {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }
}

/* Status Bar */
.status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--status-bar-height);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.25);
}

.status-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="1" fill="white" opacity="0.1"/><circle cx="80" cy="60" r="1.5" fill="white" opacity="0.1"/><circle cx="50" cy="80" r="1" fill="white" opacity="0.1"/></svg>');
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.status-bar-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    position: relative;
    z-index: 1;
}

.brand-icon {
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* App Shell */
.app-shell {
    padding-top: var(--status-bar-height);
    padding-bottom: var(--bottom-nav-height);
    height: 100vh;
    overflow: hidden;
}

/* Main Content */
.main-content {
    height: 100%;
    overflow: hidden;
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease;
    height: 100%;
    overflow: hidden;
}

.tab-content.active {
    display: block;
}

/* Scrollable tabs (except map) */
#about-tab, #info-tab {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    z-index: 1001;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
}

.bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: transparent;
    color: var(--text-lighter);
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 24px;
    position: relative;
}

.bottom-nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 40px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 100px 100px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-nav-btn .nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.bottom-nav-btn.active::before {
    transform: translateX(-50%) scale(1);
}

.bottom-nav-btn.active {
    color: var(--primary);
}

.bottom-nav-btn.active .iconify {
    transform: scale(1.1);
}

.bottom-nav-btn:active {
    transform: scale(0.95);
}

/* Panel */
.panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    border: 1px solid rgba(226, 232, 240, 0.6);
}

.panel:active {
    transform: translateY(1px);
}

.panel.compact {
    padding: 12px;
}

.panel h2 {
    font-size: 1.25rem;
    margin-bottom: 12px;
    color: var(--text);
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.panel h3 {
    font-size: 1.05rem;
    margin-bottom: 10px;
    color: var(--text);
    font-weight: 600;
}

.panel p {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Map Container */
.map-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Map Controls Panel */
.map-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-sm);
    padding: 10px;
    z-index: 1000;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

/* Custom Select Dropdown */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.custom-select-trigger:hover {
    border-color: var(--primary-light);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.custom-select-trigger span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    flex: 1;
}

.custom-arrow {
    color: var(--text-light);
    font-size: 0.9rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-select.open .custom-arrow {
    transform: rotate(180deg);
}

/* Dropdown Options */
.custom-options {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 0;
    overflow: hidden;
    z-index: 2000;
}

.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    max-height: 320px;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.search-icon {
    font-size: 1rem;
    opacity: 0.5;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 500;
}

.search-box input::placeholder {
    color: var(--text-lighter);
}

/* Options List */
.options-list {
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
}

.option-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 3px solid transparent;
}

.option-item:hover {
    background: var(--bg);
    border-left-color: var(--primary);
}

.option-item.selected {
    background: rgba(37, 99, 235, 0.08);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.option-item.parent {
    background: var(--bg-alt);
    font-weight: 600;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
}

.option-item.separator {
    height: 1px;
    padding: 0;
    margin: 4px 0;
    background: var(--border);
    cursor: default;
    pointer-events: none;
}

.option-item.no-results {
    text-align: center;
    color: var(--text-lighter);
    cursor: default;
    font-style: italic;
}

.option-item.no-results:hover {
    background: transparent;
    border-left-color: transparent;
}

/* Map Info Panel */
.map-info {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-sm);
    padding: 14px;
    z-index: 1000;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
    display: none;
}

.map-info.show {
    display: block;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.info-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.info-details {
    display: grid;
    gap: 6px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.info-label {
    color: var(--text-light);
    font-weight: 500;
}

.info-value {
    color: var(--text);
    font-weight: 600;
}

/* About & Info Sections */
.feature-grid {
    display: grid;
    gap: 10px;
    margin: 12px 0;
}

.feature-card {
    background: var(--surface);
    padding: 14px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(226, 232, 240, 0.6);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.05) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feature-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.feature-card:active::before {
    opacity: 1;
}

.feature-icon {
    font-size: 32px;
    margin-bottom: 10px;
    color: var(--primary);
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

.feature-card h3 {
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--text);
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.feature-card p {
    color: var(--text-light);
    font-size: 0.875rem;
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

.category-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.tag {
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(14, 165, 233, 0.08) 100%);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 600;
    border: 1px solid rgba(37, 99, 235, 0.15);
    transition: all 0.3s ease;
}

.tag:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(14, 165, 233, 0.15) 100%);
}

/* Accordion */
.accordion {
    margin-top: 16px;
}

.accordion-item {
    margin-bottom: 8px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.accordion-header {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-alt);
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
    transition: all 0.2s ease;
}

.accordion-header:active {
    background: var(--border);
}

.accordion-icon {
    transition: transform 0.3s ease;
    font-size: 1.2rem;
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-item.active .accordion-content {
    max-height: 500px;
}

.accordion-content p {
    padding: 16px;
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Loading */
.loading {
    text-align: center;
    padding: 32px 16px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 0 auto 12px;
    position: relative;
}

.spinner::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-bottom-color: var(--accent);
    animation: spin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite reverse;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Leaflet Custom Styles */
.leaflet-container {
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 14px;
    font-size: 0.9rem;
}

.leaflet-popup-content h4 {
    margin: 0 0 8px 0;
    color: var(--primary);
    font-weight: 700;
}

.leaflet-popup-content p {
    margin: 4px 0;
    color: var(--text-light);
}

/* Responsive Design - Tablet */
@media (min-width: 640px) {
    #about-tab, #info-tab {
        padding: 20px;
    }

    .panel {
        padding: 20px;
    }

    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .map-controls {
        max-width: 400px;
    }

    .map-info {
        max-width: 500px;
    }
}

/* Responsive Design - Desktop */
@media (min-width: 1024px) {
    :root {
        --status-bar-height: 0;
        --bottom-nav-height: 0;
    }

    html, body {
        overflow: auto;
    }

    .status-bar {
        display: none;
    }

    .bottom-nav {
        display: none;
    }

    .app-shell {
        max-width: 1400px;
        margin: 0 auto;
        padding: 32px 24px;
        height: auto;
        overflow: visible;
    }

    .main-content {
        padding: 0;
        height: auto;
        overflow: visible;
    }

    .tab-content {
        height: auto;
        overflow: visible;
    }

    #about-tab, #info-tab {
        overflow: visible;
        padding: 0;
    }

    /* Desktop Header */
    .app-shell::before {
        content: '';
        display: block;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        height: 72px;
        margin: -32px -24px 24px;
        border-radius: var(--radius);
        box-shadow: var(--shadow);
    }

    .tab-content.active::before {
        content: 'Regional';
        display: block;
        font-size: 1.75rem;
        font-weight: 700;
        color: var(--text);
        margin-bottom: 8px;
    }

    #map-tab.active::before {
        content: 'Peta Wilayah Indonesia';
    }

    #about-tab.active::before {
        content: 'Tentang Layanan';
    }

    #info-tab.active::before {
        content: 'Informasi Wilayah';
    }

    .feature-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .map-container {
        height: calc(100vh - 200px);
        overflow: hidden;
    }
}
