/* Variables for themes */
:root {
    --background-color: #ffffff;
    --text-color: #444444;
    --list-item-background: #f8f9fa;
    --realtime-indicator: #10b981;
    --static-indicator: #ef4444;
    --bus-countdown-color: #888;
}

:root[data-theme='dark'] {
    --background-color: #000000;
    --text-color: #dddddd;
    --list-item-background: #1e1e1e;
    --realtime-indicator: #34d399;
    --static-indicator: #f87171;
    --bus-countdown-color: #9ca3af;
}

body {
    font-family: 'Roboto', sans-serif;
    font-size: 1.1em; /* Reduced base font size */
    margin: 0;
    padding: 20px;
    background-color: var(--background-color);
    color: var(--text-color);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    height: 60px;
    margin-bottom: 20px;
}

header h1 {
    text-align: center;
    margin: 0;
}

.github-link {
    color: var(--text-color);
    font-size: 1.5em;
    text-decoration: none;
    display: flex;
    align-items: center;
    height: 40px;
    padding-inline-end: 6px;
    padding-inline-start: 6px;
}

.github-link:hover {
    opacity: 0.8;
}

.logo {
    height: 50px;
    width: auto;
    margin: 1rem;
}

#input-form {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

#stop-form {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

#stop-form input[type="text"] {
    flex: 1;
    width: calc(100% - 60px);
    padding: 15px;
    font-size: 1.2em;
    border: 2px solid #ccc;
    border-radius: 5px;
    color: var(--text-color);
    background-color: var(--background-color);
}

#search-button {
    background: none;
    border: 2px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-color);
    font-size: 1.2em;
    height: 58px;
    width: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#search-button:hover {
    opacity: 0.8;
}

#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    font-size: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
}

#theme-toggle:hover {
    opacity: 0.8;
}

#bus-times {
    max-width: 600px;
    margin: 25px auto;
}

#bus-times ul {
    list-style-type: none;
    padding: 0;
}

#bus-times li.bus-item {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--list-item-background);
    margin: 5px 0;
    padding: 10px; /* Reduced padding for better compactness */
    border-radius: 10px;
    font-size: 1em; /* Reduced font size */
    justify-content: space-between;
}

.status-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.status-indicator:hover {
    transform: scale(1.5);
}

.status-indicator::before {
    content: attr(title);
    position: absolute;
    top: -30px;
    right: -5px;
    background: var(--background-color);
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.status-indicator:hover::before {
    opacity: 1;
    visibility: visible;
}

.status-indicator.realtime {
    background-color: var(--realtime-indicator);
    box-shadow: 0 0 4px var(--realtime-indicator);
}

.status-indicator.static {
    background-color: var(--static-indicator);
    box-shadow: 0 0 4px var(--static-indicator);
}

.route-number {
    font-size: 1.2em; /* Adjusted font size */
    font-weight: bold;
    border: 2px solid var(--text-color);
    border-radius: 8px;
    padding: 0; /* Removed extra padding */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    text-align: center;
}

.bus-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    margin-left: 10px; /* Adjusted for spacing */
    overflow: hidden;
    white-space: nowrap;
}

.bus-stop {
    font-size: 1.1em; /* Slightly reduced */
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.bus-countdown {
    font-size: 0.85em; /* Slightly reduced */
    color: var(--bus-countdown-color);
}

.arrival-time {
    font-size: 1em; /* Adjusted to match */
    font-weight: bold;
    text-align: right;
    flex-shrink: 0;
    padding-left: 15px; /* Reduced padding for compact look */
    align-self: center;
    min-width: 80px;
}

.error {
    color: red;
    text-align: center;
}

h2 {
    text-align: center;
    font-size: 1.3em; /* Adjusted for smaller base font size */
}

/* Autocomplete styles */
.input-container {
    display: flex;
    gap: 0;
}

.awesomplete {
    flex: 1;
    gap: 0;
}

.awesomplete > ul {
    background: var(--background-color);
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    color: var(--text-color);
}

.awesomplete > ul > li {
    color: var(--text-color);
    padding: 10px;
}

.awesomplete > ul > li:hover,
.awesomplete > ul > li[aria-selected="true"] {
    background-color: #2196F3;
    color: white;
}

input[type="text"] {
    border-right: none;
    padding-right: 0;
}

button[type="submit"] {
    border-left: none;
    margin-left: 0;
}

/* Dark mode specific styles */
:root[data-theme='dark'] .awesomplete > ul {
    background: var(--background-color);
    border-color: #444;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

:root[data-theme='dark'] .awesomplete > ul > li:hover,
:root[data-theme='dark'] .awesomplete > ul > li[aria-selected="true"] {
    background-color: #2196F3;
    color: white;
}

.awesomplete mark {
    background: #FFC107;
    color: black;
    padding: 0 2px;
    border-radius: 2px;
}

:root[data-theme='dark'] .awesomplete mark {
    background: #FFC107;
    color: black;
}

/* Full-screen adjustments */
@media (min-width: 600px) {
    #bus-times li.bus-item {
        padding: 10px 20px 10px 10px;
    }

    .route-number {
        width: 50px;
        height: 50px;
    }

    .bus-details {
        margin-left: 10px;
    }

    .bus-stop {
        font-size: 1em;
    }

    .bus-countdown {
        font-size: 0.85em;
    }

    .arrival-time {
        font-size: 1em;
        padding-left: 15px;
    }
}

/* Mobile responsive adjustments */
@media (max-width: 600px) {
    body {
        padding: 10px;
        font-size: 1.2em;
    }

    header {
        padding: 0 5px;
        height: 50px;
        margin-bottom: 10px;
    }

    header h1 {
        font-size: 1.5em;
        margin: 0;
    }

    .github-link {
        font-size: 1.2em;
        color: var(--text-color) !important;
        height: 35px;
    }

    #theme-toggle {
        font-size: 1.2em;
        padding: 6px;
        height: 35px;
    }

    #stop-form input[type="text"] {
        font-size: 16px;
        padding: 12px;
    }

    #search-button {
        padding: 12px;
        height: 46px;
        width: 46px;
        font-size: 1.2em;
    }

    #bus-times li.bus-item {
        padding: 12px;
        font-size: 1em;
    }

    .status-indicator {
        width: 6px;
        height: 6px;
        top: 6px;
        right: 6px;
    }

    .status-indicator::before {
        font-size: 0.7em;
        top: -25px;
        right: -10px;
        padding: 3px 6px;
    }

    .route-number {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
        padding: 8px;
    }

    .bus-stop {
        font-size: 0.9em;
    }

    .bus-countdown {
        font-size: 0.8em;
    }

    .arrival-time {
        font-size: 1em;
        padding-left: 8px;
    }
}
