:root {
    /* Theme Colors */
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --danger: #ef4444;
    --gold: #eab308;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.logo-icon .brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.brand-text h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 7px;
}

.app-version {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 1px 7px;
    border-radius: 999px;
    letter-spacing: 0.3px;
    line-height: 1.3;
}

.app-version:empty {
    display: none;
}

.status-indicator {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-indicator .dot {
    width: 6px;
    height: 6px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Search Section */
.search-section {
    padding: var(--spacing-md);
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-start;
}

.compass-widget {
    flex-shrink: 0;
    width: 60px;
    /* Height is determined by content + padding, but let's keep it consistent */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.compass-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.direction-label {
    position: absolute;
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: bold;
}

.direction-label.n {
    top: 4px;
}

.direction-label.e {
    right: 4px;
}

.direction-label.s {
    bottom: 4px;
}

.direction-label.w {
    left: 4px;
}

.compass-arrow {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 20px solid var(--primary);
    transform-origin: center bottom;
    margin-bottom: 10px;
    transition: transform 0.3s ease-out;
}

/* Cone Indicator */
.cone-indicator {
    margin-top: 8px;
    text-align: center;
    color: var(--gold);
    font-size: 1.2rem;
    animation: pulse 2s infinite;
}

.cone-indicator.hidden {
    display: none;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.5;
        transform: scale(1);
    }
}

.search-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    min-width: 0;
    /* Prevent flex child overflow */
}

.search-bar {
    display: flex;
    gap: 4px;
    /* Reduced gap */
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    width: 100%;
}

.mic-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    /* Reduced padding */
    color: var(--danger);
    /* Default Red */
    font-size: 1.1rem;
    transition: color 0.3s;
    flex-shrink: 0;
}

.mic-icon-wrapper.active {
    color: var(--success);
}

#search-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1rem;
    padding: 8px 0;
    outline: none;
    min-width: 0;
    /* Allow shrinking */
}

.go-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0 12px;
    /* Reduced padding */
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.go-btn:hover {
    background-color: var(--primary-hover);
}

/* Active Route Banner */
.active-route-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.22), rgba(30, 41, 59, 0.95));
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.25s ease-out;
}

.active-route-banner.hidden {
    display: none;
}

.route-banner-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.route-banner-info i {
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
}

#route-banner-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-banner-meta {
    font-size: 0.75rem;
    color: var(--gold);
    background: rgba(234, 179, 8, 0.18);
    border: 1px solid rgba(234, 179, 8, 0.35);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}

.clear-route-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.clear-route-btn:hover {
    color: var(--danger);
    transform: scale(1.1);
}

.quick-filters {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    width: 100%;
}

.filter-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 8px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    width: 100%;
}

.filter-btn i {
    color: var(--primary);
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.add-btn {
    border-style: dashed;
    color: var(--text-muted);
}

/* Main Content */
#main-content {
    flex-grow: 1;
    background-color: #131c2e;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: var(--spacing-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.route-options-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding-bottom: var(--spacing-lg);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
}

/* Result Card */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    position: relative;
    transition: transform 0.2s;
}

.result-card:active {
    transform: scale(0.98);
}

.result-card.best-match {
    border: 1px solid var(--success);
    box-shadow: 0 0 0 1px var(--success);
}

.result-card.standard-match {
    border: 1px solid var(--gold);
}

.match-badge {
    position: absolute;
    top: -1px;
    left: -1px;
    background: var(--success);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 12px;
    border-top-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    text-transform: uppercase;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-sm);
    margin-top: 12px;
}

.place-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.external-link {
    color: var(--text-muted);
    font-size: 1rem;
}

.tags {
    display: flex;
    gap: 6px;
    margin-bottom: var(--spacing-md);
}

.tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.tag.on-route {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

.metrics {
    display: flex;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    color: var(--text-main);
    font-size: 0.95rem;
}

.metric {
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric i {
    color: var(--primary);
}

.detour-badge {
    color: var(--gold);
    border: 1px solid rgba(234, 179, 8, 0.3);
    background: rgba(234, 179, 8, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: monospace;
}

.speak-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-md);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.match-percent {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 700;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.78);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 500px;
    max-height: 90%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Map Popup Card */
.map-popup-card {
    width: 92%;
    max-width: 680px;
    height: 80vh;
    max-height: 580px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalScaleIn 0.22s ease-out;
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.map-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #1e293b;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.map-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-modal-title i {
    color: var(--primary);
    font-size: 1.1rem;
}

.map-modal-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.map-modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444;
    transform: scale(1.08);
}

.map-modal-body {
    flex: 1;
    position: relative;
    min-height: 250px;
    width: 100%;
}

#map-container {
    width: 100%;
    height: 100%;
}

