/* Sidebar toggle */

.sidebar-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 22000;

    width: 48px;
    height: 48px;

    border: 1px solid var(--glass-border);
    border-radius: 16px;

    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.18),
            rgba(255, 255, 255, 0.04)
        ),
        var(--glass-bg);

    color: var(--text-main);
    backdrop-filter: var(--glass-blur-soft);
    -webkit-backdrop-filter: var(--glass-blur-soft);

    font-size: 24px;
    font-weight: 900;
    line-height: 1;

    cursor: pointer;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(30, 41, 59, 0.96);
    transform: translateY(-1px);
}

.sidebar-toggle.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-12px);
}

/* Sidebar layout */

.sidebar,
.sidebar * {
    box-sizing: border-box;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 21000;

    background: rgba(2, 6, 23, 0.42);
    backdrop-filter: blur(2px);

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 23000;

    width: 310px;
    max-width: calc(100vw - 34px);
    padding: 18px;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border-right: 1px solid var(--glass-border);
    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.2),
            rgba(255, 255, 255, 0.05)
        ),
        var(--glass-bg-strong);

    color: var(--text-main);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);

    box-shadow: 24px 0 70px rgba(0, 0, 0, 0.55);

    transform: translateX(-105%);
    transition: transform 0.28s ease;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    flex-shrink: 0;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;

    margin-bottom: 10px;
    padding: 8px 4px 20px;
}

.sidebar-kicker {
    margin-bottom: 4px;

    color: var(--accent);

    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar-header h2 {
    margin: 0;

    font-size: 28px;
    font-weight: 1000;
    letter-spacing: -0.04em;
}

.sidebar-close {
    width: 38px;
    height: 38px;

    border: none;
    border-radius: 999px;

    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);

    font-size: 28px;
    line-height: 1;

    cursor: pointer;
    transition: background 0.2s ease;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Scrollable content */

.sidebar-content {
    position: relative;

    flex: 1;
    min-height: 0;

    overflow-x: hidden;
    overflow-y: auto;

    padding-bottom: 18px;

    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-content::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* Sidebar nav */

.sidebar-nav {
    display: grid;
    gap: 8px;
    min-width: 0;
    padding-right: 4px;
}

.sidebar-item {
    width: auto;
    min-width: 0;
    min-height: 76px;
    padding: 0 16px;
    margin: 0;

    display: flex;
    align-items: center;
    gap: 12px;

    border: none;
    border-radius: 18px;

    background: rgba(255, 255, 255, 0.035);
    color: var(--text-soft);
    outline: 1px solid rgba(255, 255, 255, 0.035);
    outline-offset: -1px;

    font-size: 16px;
    font-weight: 900;
    text-align: left;

    cursor: pointer;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        outline-color 0.18s ease,
        transform 0.18s ease;
}

.sidebar-item:hover,
.sidebar-item.active {
    background: rgba(255, 255, 255, 0.065);
    color: var(--text-main);
    outline-color: rgba(255, 255, 255, 0.11);
    transform: translateX(4px);
}

.sidebar-item-emoji {
    width: 30px;
    height: 30px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);

    font-size: 16px;
}

.sidebar-chevron {
    margin-left: auto;

    font-size: 18px;
    color: var(--text-muted);

    transition: transform 0.2s ease, color 0.2s ease;
}

.sidebar-chevron.open {
    transform: rotate(180deg);
    color: var(--text-main);
}

/* Static footer */

.sidebar-footer {
    position: relative;
    flex-shrink: 0;

    display: grid;
    gap: 8px;

    margin-top: 0;
    padding-top: 20px;
}

.sidebar-footer::before {
    content: "";

    position: absolute;
    left: -18px;
    right: -18px;
    top: -34px;

    height: 34px;

    pointer-events: none;
    opacity: 0;

    background: linear-gradient(
        to bottom,
        rgba(31, 37, 52, 0),
        rgba(31, 37, 52, 0.32),
        rgba(31, 37, 52, 0.92)
    );

    transition: opacity 0.18s ease;
}

.sidebar.has-footer-fade .sidebar-footer::before {
    opacity: 1;
}

.sidebar-footer::after {
    content: "";

    position: absolute;
    left: -18px;
    right: -18px;
    top: 0;

    height: 1px;

    pointer-events: none;

    background: rgba(255, 255, 255, 0.12);
}

.sidebar-settings {
    color: var(--text-soft);
}

.sidebar-about {
    color: var(--text-muted);
}

/* Shared panels */

.nearby-panel,
.favorites-panel {
    display: none;

    width: 100%;
    min-width: 0;
    margin-top: 4px;
    padding-top: 14px;

    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nearby-panel.open,
.favorites-panel.open {
    display: block;
}

.nearby-panel-header,
.favorites-panel-header {
    margin-bottom: 12px;
}

.nearby-panel-header h3,
.favorites-panel-header h3 {
    margin: 0 0 3px;

    font-size: 18px;
    color: rgba(255, 255, 255, 0.95);
}

.nearby-panel-header span,
.favorites-panel-header span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
}

/* Nearby */

.nearby-list {
    display: flex;
    flex-direction: column;
    gap: 12px;

    width: 100%;
    min-width: 0;
}

.nearby-empty,
.favorites-empty,
.favorites-loading,
.favorite-empty {
    padding: 14px;

    border-radius: 16px;

    color: rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.06);

    font-size: 13px;
}

