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

body {
    font-family: Arial, sans-serif;
    background-color: #e8f5e9;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
header {
    background-color: #1565c0;
    color: white;
    text-align: center;
    padding: 24px 20px 16px;
}

header h1 {
    font-size: 2.2em;
}

header h1 a {
    color: white;
    text-decoration: none;
}

header p {
    font-size: 1.1em;
    margin-top: 6px;
    opacity: 0.9;
}

.train-banner {
    font-size: 1.8em;
    margin-top: 10px;
    letter-spacing: 5px;
}

nav {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

nav a {
    color: white;
    text-decoration: none;
    background: rgba(255,255,255,0.15);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 1em;
    transition: background 0.2s;
}

nav a:hover {
    background: rgba(255,255,255,0.3);
}

/* --- Main --- */
main {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

/* --- Flash messages --- */
.flash {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 1em;
}

.flash-success {
    background: #c8e6c9;
    color: #2e7d32;
}

.flash-error {
    background: #ffcdd2;
    color: #c62828;
}

/* --- Search bar --- */
.search-section {
    text-align: center;
    margin-bottom: 28px;
}

.search-section h2 {
    color: #1565c0;
    font-size: 1.6em;
    margin-bottom: 14px;
}

.search-box {
    display: flex;
    max-width: 500px;
    margin: 0 auto;
}

.search-box input {
    flex: 1;
    padding: 14px 18px;
    font-size: 1.1em;
    border: 3px solid #1565c0;
    border-radius: 12px 0 0 12px;
    outline: none;
}

.search-box input:focus {
    border-color: #ffc107;
}

.search-box button {
    padding: 14px 22px;
    font-size: 1.2em;
    background: #1565c0;
    color: white;
    border: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
}

.search-box button:hover {
    background: #0d47a1;
}

.search-stats {
    margin-top: 10px;
    color: #666;
    font-size: 0.95em;
}

/* --- Map card grid --- */
.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.map-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.map-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.map-card-thumb {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #e3f2fd;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-card-thumb img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.map-card-thumb .placeholder {
    font-size: 4em;
    color: #90caf9;
}

.map-card-body {
    padding: 16px;
}

.map-card-body h3 {
    color: #1565c0;
    font-size: 1.15em;
    margin-bottom: 4px;
}

.map-card-city {
    color: #666;
    font-size: 0.95em;
    margin-bottom: 8px;
}

.map-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- System type badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
    color: white;
}

.badge-metro { background: #1565c0; }
.badge-tram { background: #2e7d32; }
.badge-commuter_rail { background: #e65100; }
.badge-bus { background: #c62828; }
.badge-other { background: #6a1b9a; }

.country-flag {
    font-size: 1.3em;
}

/* --- Browse page --- */
.breadcrumb {
    background: white;
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    font-size: 1em;
}

.breadcrumb a {
    color: #1565c0;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    margin: 0 6px;
    color: #999;
}

.browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.browse-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.browse-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.browse-card .emoji {
    font-size: 3em;
    display: block;
    margin-bottom: 10px;
}

.browse-card h3 {
    color: #1565c0;
    font-size: 1.2em;
}

.browse-card .count {
    color: #888;
    font-size: 0.9em;
    margin-top: 4px;
}

/* --- Map detail page --- */
.map-detail {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.map-detail h2 {
    color: #1565c0;
    font-size: 1.8em;
    margin-bottom: 6px;
    border-bottom: 3px solid #ffc107;
    padding-bottom: 10px;
}

.map-detail-meta {
    color: #666;
    margin-bottom: 16px;
    font-size: 1.05em;
}

.map-detail-thumb {
    margin: 20px 0;
    text-align: center;
}

.map-detail-thumb img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.map-detail-desc {
    font-size: 1.1em;
    line-height: 1.7;
    margin-bottom: 20px;
}

.map-detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 14px 28px;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 10px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    text-align: center;
    min-width: 48px;
    min-height: 48px;
}

.btn-primary {
    background: #1565c0;
    color: white;
}

.btn-primary:hover {
    background: #0d47a1;
}

.btn-secondary {
    background: #ffc107;
    color: #333;
}

.btn-secondary:hover {
    background: #ffb300;
}

.btn-danger {
    background: #c62828;
    color: white;
}

.btn-danger:hover {
    background: #b71c1c;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
    border-radius: 6px;
}

/* --- Admin --- */
.admin-form {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 0 auto;
}

.admin-form h2 {
    color: #1565c0;
    margin-bottom: 20px;
    border-bottom: 3px solid #ffc107;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    border: 2px solid #ccc;
    border-radius: 8px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #1565c0;
}

.form-group textarea {
    height: 100px;
    resize: vertical;
}

/* Admin dashboard table */
.admin-table-wrap {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.admin-table-wrap h2 {
    color: #1565c0;
    margin-bottom: 16px;
    border-bottom: 3px solid #ffc107;
    padding-bottom: 10px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.admin-table th {
    background: #e3f2fd;
    color: #1565c0;
    font-size: 0.9em;
}

.admin-table tr:hover {
    background: #f5f5f5;
}

/* --- No results --- */
.no-results {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 1.2em;
}

.no-results .emoji {
    font-size: 3em;
    display: block;
    margin-bottom: 12px;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 20px;
    background-color: #1565c0;
    color: white;
    margin-top: 30px;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.6em;
    }

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

    .browse-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .map-detail-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
