/* ==========================================================================
   Eternatus Quest Radar - Modern Pokémon Theme (Dark Glassmorphism)
   ========================================================================== */

:root {
    --bg-dark: #0f0c1b;
    --bg-card: rgba(26, 20, 48, 0.75);
    --bg-card-hover: rgba(41, 31, 74, 0.9);
    --border-color: rgba(147, 51, 234, 0.25);
    --border-hover: rgba(168, 85, 247, 0.6);
    
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.5);
    --eternatus-red: #f43f5e;
    --eternatus-pink: #ec4899;
    --accent-cyan: #06b6d4;
    --accent-gold: #fbbf24;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --nav-height: 64px;
    --stats-height: 44px;
    --control-height: 98px;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans TC', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* ==========================================================================
   Header & Top Nav
   ========================================================================== */

.top-nav {
    height: var(--nav-height);
    background: linear-gradient(135deg, rgba(19, 13, 36, 0.95), rgba(30, 16, 56, 0.9));
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
}

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

.logo-box {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(244, 63, 94, 0.3) 0%, rgba(139, 92, 246, 0.2) 70%);
    border: 1.5px solid var(--eternatus-pink);
    box-shadow: 0 0 15px var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.eternatus-avatar {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.candy-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: linear-gradient(135deg, #e11d48, #be185d);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    padding: 1px 5px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ffffff, #c084fc, #f43f5e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.4);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   Stats Bar
   ========================================================================== */

.stats-bar {
    background: rgba(15, 11, 28, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 20px;
    overflow-x: auto;
    font-size: 0.8rem;
    white-space: nowrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-label {
    color: var(--text-dim);
}

.stat-val {
    color: var(--text-main);
    font-weight: 600;
}

.stat-val.highlight {
    color: var(--eternatus-pink);
    font-weight: 800;
}

.reward-tag {
    background: rgba(244, 63, 94, 0.15);
    color: #fda4af;
    border: 1px solid rgba(244, 63, 94, 0.3);
    padding: 1px 8px;
    border-radius: 12px;
}

.alert-banner {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #ffffff;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 1001;
    animation: pulseGlow 2s infinite;
}

.alert-banner.hidden {
    display: none;
}

.stale-banner {
    background: linear-gradient(135deg, #e11d48, #b91c1c);
    color: #ffffff;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 1001;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.stale-banner.hidden {
    display: none;
}

.error-banner {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #ffffff;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 1001;
}

.error-banner.hidden {
    display: none;
}

/* ==========================================================================
   Control Panel & Filter Chips
   ========================================================================== */

.control-panel {
    background: rgba(22, 16, 40, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.city-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.city-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.chip.active {
    background: linear-gradient(135deg, var(--eternatus-red), var(--eternatus-pink));
    color: #ffffff;
    border-color: transparent;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4);
}

.btn-chip-filter {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-chip-filter:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.btn-chip-filter.active {
    background: linear-gradient(135deg, var(--eternatus-red), var(--eternatus-pink));
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4);
}

.filter-row-2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 450px;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0.6;
}

.search-box input {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 7px 32px 7px 32px;
    color: #ffffff;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.btn-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-clear.hidden {
    display: none;
}

.view-toggles {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.btn-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
}

/* ==========================================================================
   Main Layout: Split / Map / List
   ========================================================================== */

.main-content {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Split view (desktop default) */
.main-content.split-view .map-wrapper {
    flex: 1;
    height: 100%;
    position: relative;
}

.main-content.split-view .list-wrapper {
    width: 420px;
    height: 100%;
    background: rgba(18, 14, 32, 0.92);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 500;
}

/* Map only view */
.main-content.map-view .map-wrapper {
    width: 100%;
    height: 100%;
}

.main-content.map-view .list-wrapper {
    display: none;
}

/* List only view */
.main-content.list-view .map-wrapper {
    display: none;
}

.main-content.list-view .list-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#map {
    width: 100%;
    height: 100%;
    background: #110d21;
}

.map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 12, 27, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 1000;
}

.map-overlay.hidden {
    display: none;
}

/* ==========================================================================
   List Sidebar & Quest Cards
   ========================================================================== */

.list-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(25, 19, 44, 0.6);
}

.list-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-title-wrap h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.badge {
    background: rgba(139, 92, 246, 0.2);
    color: #c084fc;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.sort-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sort-selector select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: #ffffff;
    font-size: 0.75rem;
    padding: 4px 6px;
    outline: none;
}

.quest-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quest-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.quest-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.2);
}

.quest-card.active {
    border-color: var(--eternatus-pink);
    box-shadow: 0 0 16px rgba(244, 63, 94, 0.35);
}

.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.stop-name-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pokestop-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.stop-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
}