.nearby-card-header {
    align-items: flex-start;
}

.nearby-distance {
    flex-shrink: 0;

    padding: 6px 8px;

    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
    color: rgba(255, 255, 255, 0.78);

    font-size: 12px;
    font-weight: 900;
}

/* Favorites */

.favorites-list-wrapper,
.favorites-list,
.favorite-card {
    width: 100%;
    min-width: 0;
}

.favorites-list-wrapper {
    position: relative;
}

.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 12px;

    padding-right: 0;

    overflow: visible;

    scrollbar-width: none;
    -ms-overflow-style: none;
}

.favorites-list::-webkit-scrollbar {
    display: none;
}

.favorites-list.has-fade {
    mask-image: none;
    -webkit-mask-image: none;
}

.favorite-card {
    overflow: hidden;
    padding: 12px;

    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;

    background: rgba(255, 255, 255, 0.07);
    cursor: pointer;
    outline: 1px solid transparent;
    outline-offset: -1px;

    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        outline-color 0.18s ease,
        transform 0.18s ease;
}

.favorite-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.1);
    outline-color: rgba(255, 255, 255, 0.11);
    transform: translateX(4px);
}

.favorite-card-header,
.favorite-departure-main {
    min-width: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.favorite-card-header {
    margin-bottom: 10px;
}

.favorite-open {
    flex: 1;
    min-width: 0;
    padding: 0;

    display: flex;
    align-items: center;
    gap: 8px;

    border: none;
    background: transparent;
    color: white;

    font-family: inherit;
    font-weight: 800;
    text-align: left;

    cursor: pointer;
}

.favorite-station-name,
.favorite-departure-direction {
    min-width: 0;
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.favorite-remove {
    flex-shrink: 0;

    width: 26px;
    height: 26px;

    border: none;
    border-radius: 999px;

    background: rgba(255, 255, 255, 0.08);
    color: white;

    font-family: inherit;
    font-size: 18px;
    line-height: 1;

    cursor: pointer;
}

.favorite-remove:hover {
    background: rgba(255, 255, 255, 0.16);
}

.favorite-departures {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.favorite-departure {
    padding: 8px;

    border-radius: 12px;
    background: rgba(0, 0, 0, 0.18);
}

.favorite-departure-line {
    flex: 1;
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 8px;
}

.favorite-departure-direction {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.62);
}

.favorite-departure-time-group {
    flex-shrink: 0;

    display: flex;
    align-items: baseline;
    gap: 5px;
}

.favorite-departure-time {
    font-size: 13px;
    font-weight: 800;
    color: white;
}

.favorite-departure-delay {
    font-size: 11px;
    font-weight: 800;
    color: #fb7185;
}

/* Station popup favorite button */

.station-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.station-favorite-button {
    width: 34px;
    height: 34px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid rgba(250, 204, 21, 0.35);
    border-radius: 999px;

    background: rgba(250, 204, 21, 0.12);
    color: #facc15;

    font-size: 21px;
    line-height: 1;

    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.station-favorite-button:hover {
    border-color: rgba(250, 204, 21, 0.65);
    background: rgba(250, 204, 21, 0.2);
    transform: scale(1.05);
}

/* Mobile */

@media (max-width: 600px) {
    .sidebar-toggle {
        top: 12px;
        left: 12px;
    }

    .sidebar {
        width: 290px;
    }
}
