/* Layout for chat and right panel */
.main-flex { display:flex; flex-direction:row; gap:16px; align-items:stretch; position:relative; }
.left-panel { flex:1 1 auto; min-width:380px; max-width:none; }
.right-panel { flex:0 0 300px; width:300px; max-width:300px; min-width:260px; display:flex; flex-direction:column; gap:12px; }

/* Collapsible right panel behavior */
.right-panel.collapsed {
    max-width: 0 !important;
    min-width: 0 !important;
    width: 0 !important;
    overflow: hidden;
    padding: 0;
    margin: 0;
}
.right-panel-toggle { background:#f0f2f8; border:1px solid #cbd3e6; color:#1f3c88; border-radius:6px; cursor:pointer; padding:4px 8px; font-size:12px; line-height:1; }
.right-panel-toggle:hover { background:#e4e9f5; }
.right-panel-toggle.inside { position:static; margin-left:auto; }
/* Floating toggle button always visible */
.floating-toggle {
    position:fixed;
    top:16px;
    right:16px;
    z-index:2000;
    background:#1f3c88;
    color:#fff;
    border:none;
    border-radius:40px;
    padding:10px 14px;
    box-shadow:0 4px 14px rgba(0,0,0,0.18);
    cursor:pointer;
    font-size:14px;
    font-weight:600;
    display:flex;
    align-items:center;
    gap:6px;
    transition:background .2s, transform .2s;
}
.floating-toggle:hover { background:#25489e; transform:translateY(-2px); }
.floating-toggle.collapsed { background:#455a64; }
.floating-toggle.collapsed:hover { background:#546e7a; }
/* Google Maps container */
.map-container { width:100%; margin:8px 0 0 0; border-radius:8px; overflow:hidden; box-shadow:0 1px 6px rgba(0,0,0,0.08); }
/* Modern Checkbox Styles */
.disability-selector { margin:0; }
.panel-header-compact { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.panel-header-compact label { font-size:12px; font-weight:600; margin:0; }
.checkbox-group { display:flex; flex-direction:column; gap:4px; margin-top:4px; }
.modern-checkbox { position:relative; padding-left:18px; cursor:pointer; font-size:12px; user-select:none; color:#333; display:flex; align-items:center; min-height:20px; }
.modern-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}
.modern-checkbox .checkmark {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 14px;
    width: 14px;
    background-color: #eee;
    border-radius: 4px;
    border: 1.5px solid #bbb;
    transition: background 0.2s, border 0.2s;
}
.modern-checkbox input:checked ~ .checkmark {
    background-color: #007bff;
    border-color: #007bff;
}
.modern-checkbox .checkmark:after {
    left: 4px;
    top: 1px;
    width: 3px;
    height: 7px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* When the right panel is collapsed, expand chat */
#main-container.right-collapsed .left-panel {
    flex: 1 1 auto;
    max-width: none;
}
body { font-family:Arial,sans-serif; margin:0; padding:0; background:#f4f4f9; }
.container { max-width:99vw; width:99vw; margin:4px auto; padding:16px 6px 20px; background:#fff; border-radius:10px; box-shadow:0 2px 14px rgba(0,0,0,0.06); }
h1 { text-align:center; color:#333; font-size:1.25rem; margin:4px 0 6px; font-weight:600; letter-spacing:.5px; }

#chat-box { display:flex; flex-direction:column; height:460px; border:1px solid #d9d9d9; border-radius:8px; overflow:hidden; }

/* Message style when showing the chosen route text */
.message.chosen-route {
    background: #eef9f1;
    border-left: 4px solid #38a169;
}

.chat-history { flex:1; padding:6px 8px; overflow-y:auto; background:#f9f9f9; }

.chat-history .message { margin:0 0 6px; padding:6px 8px; border-radius:5px; }

.chat-history .message.user {
    background-color: #d1e7dd;
    text-align: right;
}

.chat-history .message.bot {
    background-color: #f8d7da;
    text-align: left;
}

.chat-input { display:flex; padding:6px; background:#fff; border-top:1px solid #ddd; }

.chat-input input { flex:1; padding:6px 8px; border:1px solid #ccc; border-radius:5px; margin-right:6px; font-size:13px; }

.chat-input button { padding:6px 12px; background:#007bff; color:#fff; border:none; border-radius:5px; cursor:pointer; font-size:13px; }

.chat-input button:disabled {
    background-color: #bdbdbd;
    color: #f3f3f3;
    cursor: not-allowed;
}

.chat-input button:not(:disabled):hover {
    background-color: #0056b3;
}

.chart-container {
    margin-top: 20px;
}

/* Natural answer width and wrapping */
.natural-answer { max-width:68ch; margin:4px 0; }
.natural-answer pre { white-space:pre-wrap; word-break:break-word; margin:0; background:transparent; font-family:inherit; font-size:.9em; }

/* Copy button styles */
.copy-btn {
    background: #eef3ff;
    border: 1px solid #c6d5f5;
    color: #1f3c88;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
}
.copy-btn:hover {
    background: #e0e8ff;
}
.copy-btn.copied {
    background: #e6f4ea;
    border-color: #bde5c8;
    color: #18632a;
}

/* HTML modal styles */
.html-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 20, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.html-modal {
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
}
.html-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f5f7fb;
    border-bottom: 1px solid #e6e9f2;
}
.html-modal-title {
    font-weight: 600;
}
.html-modal-close {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
}
.html-modal-iframe {
    flex: 1;
    border: none;
}

/* Bootstrap-like elegant table styles */
.results-table-container { overflow-x:auto; margin:10px 0; }
.results-table { width:100%; border-collapse:collapse; background:#fff; font-size:.9em; color:#222; box-shadow:0 1px 4px rgba(0,0,0,0.05); border-radius:6px; overflow:hidden; }

/* Best route table specific tweaks */
.best-route-table .col-natural {
    max-width: 30vw; /* roughly 30% of viewport width */
    width: 30%;
}
.best-route-table .col-natural pre.cell-pre {
    white-space: normal;
}
.best-route-table .col-horas {
    max-width: 22vw;
}
.best-route-table .col-horas pre.cell-pre {
    white-space: normal;
}

/* Traffic light (semaforo) indicators standardized 1-5 */
.semaforo { display:inline-flex; align-items:center; gap:4px; padding:2px 6px; border-radius:999px; font-weight:600; font-size:.70rem; line-height:1; }
.semaforo .dot { width:10px; height:10px; border-radius:50%; display:inline-block; }
/* Level 0 (neutral) */
.semaforo.sem-level-0 { background:#eceff1; color:#546e7a; }
.semaforo.sem-level-0 .dot { background:#90a4ae; }
/* Level 1 very easy / low */
.semaforo.sem-level-1 { background:#e8f5e9; color:#2e7d32; }
.semaforo.sem-level-1 .dot { background:#2e7d32; }
/* Level 2 easy */
.semaforo.sem-level-2 { background:#f1f8e9; color:#558b2f; }
.semaforo.sem-level-2 .dot { background:#558b2f; }
/* Level 3 medium */
.semaforo.sem-level-3 { background:#fff8e1; color:#f57f17; }
.semaforo.sem-level-3 .dot { background:#f57f17; }
/* Level 4 hard */
.semaforo.sem-level-4 { background:#ffebee; color:#d84315; }
.semaforo.sem-level-4 .dot { background:#d84315; }
/* Level 5 very hard / critical */
.semaforo.sem-level-5 { background:#ffebee; color:#b71c1c; box-shadow:0 0 0 1px #ffcdd2 inset; }
.semaforo.sem-level-5 .dot { background:#b71c1c; }
/* Backwards compatibility for existing classes (optional) */
.semaforo.low { background:#e8f5e9; color:#2e7d32; }
.semaforo.low .dot { background:#2e7d32; }
.semaforo.mid { background:#fff8e1; color:#f57f17; }
.semaforo.mid .dot { background:#f57f17; }
.semaforo.high { background:#ffebee; color:#c62828; }
.semaforo.high .dot { background:#c62828; }
.results-table th, .results-table td { padding:8px 10px; border-bottom:1px solid #e9ecef; text-align:left; vertical-align:top; }
.results-table th {
    background: #f5f7fb;
    font-weight: 600;
    color: #1f3c88;
    border-top: 1px solid #e9ecef;
}
.results-table tr:last-child td {
    border-bottom: none;
}
.results-table tr:hover {
    background: #f0f4fa;
    transition: background 0.2s;
}

/* Make route rows look clickable */
tr.route-row { cursor:pointer; }
tr.route-row:hover { background:#e9f2ff; }

/* Selected route row */
.results-table tr.selected-route {
    background: #e3f2fd !important;
}

/* Optional: rounded corners for first/last cells */
.results-table th:first-child, .results-table td:first-child {
    border-top-left-radius: 8px;
}
.results-table th:last-child, .results-table td:last-child {
    border-top-right-radius: 8px;
}

/* Markdown styles */
.markdown-body { font-family:'Segoe UI', Arial, sans-serif; font-size:.9em; color:#222; line-height:1.5; max-width:68ch; margin:0 auto 1em; word-break:break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    font-weight: 600;
    margin-top: 1.2em;
    margin-bottom: 0.6em;
    color: #1f3c88;
}
.markdown-body ul, .markdown-body ol {
    margin: 1em 0 1em 2em;
}
.markdown-body pre, .markdown-body code {
    background: #f5f7fb;
    border-radius: 4px;
    font-family: 'Fira Mono', 'Consolas', monospace;
    font-size: 0.97em;
    padding: 2px 6px;
}
.markdown-body pre {
    padding: 12px;
    overflow-x: auto;
}
.markdown-body blockquote {
    border-left: 4px solid #b3c7f9;
    background: #f5f7fb;
    color: #555;
    margin: 1em 0;
    padding: 0.7em 1em;
    border-radius: 4px;
}
.markdown-body table {
    margin: 1em 0;
    border-collapse: collapse;
    width: 100%;
}
.markdown-body th, .markdown-body td {
    border: 1px solid #e9ecef;
    padding: 8px 12px;
}
.markdown-body th {
    background: #f5f7fb;
    font-weight: 600;
    color: #1f3c88;
}

/* Lost button styles */
.chat-input .lost-btn {
    background: #ff0026;
    border: 1px solid #ffcdd2;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
}

.chat-input .lost-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
} 

.chat-input .lost-btn:not(:disabled):hover {
    background: #ffcdd2;
}

/* ================= Origen/Destino Panel ================= */
.od-panel { position:fixed; right:16px; bottom:16px; width:300px; max-height:60vh; background:#ffffff; box-shadow:0 4px 16px rgba(0,0,0,0.18); border-radius:14px; padding:14px 16px 18px; display:flex; flex-direction:column; gap:10px; z-index:1500; border:1px solid #ececec; }
.od-header { font-weight:600; font-size:15px; }
.od-field-group { position:relative; }
.od-label { display:block; font-size:12px; font-weight:600; margin-bottom:4px; }
.od-input { width:100%; padding:8px 10px; border:1px solid #ccc; border-radius:8px; font-size:13px; background:#fff; }
.od-input:focus { outline:2px solid #1976d2; border-color:#1976d2; }
.od-results { list-style:none; margin:4px 0 0; padding:0; max-height:150px; overflow:auto; border:1px solid #ddd; border-radius:8px; background:#fff; box-shadow:0 2px 8px rgba(0,0,0,0.1); }
.od-results li { padding:6px 10px; cursor:pointer; font-size:13px; }
.od-results li:hover, .od-results li:focus { background:#f0f6ff; }
.od-results li.selected { background:#dbeeff; }
.od-actions { display:flex; justify-content:flex-end; }
.od-ok-btn { background:#1976d2; color:#fff; border:none; padding:8px 16px; border-radius:8px; font-size:13px; cursor:pointer; transition:.2s; }
.od-ok-btn:disabled { opacity:.45; cursor:not-allowed; }
.od-ok-btn:not(:disabled):hover { background:#125ca5; }
.od-hint { font-size:11px; color:#666; margin-top:2px; }
@media (max-width: 800px) { .od-panel { width:90%; right:5%; bottom:8px; } }

/* Selected Route Panel */
.selected-route-panel { margin:12px auto 18px; max-width:92vw; width:92vw; background:#ffffff; border:1px solid #dfe3eb; border-radius:10px; padding:12px 16px 16px; box-shadow:0 2px 10px rgba(0,0,0,0.05); font-size:.85rem; }
.selected-route-panel .sr-header { display:flex; flex-direction:column; gap:6px; margin-bottom:10px; }
.selected-route-panel .sr-title { margin:0; font-size:1rem; font-weight:600; color:#1f3c88; }
.selected-route-panel .sr-meta { display:flex; flex-wrap:wrap; gap:12px; font-size:.75rem; color:#444; }
.selected-route-panel .sr-departure { margin-top:4px; }

/* Departure semaphore (time to next departure) */
.departure-semaforo { display:inline-flex; align-items:center; gap:6px; padding:6px 14px; border-radius:999px; font-weight:700; font-size:.9rem; letter-spacing:.5px; }
.departure-semaforo .dot { width:10px; height:10px; border-radius:50%; }
.departure-semaforo.ds-level-green { background:#e8f5e9; color:#2e7d32; }
.departure-semaforo.ds-level-green .dot { background:#2e7d32; }
.departure-semaforo.ds-level-amber { background:#fff8e1; color:#f57f17; }
.departure-semaforo.ds-level-amber .dot { background:#f57f17; }
.departure-semaforo.ds-level-red { background:#ffebee; color:#c62828; }
.departure-semaforo.ds-level-red .dot { background:#c62828; }
.departure-semaforo.ds-level-grey { background:#eceff1; color:#455a64; }
.departure-semaforo.ds-level-grey .dot { background:#90a4ae; }

/* Hora elegida badge (comparativa visual) */
#sr-hora-elegida.hora-elegida-badge { display:inline-flex; align-items:center; gap:6px; padding:6px 14px; border-radius:999px; font-weight:700; font-size:.9rem; }
/* Reuse departure-semaforo palette */
#sr-hora-elegida.hora-elegida-badge.ds-level-green { background:#e8f5e9; color:#2e7d32; }
#sr-hora-elegida.hora-elegida-badge.ds-level-amber { background:#fff8e1; color:#f57f17; }
#sr-hora-elegida.hora-elegida-badge.ds-level-red { background:#ffebee; color:#c62828; }
#sr-hora-elegida.hora-elegida-badge.ds-level-grey { background:#eceff1; color:#455a64; }

/* Steps schematic */
.sr-steps { display:flex; flex-direction:column; gap:6px; position:relative; }
.sr-step { display:flex; align-items:flex-start; gap:10px; background:#f7f9fc; border:1px solid #e3e8f1; border-radius:8px; padding:8px 10px; position:relative; }
.sr-step .sr-index { width:22px; height:22px; border-radius:50%; background:#1f3c88; color:#fff; font-size:.7rem; font-weight:600; display:flex; align-items:center; justify-content:center; flex-shrink:0; box-shadow:0 0 0 2px #fff; }
.sr-step .sr-body { flex:1; display:flex; flex-direction:column; gap:2px; }
.sr-step .sr-instruction { font-size:.7rem; line-height:1.2; color:#222; }
.sr-step .sr-extra { font-size:.6rem; color:#555; display:flex; gap:8px; flex-wrap:wrap; }
.sr-step .sr-slope { font-weight:600; }
.sr-step.transit { border-left:4px solid #1976d2; }
.sr-step.walking { border-left:4px solid #43a047; }
.sr-step.driving { border-left:4px solid #ef6c00; }
.sr-step.cycling { border-left:4px solid #7b1fa2; }

@media (min-width: 900px) {
    .sr-steps { max-height:320px; overflow-y:auto; }
}

/* Voice controls */
.mic-btn, .tts-btn {
    margin-left: 8px;
    border: none;
    background: #eef2ff;
    color: #334155;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
}
.mic-btn.active {
    background: #fde68a;
}
.listening-indicator {
    margin-left: 8px;
    color: #b45309;
    font-size: 0.9em;
}