/* =========================================================
   GRUNDLAGEN
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f4f6f8;
    color: #222;
}

/* =========================================================
   HEADER
   ========================================================= */

.header {
    background: #111827;
    color: white;
    padding: 28px 20px;
}

.header-inner {
    max-width: 1400px;
    margin: auto;
}

.header h1 {
    margin: 0 0 6px;
    font-size: 30px;
}

.header p {
    margin: 0;
    color: #cbd5e1;
}

/* =========================================================
   CONTAINER
   ========================================================= */

.container {
    max-width: 1400px;
    margin: auto;
    padding: 25px 20px 50px;
}

/* =========================================================
   SECTIONS
   ========================================================= */

.map-section,
.tour-section {
    background: white;
    border-radius: 14px;
    margin-bottom: 25px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

/* =========================================================
   SECTION TITLE
   ========================================================= */

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.section-title h2 {
    margin: 0 0 4px;
}

.section-title p {
    margin: 0;
    color: #6b7280;
}

/* =========================================================
   MAP BUTTONS
   ========================================================= */

.map-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =========================================================
   BUTTON
   ========================================================= */

.button {
    border: none;
    background: #2563eb;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 44px;
    line-height: 1.2;
}

.button:hover {
    background: #1d4ed8;
}

.button:active {
    transform: scale(0.98);
}

.button-secondary {
    background: #e5e7eb;
    color: #374151;
}

.button-secondary:hover {
    background: #d1d5db;
}

/* =========================================================
   MAP
   ========================================================= */

#map {
    width: 100%;
    height: 650px;
    border-radius: 10px;
    overflow: hidden;
}

.map-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 13px;
}

/* =========================================================
   YEAR GROUP
   ========================================================= */

.year-group {
    margin-bottom: 30px;
}

.year-group:last-child {
    margin-bottom: 0;
}

/* =========================================================
   YEAR HEADER
   ========================================================= */

.year-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.year-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-wrap: wrap;
}

.year-heading h3 {
    margin: 0;
    font-size: 24px;
}

.year-heading span {
    color: #6b7280;
    font-size: 13px;
}

.year-distance {
    color: #6b7280;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.year-toggle-button {
    flex-shrink: 0;
    white-space: nowrap;
}

/* =========================================================
   TOUR GRID
   ========================================================= */

.tour-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 15px;
    /* Wichtig: Verhindert Überlauf */
    overflow: hidden;
    width: 100%;
}

/* =========================================================
   TOUR CARD
   ========================================================= */

.tour-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fafafa;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
    /* Wichtig: Verhindert Überlauf */
    max-width: 100%;
    overflow: hidden;
}

.tour-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.tour-card.active {
    background: #eff6ff;
    border-color: #93c5fd;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.10);
}

/* =========================================================
   TOUR ICON
   ========================================================= */

.tour-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    border-radius: 10px;
    font-size: 24px;
}

.tour-card.active .tour-icon {
    background: #dbeafe;
}

/* =========================================================
   TOUR INFO
   ========================================================= */

.tour-info {
    flex: 1;
    min-width: 0;
    /* Wichtig: Verhindert Überlauf bei langen Texten */
    overflow: hidden;
}

.tour-info h3 {
    margin: 0 0 6px;
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tour-meta {
    font-size: 12px;
    color: #2563eb;
    font-weight: 700;
}

.tour-distance {
    margin-top: 4px;
    font-size: 13px;
    color: #374151;
    font-weight: 600;
}

.filename {
    margin: 5px 0 0;
    font-size: 12px;
    color: #9ca3af;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================
   TOUR ACTIONS
   ========================================================= */

.tour-actions {
    flex-shrink: 0;
}

.tour-button {
    white-space: nowrap;
    min-width: 120px;
}

.show-text {
    display: inline;
}

.hide-text {
    display: none;
}

.tour-card.active .show-text {
    display: none;
}

.tour-card.active .hide-text {
    display: inline;
}

/* =========================================================
   EMPTY STATE
   ========================================================= */

.empty {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.empty-icon {
    font-size: 50px;
    margin-bottom: 15px;
}

.empty h3 {
    color: #374151;
}

/* =========================================================
   FOOTER
   ========================================================= */

.footer {
    text-align: center;
    padding: 30px 20px;
    color: #6b7280;
    font-size: 13px;
}

.footer a {
    color: #2563eb;
    text-decoration: none;
}

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

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {
    .header h1 {
        font-size: 24px;
    }

    .container {
        padding: 12px;
    }

    .map-section,
    .tour-section {
        padding: 12px;
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .map-buttons {
        width: 100%;
    }

    .map-buttons .button {
        flex: 1;
        font-size: 13px;
        padding: 10px 12px;
    }

    #map {
        height: 500px;
    }

    .tour-grid {
        grid-template-columns: 1fr;
        /* Einspaltig auf mobile */
        gap: 12px;
    }

    .tour-card {
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 14px;
        /* Wichtig: Kein Überlauf */
        max-width: 100%;
        width: 100%;
    }

    .tour-info {
        flex: 1 1 calc(100% - 62px);
        min-width: 0;
        /* Wichtig: Verhindert Überlauf */
        overflow: hidden;
    }

    .tour-actions {
        flex: 1 1 100%;
        margin-top: 10px;
        margin-left: 0;
    }

    .tour-button {
        width: 100%;
        min-width: unset;
        padding: 12px 10px;
        font-size: 14px;
        justify-content: center;
    }

    .year-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .year-heading {
        width: 100%;
        flex-wrap: wrap;
    }

    .year-heading h3 {
        font-size: 21px;
    }

    .year-toggle-button {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .year-distance {
        white-space: normal;
        /* Ermöglicht Umbruch bei langen Texten */
    }

    .tour-icon {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        font-size: 20px;
    }

    .tour-info h3 {
        font-size: 15px;
    }
}

/* =========================================================
   KLEINE MOBILE (unter 400px)
   ========================================================= */

@media (max-width: 400px) {
    .header h1 {
        font-size: 20px;
    }

    .container {
        padding: 8px;
    }

    .map-section,
    .tour-section {
        padding: 10px;
    }

    .tour-grid {
        gap: 10px;
    }

    .tour-card {
        padding: 12px;
        gap: 10px;
    }

    .tour-button {
        font-size: 13px;
        padding: 10px 8px;
    }

    .year-heading h3 {
        font-size: 18px;
    }

    .year-heading span {
        font-size: 12px;
    }

    .year-distance {
        font-size: 12px;
    }
}