@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --bg-input-focus: #ffffff;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-focus: #93c5fd;
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --transition: 0.2s ease-in-out;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ============ MAP ============ */
#map-container { position: absolute; inset: 0; }
#map { width: 100%; height: 100%; z-index: 1; }

/* ============ FLOATING UI CARD ============ */
.sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 360px;
    max-height: calc(100vh - 40px);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============ HEADER ============ */
.header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 24px; }
h1 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.subtitle { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* ============ CONTENT ============ */
.content { padding: 16px 20px; overflow-y: auto; }
.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* ============ STATUS BADGE ============ */
.status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 12px;
    font-size: 0.7rem; font-weight: 500;
    background: #f1f5f9; border: 1px solid var(--border);
    color: var(--text-secondary); margin-bottom: 16px;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.status-dot.online { background: #10b981; }
.status-dot.offline { background: #ef4444; }

/* ============ API KEY ============ */
.api-key-section { margin-bottom: 16px; }
.api-key-section label {
    display: block; font-size: 0.7rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 4px; text-transform: uppercase;
}
.api-key-input {
    width: 100%; padding: 8px 10px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.8rem;
    transition: all var(--transition);
}
.api-key-input:focus { outline: none; border-color: var(--border-focus); background: var(--bg-input-focus); }

/* ============ PROFILE SELECTOR ============ */
.profile-selector {
    display: flex; background: #f1f5f9;
    border-radius: var(--radius-sm); padding: 4px; margin-bottom: 16px;
}
.profile-btn {
    flex: 1; padding: 6px; background: transparent; border: none;
    color: var(--text-secondary); font-size: 0.8rem; font-weight: 500;
    border-radius: 4px; cursor: pointer; transition: all var(--transition);
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.profile-btn:hover { background: #e2e8f0; }
.profile-btn.active { background: white; color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.profile-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* ============ INPUTS ============ */
.inputs-container { margin-bottom: 16px; }
.input-group { position: relative; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.input-icon { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.icon-start { border: 3px solid var(--accent); background: white; }
.icon-end { background: #ef4444; }
.input-wrapper { flex: 1; position: relative; }
.location-input {
    width: 100%; padding: 10px 30px 10px 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.85rem;
    transition: all var(--transition);
}
.location-input:focus { outline: none; border-color: var(--border-focus); background: var(--bg-input-focus); box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
.input-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    display: none; padding: 4px; font-size: 10px;
}
.input-wrapper:has(.location-input.has-value) .input-clear { display: block; }

/* ============ SUGGESTIONS ============ */
.suggestions {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: white; border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); z-index: 2000; max-height: 150px; overflow-y: auto; display: none;
}
.suggestions.show { display: block; }
.suggestion-item { padding: 6px 10px; cursor: pointer; border-bottom: 1px solid #f1f5f9; display: flex; gap: 8px; align-items: flex-start; }
.suggestion-item:hover { background: #f8fafc; }
.suggestion-item svg { width: 12px; height: 12px; fill: var(--text-muted); margin-top: 3px; flex-shrink: 0; }
.suggestion-main { font-size: 0.75rem; font-weight: 500; color: var(--text-primary); margin-bottom: 1px; line-height: 1.2; }
.suggestion-sub { font-size: 0.65rem; color: var(--text-muted); line-height: 1.2; }

/* ============ BUTTONS ============ */
.btn-group { display: flex; gap: 8px; }
.primary-btn {
    flex: 1; padding: 10px; background: var(--accent); color: white;
    border: none; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition); display: flex; justify-content: center; gap: 6px; align-items: center;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn svg { width: 16px; height: 16px; fill: currentColor; }
.secondary-btn {
    padding: 10px 16px; background: white; color: var(--text-secondary);
    border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
}
.secondary-btn:hover { background: #f8fafc; color: var(--text-primary); }

/* ============ ROUTE STATS & DIRECTIONS ============ */
.route-stats {
    display: none; margin-top: 16px; padding: 12px;
    background: #f8fafc; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; margin-bottom: 2px; }
.stat-value { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.stat-value.time { color: var(--accent); }

.directions-panel { display: none; margin-top: 12px; }
.directions-header {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
    cursor: pointer; padding: 8px 0; border-top: 1px solid var(--border);
}
.directions-list { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.directions-list.open { max-height: 300px; overflow-y: auto; padding-right: 4px; }
.direction-step {
    display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f5f9;
}
.step-num {
    width: 20px; height: 20px; background: #eff6ff; color: var(--accent);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; font-weight: 600; flex-shrink: 0;
}
.step-instruction { font-size: 0.75rem; color: var(--text-primary); margin-bottom: 2px; }
.step-distance { font-size: 0.65rem; color: var(--text-muted); }

/* ============ MAP CONTROLS ============ */
.locate-control {
    position: absolute; bottom: 30px; right: 20px; z-index: 1000;
    width: 40px; height: 40px; background: white; border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 1px 5px rgba(0,0,0,0.65);
}
.locate-control:hover { background: #f4f4f4; }
.locate-control svg { width: 20px; height: 20px; fill: #444; }

.loading-overlay {
    display: none; position: absolute; inset: 0; background: rgba(255,255,255,0.7);
    z-index: 900; align-items: center; justify-content: center;
}
.loading-overlay.show { display: flex; }
.loading-spinner { width: 40px; height: 40px; border: 3px solid #e2e8f0; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.user-location-marker { width: 14px; height: 14px; background: var(--accent); border: 2px solid white; border-radius: 50%; box-shadow: 0 0 8px rgba(0,0,0,0.4); }

/* ============ TOAST ============ */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 16px; background: white; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); font-size: 0.8rem; color: var(--text-primary);
    display: flex; align-items: center; gap: 8px; border-left: 3px solid var(--accent);
}

/* ============ MOBILE ============ */
.sidebar-open-btn, .sidebar-toggle, .sidebar-close-btn { display: none !important; }
@media (max-width: 600px) {
    .sidebar { width: calc(100% - 20px); left: 10px; top: 10px; max-height: 50vh; }
    .locate-control { bottom: 20px; right: 10px; }
}