.distance-badge {
    background: rgba(6, 182, 212, 0.15);
    color: #67e8f9;
    border: 1px solid rgba(6, 182, 212, 0.3);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
}

.card-task {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #e2e8f0;
}

.task-tag {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 6px;
    white-space: nowrap;
}

.card-reward {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.25);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    margin-top: 2px;
}

.reward-candy-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.reward-text {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fda4af;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.75rem;
    color: var(--text-dim);
}

.card-actions {
    display: flex;
    gap: 6px;
}

.btn-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    min-height: 44px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
    transition: all 0.2s;
}

.btn-nav:hover {
    filter: brightness(1.15);
    transform: scale(1.03);
}

.btn-copy {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-muted);
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* ==========================================================================
   Leaflet Custom Map Marker & Popups
   ========================================================================== */

.custom-eternatus-marker {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle, #f43f5e 20%, #7c3aed 80%);
    border: 2px solid #ffffff;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.8), 0 2px 8px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.custom-eternatus-marker:hover {
    transform: scale(1.2);
    z-index: 9999 !important;
}

.custom-eternatus-marker img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}

.custom-eternatus-marker .marker-amount {
    position: absolute;
    bottom: -5px;
    right: -6px;
    background: #ec4899;
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    padding: 1px 4px;
    border-radius: 8px;
    border: 1px solid #fff;
}

/* Leaflet Popup Styling */
.leaflet-popup-content-wrapper {
    background: rgba(20, 15, 38, 0.96) !important;
    backdrop-filter: blur(10px);
    border: 1px solid var(--eternatus-pink) !important;
    border-radius: var(--radius-md) !important;
    color: #ffffff !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7), 0 0 18px rgba(244, 63, 94, 0.4) !important;
    padding: 0 !important;
}

.leaflet-popup-tip {
    background: rgba(20, 15, 38, 0.96) !important;
    border: 1px solid var(--eternatus-pink) !important;
}

.popup-card {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
}

.popup-title {
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.popup-task {
    font-size: 0.85rem;
    color: #cbd5e1;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 8px;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.popup-reward {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fda4af;
}

.popup-btn-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    margin-top: 4px;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.4);
}

/* User Location Marker */
.user-location-marker {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #06b6d4;
    border: 3px solid #ffffff;
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.9);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.8); }
    70% { box-shadow: 0 0 0 15px rgba(6, 182, 212, 0); }
    100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

/* Spinners */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-state, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* ==========================================================================
   Responsive Mobile Optimization
   ========================================================================== */

@media (max-width: 768px) {
    .main-content.split-view {
        flex-direction: column;
    }

    .main-content.split-view .map-wrapper {
        height: 48%;
    }

    .main-content.split-view .list-wrapper {
        width: 100%;
        height: 52%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .brand-text h1 {
        font-size: 1rem;
    }

    .subtitle {
        display: none;
    }

    .btn-text {
        display: none;
    }

    .btn {
        padding: 8px;
    }

    .filter-row-2 {
        flex-wrap: wrap;
        gap: 8px;
    }

    .search-box {
        max-width: 100%;
        flex: 1 1 100%;
    }

    .btn-chip-filter {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .btn-nav {
        min-height: 44px;
        min-width: 60px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .btn-copy {
        min-height: 44px;
        padding: 10px 12px;
    }
}