.map-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #1e293b;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    gap: 10px;
    flex-wrap: wrap;
}

.map-modal-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.map-modal-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.map-modal-meta .detour-chip {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(37, 99, 235, 0.4);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.map-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-modal-actions .modal-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-sm);
    margin: 0;
}

/* Settings Modal Specifics - Dark Theme */
.settings-content {
    background: var(--bg-card);
    color: var(--text-main);
}

.modal-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-main);
}

.close-modal-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal-btn:hover {
    color: var(--text-main);
}

.modal-body {
    padding: var(--spacing-md);
    overflow-y: auto;
}

/* Loading Spinner */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

#loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(59, 130, 246, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--spacing-md);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    .search-section {
        padding: var(--spacing-sm);
        gap: var(--spacing-sm);
    }

    .compass-widget {
        width: 50px;
    }

    .compass-circle {
        width: 50px;
        height: 50px;
    }

    .search-bar {
        padding: 2px;
    }

    .go-btn {
        padding: 0 10px;
        font-size: 0.9rem;
    }
}

/* Add Filter Modal Styles */
.filter-modal-content {
    max-width: 400px;
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--primary);
}

.icon-selection-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--bg-dark);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.icon-option {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-option:hover {
    color: var(--text-main);
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.icon-option.selected {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.modal-btn.primary {
    background: var(--primary);
    color: white;
}

.modal-btn.primary:hover {
    background: var(--primary-hover);
}

.modal-btn.secondary {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.modal-btn.secondary:hover {
    color: var(--text-main);
    background: var(--bg-card-hover);
}

/* Live Log Console Drawer */
.log-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #0f172a;
    border-top: 1px solid var(--border-color);
    z-index: 900;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #1e293b;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
}

.log-title i {
    color: var(--primary);
}

.log-badge {
    background: var(--primary);
    color: white;
    font-size: 0.68rem;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 700;
}

.log-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.log-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 5px;
    transition: color 0.2s;
}

.log-icon-btn:hover {
    color: var(--danger);
}

.toggle-chevron {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.25s ease;
}

.toggle-chevron.open {
    transform: rotate(180deg);
}

.log-content {
    max-height: 220px;
    overflow-y: auto;
    padding: 10px 14px;
    font-size: 0.76rem;
    color: #cbd5e1;
    background: #090d16;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-content.hidden {
    display: none;
}

.log-line {
    line-height: 1.45;
    word-break: break-word;
}

.log-line.info { color: #94a3b8; }
.log-line.success { color: #34d399; font-weight: 600; }
.log-line.warning { color: #fbbf24; }
.log-line.error { color: #f87171; font-weight: 600; }
.log-line.highlight { color: #60a5fa; }

/* High-Tech Radar HUD Cone Styling */
.radar-cone-main {
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.45));
    animation: radarConePulse 3.5s ease-in-out infinite alternate;
}

.radar-range-ring {
    stroke-linecap: round;
    filter: drop-shadow(0 0 3px rgba(56, 189, 248, 0.4));
}

.radar-heading-line {
    stroke-linecap: round;
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.9));
    animation: radarBeamFlow 1.8s linear infinite;
}

@keyframes radarConePulse {
    0% {
        fill-opacity: 0.12;
        stroke-opacity: 0.65;
    }
    100% {
        fill-opacity: 0.22;
        stroke-opacity: 0.95;
    }
}

@keyframes radarBeamFlow {
    from {
        stroke-dashoffset: 0;
    }
    to {
        stroke-dashoffset: -24;
    }
}

.radar-badge-container {
    background: transparent !important;
    border: none !important;
    pointer-events: none !important;
}

.radar-dist-badge {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.55);
    color: #38bdf8;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    white-space: nowrap;
    display: inline-block;
    line-height: 1.2;
}

.radar-dist-badge.max {
    border-color: rgba(56, 189, 248, 0.85);
    color: #e0f2fe;
    background: rgba(2, 132, 199, 0.9);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

