* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f0f4f8;
    color: #1e293b;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ===== Map ===== */
#map {
    width: 100%;
    height: 100%;
}

/* ===== Search Panel ===== */
#search-panel {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    width: 380px;
    max-width: calc(100vw - 32px);
}

#search-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 6px 12px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

#logo {
    margin-right: 12px;
    white-space: nowrap;
}

.logo-text {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.5px;
}

.logo-accent {
    color: #2563eb;
}

#search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #1e293b;
    font-size: 15px;
    padding: 8px 4px;
}

#search-input::placeholder {
    color: #94a3b8;
}

#search-btn {
    background: #2563eb;
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#search-btn:hover {
    background: #1d4ed8;
}

/* Search Results */
#search-results {
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    max-height: 400px;
    overflow-y: auto;
}

#search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: background 0.15s;
}

.search-result-item:hover {
    background: rgba(37, 99, 235, 0.06);
}

.search-result-item:last-child {
    border-bottom: none;
}

.result-name {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
}

.result-type {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.result-score {
    font-size: 11px;
    color: rgba(37, 99, 235, 0.7);
    margin-left: 6px;
}

/* ===== Toolbar ===== */
#toolbar {
    position: absolute;
    top: 80px;
    left: 16px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toolbar-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.toolbar-btn:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.3);
    color: #2563eb;
}

.toolbar-btn.active {
    background: rgba(37, 99, 235, 0.1);
    border-color: #2563eb;
    color: #2563eb;
}

/* ===== Insights Panel ===== */
#insights-panel {
    position: absolute;
    top: 80px;
    right: 16px;
    z-index: 10;
    width: 400px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

#insights-panel.hidden { display: none; }

#insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-weight: 600;
    font-size: 15px;
    color: #0f172a;
}

#insights-header button {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
}

#insights-controls {
    display: flex;
    gap: 8px;
    padding: 12px 16px 8px;
}

#insights-controls select {
    flex: 1;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: #1e293b;
    font-size: 13px;
    outline: none;
}

#insights-hint {
    padding: 0 16px 12px;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.5;
}

#insights-results {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.insights-card {
    background: rgba(248, 250, 252, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 14px;
}

.insights-card h3 {
    font-size: 15px;
    margin-bottom: 6px;
    color: #0f172a;
}

.insights-subtitle {
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.5;
}

.insight-verdict {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(217, 119, 6, 0.1);
    color: #b45309;
    font-size: 12px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.score-item {
    background: rgba(241, 245, 249, 0.9);
    border-radius: 10px;
    padding: 10px;
}

.score-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.score-bar {
    height: 7px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4ecdc4, #ffd166, #ff6b6b);
}

.insight-reasons {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.insight-reason {
    font-size: 12px;
    color: #334155;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    padding: 8px 10px;
}

.gap-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.gap-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: rgba(241, 245, 249, 0.9);
    border-radius: 10px;
    padding: 10px 12px;
}

.gap-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gap-title {
    font-size: 13px;
    color: #1e293b;
}

.gap-caption {
    font-size: 11px;
    color: #94a3b8;
}

.gap-score {
    color: #059669;
    font-size: 13px;
    font-weight: 700;
}

/* ===== Route Panel ===== */
#route-panel {
    position: absolute;
    top: 80px;
    left: 68px;
    z-index: 10;
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

#route-panel.hidden { display: none; }

#route-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 15px;
    color: #0f172a;
}

#route-header button {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
}

#route-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

#route-inputs input {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: #1e293b;
    font-size: 13px;
    outline: none;
}

#route-info {
    padding: 8px 0;
    font-size: 14px;
    font-weight: 500;
    color: #2563eb;
}

#route-info.hidden { display: none; }

#route-actions {
    display: flex;
    gap: 8px;
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 6px 14px;
    color: #475569;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
}

/* Route marker */
.route-marker {
    width: 28px;
    height: 28px;
    background: #2563eb;
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ===== AI Panel ===== */
#ai-panel {
    position: absolute;
    bottom: 60px;
    right: 16px;
    z-index: 10;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: 500px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}

#ai-panel.hidden { display: none; }

#ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-weight: 600;
    font-size: 15px;
    color: #0f172a;
}

#ai-header button {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
}

#ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    max-height: 350px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-message {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
}

.ai-user {
    background: rgba(37, 99, 235, 0.1);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    color: #1e293b;
}

.ai-assistant {
    background: rgba(241, 245, 249, 0.95);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    color: #334155;
}

.ai-action-btn {
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
    padding: 6px 12px;
    color: #2563eb;
    font-size: 12px;
    cursor: pointer;
    align-self: flex-start;
    transition: background 0.2s;
}

.ai-action-btn:hover {
    background: rgba(37, 99, 235, 0.15);
}

#ai-input-container {
    display: flex;
    padding: 10px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    gap: 8px;
}

#ai-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: #1e293b;
    font-size: 13px;
    outline: none;
}

#ai-input::placeholder {
    color: #94a3b8;
}

#ai-send {
    background: #2563eb;
    border: none;
    border-radius: 8px;
    padding: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#ai-send:hover {
    background: #1d4ed8;
}

/* ===== Info Panel ===== */
#info-panel {
    position: absolute;
    bottom: 24px;
    left: 16px;
    z-index: 10;
    width: 380px;
    max-width: calc(100vw - 32px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 16px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

#info-panel.hidden {
    display: none;
}

#info-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

#info-close:hover {
    color: #475569;
}

#info-content h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #0f172a;
}

#info-content p {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 4px;
}

.info-coords {
    font-family: 'Consolas', monospace;
    font-size: 12px !important;
    color: rgba(37, 99, 235, 0.7) !important;
}

.info-timing {
    font-size: 11px !important;
    color: #94a3b8 !important;
    margin-top: 8px !important;
}

.info-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.info-actions button {
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
    padding: 6px 12px;
    color: #2563eb;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.info-actions button:hover {
    background: rgba(37, 99, 235, 0.15);
}

.info-address {
    font-weight: 500;
    color: #0f172a !important;
}

.info-road {
    color: #475569 !important;
}

.info-road small {
    color: #94a3b8;
}

.info-place small {
    color: #94a3b8;
}

/* ===== Stats Badge ===== */
#stats-badge {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 11px;
    color: #94a3b8;
    backdrop-filter: blur(8px);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

/* ===== MapLibre overrides ===== */
.maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.85) !important;
    color: #94a3b8 !important;
    font-size: 10px !important;
}

.maplibregl-ctrl-attrib a {
    color: rgba(37, 99, 235, 0.7) !important;
}

.maplibregl-popup-content {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #1e293b !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
}

.maplibregl-popup-content a {
    color: #2563eb !important;
}

.maplibregl-popup-tip {
    border-top-color: rgba(255, 255, 255, 0.95) !important;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    #search-panel { width: calc(100vw - 32px); }
    #info-panel { width: calc(100vw - 32px); }
    #ai-panel { width: calc(100vw - 32px); right: 16px; }
    #insights-panel { width: calc(100vw - 32px); top: 132px; }
    #route-panel { width: calc(100vw - 84px); }
    #toolbar { top: 74px; }
}
