:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --code-bg: #f1f5f9;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px 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 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.legend {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-title {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.legend-item {
    display: inline-block;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

/* Search Section */
.search-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-container label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.search-container select,
.search-container input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
}

.search-container select:focus,
.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-container input:disabled {
    background-color: var(--bg-color);
    cursor: not-allowed;
}

.search-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

.suggestions {
    position: relative;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 10;
}

.suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.suggestion-item:hover {
    background: var(--bg-color);
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* Filter Options */
.filter-options {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 6px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    user-select: none;
}

/* Selection Tools */
.selection-tools {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.tool-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

.tool-btn.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tool-btn.primary:hover {
    background: var(--primary-hover);
}

.tool-btn.active {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.selection-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.tools-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.tools-right {
    display: flex;
    gap: 0.5rem;
}

.view-btn span {
    font-size: 1.2rem;
}

.selected-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Results Section */
.results-container {
    min-height: 200px;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 1.1rem;
}

/* Card View */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* List View */
.view-list .results-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.view-list .stop-card {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1rem;
}

.view-list .stop-card:hover {
    transform: none;
}

.view-list .stop-card-header {
    margin-bottom: 0;
    gap: 1rem;
    flex: 0 0 auto;
}

.view-list .stop-card-checkbox {
    grid-column: 1;
}

.view-list .stop-info-section {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.view-list .stop-name {
    font-size: 1rem;
    margin: 0;
}

.view-list .stop-tpc {
    display: inline-flex;
    margin: 0;
    padding: 0.25rem 0.5rem;
    width: fit-content;
}

.view-list .tpc-label {
    font-size: 0.75rem;
}

.view-list .tpc-code {
    font-size: 0.85rem;
}

.view-list .stop-area {
    display: inline-block;
    margin-left: 0.5rem;
}

.view-list .lines-section {
    grid-column: 3;
    margin: 0;
    min-width: 200px;
}

.view-list .lines-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0;
}

.view-list .line-tag {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
}

.view-list .tpc-actions {
    grid-column: 4;
    margin: 0;
    flex-shrink: 0;
}

.view-list .coordinates {
    display: none;
}

@media (max-width: 1024px) {
    .view-list .stop-card {
        grid-template-columns: auto 1fr auto;
    }
    
    .view-list .lines-section {
        grid-column: 2;
        grid-row: 2;
        margin-top: 0.5rem;
        min-width: unset;
    }
    
    .view-list .tpc-actions {
        grid-column: 3;
        grid-row: 1;
    }
}

@media (max-width: 640px) {
    .view-list .stop-card {
        grid-template-columns: auto 1fr;
        gap: 0.5rem;
    }
    
    .view-list .tpc-actions {
        grid-column: 2;
        grid-row: 3;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }
}

.stop-card {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
    position: relative;
}

.stop-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.stop-card.selected {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.stop-card.pair-highlight {
    background: rgba(16, 185, 129, 0.05);
    border-left: 4px solid var(--success-color);
}

.stop-card.pair-hover {
    border: 3px solid #f97316;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
    z-index: 10;
}

.stop-card-header {
    display: flex;
    align-items: start;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.stop-card-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.stop-info-section {
    flex: 1;
}

.stop-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.stop-area {
    background: var(--code-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    display: inline-block;
    margin-left: 0.5rem;
}

.stop-tpc {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-color);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.tpc-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tpc-code {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    flex: 1;
}

.tpc-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.copy-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.copy-button:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.copy-button:active {
    transform: scale(0.95);
}

.copy-button.copied {
    background: var(--success-color);
}

.copy-button.copied::before {
    content: '✓ ';
}

.link-btn.compact {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.stop-coordinates {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    margin-top: 0.75rem;
}

.stop-coordinates .map-btn {
    display: inline-block;
    text-decoration: none;
    width: 100%;
    text-align: center;
}

.stop-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.meta-tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--code-bg);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.meta-tag.realtime {
    background: #d1fae5;
    color: #065f46;
    font-weight: 500;
}

.stop-lines {
    margin-bottom: 0.75rem;
}

.lines-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.lines-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.line-tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: help;
    transition: transform 0.1s;
}

.line-tag:hover {
    transform: scale(1.1);
}

.line-tag.bus {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.line-tag.tram {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.line-tag.train {
    background: #fce7f3;
    color: #9f1239;
    border: 1px solid #f9a8d4;
}

.line-tag.metro {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.line-tag.ferry {
    background: #cffafe;
    color: #155e75;
    border: 1px solid #67e8f9;
}

.line-tag.boat {
    background: #dbeafe;
    color: #0c4a6e;
    border: 1px solid #7dd3fc;
}

.line-tag.subway {
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #c4b5fd;
}

/* Default for unknown transport types */
.line-tag:not(.bus):not(.tram):not(.train):not(.metro):not(.ferry):not(.boat):not(.subway) {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* Link buttons */
.link-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.75rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.link-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.link-btn.secondary {
    background: #64748b;
}

.link-btn.secondary:hover {
    background: #475569;
}

/* Info Section */
details {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

summary:hover {
    color: var(--primary-color);
}

.info-content {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.info-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.info-content h3:first-child {
    margin-top: 0;
}

.info-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.info-content li {
    margin-bottom: 0.5rem;
}

.info-content code {
    background: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.info-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.info-content a:hover {
    text-decoration: underline;
}

.info-content ul {
    list-style: none;
    margin-left: 0;
}

.info-content ul li {
    padding: 0.5rem 0;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Error State */
.error-message {
    background: #fef2f2;
    border: 2px solid #ef4444;
    color: #991b1b;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.error-message strong {
    display: block;
    margin-bottom: 0.5rem;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    header .subtitle {
        font-size: 1rem;
    }

    section {
        padding: 1.5rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
