:root {
    --primary: hsl(24, 95%, 53%);
    --primary-light: hsl(24, 95%, 96%);
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    min-height: 100vh;
    background: var(--bg-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    padding: 0;
    line-height: 1.5;
}

.widget-wrapper {
    width: 100%;
    background: var(--card-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* SEARCH SECTION */
.search-section {
    display: flex;
    flex-direction: column;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 20;
}

.search-icon {
    width: 20px !important;
    height: 20px !important;
    color: #94a3b8;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    padding: 0 4px;
}

.search-box input::placeholder {
    color: #cbd5e1;
}

.search-clear {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-clear.visible {
    display: flex;
}

.search-clear:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.search-results {
    flex: 1;
    overflow-y: auto;
}

.search-status {
    padding: 60px 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.stop-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.stop-item:hover {
    background: #fdfdfd;
}

.stop-item-icon {
    width: 18px !important;
    height: 18px !important;
    color: #3b82f6;
    /* More elegant blue */
    flex-shrink: 0;
}

.stop-item-name {
    flex: 1;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
    /* Match the elegant look */
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.stop-item-count {
    font-size: 0.75rem;
    color: #94a3b8;
    background: transparent;
    padding: 0;
    margin-right: 12px;
}

.stop-item-arrow {
    width: 16px !important;
    height: 16px !important;
    color: #cbd5e1;
    flex-shrink: 0;
}

/* DEPARTURES SECTION */
.departures-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 20;
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.back-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.back-btn:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

.stop-info {
    flex: 1;
    min-width: 0;
}

.stop-info h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.stop-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: background 0.5s;
    position: relative;
}

.status-dot.online::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.3;
    animation: ripple 2s infinite;
}

.status-dot.online {
    background: #22c55e;
}

.status-dot.loading {
    background: var(--primary);
    animation: pulse 0.8s infinite alternate;
}

@keyframes ripple {
    from {
        transform: scale(1);
        opacity: 0.4;
    }

    to {
        transform: scale(2.5);
        opacity: 0;
    }
}

#bus-widget {
    flex: 1;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 20px;
    background: #f8fafc;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.line-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 30px;
    /* Changed from fixed height */
    padding: 4px 8px;
    /* Added padding */
    font-weight: 800;
    font-size: 0.85rem;
    /* Slightly smaller for long text */
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: normal;
    /* Allow wrapping */
    line-height: 1.2;
    text-align: center;
    max-width: 110px;
    /* Prevent it from getting too wide */
}

.direction {
    font-size: 0.95rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 2px;
    display: block;
}

.platform {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

.time {
    text-align: right;
    font-weight: 900;
    color: var(--primary);
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}

.time.urgent {
    color: #ef4444;
}

.time.at-stop {
    color: #10b981;
    font-size: 0.85rem;
}

.trip-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: #94a3b8;
    cursor: pointer;
    margin-left: 12px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.trip-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.widget-footer {
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 500;
}

/* TRIP SECTION (Thermometer) */
.trip-stop {
    display: flex;
    align-items: stretch;
    /* Changed from center to stretch for continuous line */
    padding: 0 20px;
    min-height: 48px;
}

.trip-stop-dot {
    position: relative;
    width: 40px;
    min-width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.trip-stop-time {
    width: 50px;
    text-align: right;
    font-weight: 700;
    color: #64748b;
    font-size: 0.85rem;
}

.trip-stop.selected .trip-stop-time {
    color: var(--primary);
}

.trip-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e2e8f0;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px #e2e8f0;
    z-index: 2;
    transition: all 0.3s;
}

.trip-dot.selected {
    width: 16px;
    height: 16px;
    background: var(--primary);
    box-shadow: 0 0 0 2px var(--primary), 0 0 12px rgba(249, 115, 22, 0.4);
}

.trip-line {
    width: 4px;
    background: #e2e8f0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    bottom: 0;
    z-index: 1;
}

.trip-line.no-top {
    top: 50%;
}

.trip-line.no-bottom {
    bottom: 50%;
}

.trip-stop.prev .trip-line,
.trip-stop.selected .trip-line {
    background: #cbd5e1;
}

.trip-stop-name {
    flex: 1;
    padding: 12px 0 12px 16px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #475569;
}

.trip-stop.selected .trip-stop-name {
    font-weight: 700;
    color: var(--text-main);
}