/* ============================================================
   training-modern.css
   ============================================================ */

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #f1f5f9;
    color: #1e293b;
    min-height: 100vh;
}

/* === Auth Layout (Login / Register) === */
body.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-box {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 40px;
    width: min(100%, 440px);
}

.auth-box h1 {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    color: #1e293b;
}

.auth-box .auth-sub {
    color: #64748b;
    margin: 0 0 28px 0;
    font-size: 0.9rem;
}

/* === Navigation === */
.main-nav {
    background: #1e293b;
    padding: 0 24px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-wrap: wrap;
}

.nav-brand {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    padding: 0 20px 0 0;
    margin-right: 8px;
    border-right: 1px solid #334155;
    line-height: 52px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.nav-links {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
}

.nav-link {
    color: #94a3b8;
    text-decoration: none;
    padding: 0 14px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 52px;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

.nav-link:hover {
    color: #fff;
    background: #334155;
}

.nav-link.active {
    color: #fff;
    border-bottom-color: #1d4ed8;
}

.nav-user {
    margin-left: auto;
    color: #64748b;
    font-size: 0.825rem;
    line-height: 52px;
    padding-left: 14px;
    white-space: nowrap;
}

.nav-user a {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.15s;
}

.nav-user a:hover {
    color: #fff;
}

/* === Page Layout === */
.page-main {
    padding: 32px 16px 48px;
}

.container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
    padding: 32px;
    width: min(92%, 740px);
    margin: 0 auto;
}

.container.wide {
    width: min(96%, 1100px);
}

.container.stretch {
    width: 80%;
    max-width: 2400px;
}

h1 {
    margin-top: 0;
    color: #1e293b;
    font-size: 1.55rem;
    font-weight: 700;
}

h2 {
    color: #1e293b;
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 2rem;
}

h3 {
    color: #334155;
    font-size: 1rem;
    font-weight: 600;
}

/* === Buttons === */
.button,
button[type="submit"] {
    display: inline-block;
    padding: 9px 18px;
    background-color: #1d4ed8;
    color: #fff;
    text-decoration: none;
    border: none;
    border-radius: 7px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1.4;
}

.button:hover,
button[type="submit"]:hover {
    background-color: #1e40af;
}

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

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

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* === Forms === */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    max-width: 440px;
    padding: 9px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 7px;
    font-size: 0.925rem;
    font-family: inherit;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

input[readonly] {
    background: #f8fafc;
    color: #64748b;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    margin-top: 24px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px;
    margin: 24px 0;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
}

.stat-card h3 {
    margin: 0 0 8px 0;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-card p {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
    color: #1d4ed8;
}

/* === Tables === */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 11px 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    white-space: nowrap;
    position: relative;
}

/* === Resizable columns === */
.resizable-table {
    table-layout: fixed;
    width: max-content;
    min-width: 100%;
}

.resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    user-select: none;
    z-index: 1;
}

.resize-handle:hover {
    background: linear-gradient(to right, transparent 2px, #1d4ed8 2px, #1d4ed8 4px, transparent 4px);
}

.resize-handle.is-resizing {
    background: linear-gradient(to right, transparent 2px, #1d4ed8 2px, #1d4ed8 4px, transparent 4px);
}

/* === Column toggle controls === */
.col-controls {
    display: flex;
    align-items: center;
    gap: 6px 14px;
    flex-wrap: wrap;
    margin: 14px 0 4px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.8rem;
}

.col-controls-label {
    font-weight: 600;
    color: #475569;
    margin-right: 4px;
    white-space: nowrap;
}

.col-toggle-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: #475569;
    user-select: none;
}

.col-toggle-item input[type="checkbox"] {
    accent-color: #1d4ed8;
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.col-controls-sep {
    width: 1px;
    height: 16px;
    background: #e2e8f0;
    margin: 0 4px;
}

.width-presets {
    display: flex;
    gap: 4px;
}

.width-presets button {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    color: #475569;
    font-size: 0.78rem;
    padding: 2px 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.width-presets button:hover {
    border-color: #1d4ed8;
    color: #1d4ed8;
}

.width-presets button.active {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #1e293b;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

small {
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.4;
}

/* === Action links in tables === */
.actions-cell {
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.actions-cell a,
.action-link-button {
    display: block;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: #1d4ed8;
    text-decoration: none;
    font: inherit;
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
}

.actions-cell a:hover,
.action-link-button:hover {
    color: #dc2626;
    text-decoration: underline;
    background: none;
}

.action-link-danger {
    color: #dc2626;
}

.inline-form {
    display: inline;
    margin: 0 6px 0 0;
}

/* === Range inputs in quick-edit table === */
input[type="range"] {
    accent-color: #1d4ed8;
    vertical-align: middle;
    width: 90px;
}

.range-value {
    display: inline-block;
    min-width: 18px;
    margin-left: 4px;
    font-weight: 600;
    color: #1d4ed8;
    font-size: 0.825rem;
}

select[form] {
    max-width: 140px;
    padding: 5px 8px;
    font-size: 0.825rem;
}

input[type="range"][form] {
    width: 90px;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-green {
    background: #dcfce7;
    color: #166534;
}

.badge-red {
    background: #fee2e2;
    color: #991b1b;
}

.badge-gray {
    background: #f1f5f9;
    color: #475569;
}

.badge-blue {
    background: #dbeafe;
    color: #1e40af;
}

/* === Chart === */
.chart-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.chart-range-btn {
    padding: 6px 14px;
    background: #f1f5f9;
    color: #475569;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.825rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit;
}

.chart-range-btn:hover {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
}

.chart-range-btn.active {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
}

.chart-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin: 0 0 32px 0;
    height: 380px;
}

.chart-card canvas {
    width: 100% !important;
    height: 100% !important;
}

/* === Wiki === */
.wiki-intro {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.wiki-toc {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 20px;
}

.wiki-note {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 14px 18px;
    margin: 20px 0;
}

.wiki-section {
    margin-top: 32px;
    text-align: left;
}

.wiki-section h2 {
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 16px;
}

.wiki-section h3 {
    margin-top: 28px;
    margin-bottom: 8px;
    color: #1d4ed8;
}

.wiki-section p,
.wiki-section li {
    line-height: 1.7;
    color: #334155;
}

.wiki-section ul {
    padding-left: 22px;
}

.wiki-section code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 5px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.88em;
    color: #1d4ed8;
}

.wiki-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.faq-item {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f1f5f9;
}

.faq-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.muted {
    color: #64748b;
}

/* === Changelog === */
.changelog-entry {
    margin-top: 36px;
    padding-bottom: 32px;
    border-bottom: 2px solid #e2e8f0;
}

.changelog-entry:last-child {
    border-bottom: none;
}

.changelog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.changelog-meta {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.changelog-version {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1d4ed8;
    font-family: 'Consolas', 'Monaco', monospace;
}

.changelog-date {
    font-size: 0.875rem;
    color: #64748b;
}

.changelog-badges {
    display: flex;
    gap: 6px;
}

.changelog-title {
    margin: 4px 0 8px 0;
    font-size: 1.1rem;
    color: #1e293b;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.changelog-summary {
    color: #475569;
    margin-bottom: 20px;
    line-height: 1.65;
}

.changelog-fixes {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.changelog-fix {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #1d4ed8;
    border-radius: 8px;
    padding: 14px 16px;
}

.changelog-fix-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.changelog-fix-header strong {
    color: #1e293b;
    font-size: 0.95rem;
}

.changelog-fix p {
    margin: 0 0 10px 0;
    color: #475569;
    font-size: 0.9rem;
    line-height: 1.65;
}

.changelog-fix p:last-child {
    margin-bottom: 0;
}

.changelog-files {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.changelog-files code {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 1px 7px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.82rem;
    color: #1d4ed8;
}

/* ============================================================
   Mobile UX — Bottom Navigation & Mobile Layouts
   ============================================================ */

/* Default: hidden on desktop, revealed in media query */
.bottom-nav        { display: none; }
.rating-buttons    { display: none; }
.mobile-card-list  { display: none; }
.strava-card-list  { display: none; }

@media (max-width: 640px) {

    /* === Top nav: nur Brand + User, Links weg === */
    .nav-links { display: none; }
    .nav-user  { margin-left: auto; }

    /* === Bottom Navigation === */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #1e293b;
        border-top: 1px solid #334155;
        z-index: 200;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.18);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 4px;
        color: #94a3b8;
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 500;
        gap: 3px;
        min-height: 56px;
        transition: color 0.15s, background 0.15s;
    }

    .bottom-nav-item:hover,
    .bottom-nav-item.active {
        color: #fff;
        background: #334155;
    }

    .bottom-nav-item.bottom-nav-new {
        color: #60a5fa;
    }

    .bottom-nav-item.bottom-nav-new.active,
    .bottom-nav-item.bottom-nav-new:hover {
        color: #fff;
        background: #1d4ed8;
    }

    .bottom-nav-icon {
        font-size: 1.25rem;
        line-height: 1;
    }

    /* Platz für Bottom Nav am Seitenende */
    .page-main {
        padding-bottom: calc(56px + env(safe-area-inset-bottom) + 16px);
    }

    /* === Desktop-Elemente ausblenden === */
    .col-controls,
    .hide-on-mobile {
        display: none !important;
    }

    /* === Container auf Mobile === */
    .container.wide,
    .container.stretch {
        padding: 16px 12px;
    }

    /* === Page Actions: gestapelt === */
    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions .button {
        text-align: center;
    }

    /* === Mobile Entry Cards === */
    .mobile-card-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 12px;
    }

    .entry-card {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        padding: 14px 16px;
        text-decoration: none;
        color: inherit;
        display: block;
        transition: background 0.1s;
    }

    .entry-card:active {
        background: #e2e8f0;
    }

    .entry-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 6px;
    }

    .entry-card-title {
        font-weight: 600;
        font-size: 0.95rem;
        color: #1e293b;
        flex: 1;
        line-height: 1.3;
    }

    .entry-card-date {
        font-size: 0.75rem;
        color: #64748b;
        white-space: nowrap;
        padding-top: 2px;
    }

    .entry-card-stats {
        display: flex;
        gap: 14px;
        flex-wrap: wrap;
        margin-top: 6px;
    }

    .entry-card-stat {
        font-size: 0.8rem;
        color: #475569;
    }

    .entry-card-stat strong {
        color: #1d4ed8;
        font-weight: 700;
    }

    .entry-card-notes {
        margin-top: 8px;
        font-size: 0.8rem;
        color: #64748b;
        line-height: 1.45;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* === Strava Mobile Cards === */
    .strava-card-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 12px;
    }

    .strava-card {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        padding: 14px 16px;
        display: flex;
        align-items: center;
        gap: 14px;
    }

    .strava-card input[type="checkbox"] {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
        accent-color: #1d4ed8;
        cursor: pointer;
    }

    .strava-card-info {
        flex: 1;
        min-width: 0;
    }

    .strava-card-title {
        font-weight: 600;
        font-size: 0.9rem;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .strava-card-meta {
        font-size: 0.78rem;
        color: #64748b;
        margin-top: 3px;
    }

    /* === Rating Buttons (RPE / Fitness) === */
    .rating-buttons {
        display: flex;
        gap: 5px;
        flex-wrap: wrap;
        margin-top: 6px;
    }

    .rating-btn {
        width: 40px;
        height: 40px;
        border: 1.5px solid #cbd5e1;
        border-radius: 8px;
        background: #fff;
        color: #475569;
        font-weight: 600;
        font-size: 0.9rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        transition: background 0.1s, color 0.1s, border-color 0.1s;
        min-width: 40px;
    }

    .rating-btn.active {
        background: #1d4ed8;
        border-color: #1d4ed8;
        color: #fff;
    }

    /* Zahlen-Input verstecken, Button-Reihe zeigen */
    .rating-input-number { display: none !important; }

    /* === Edit Form: Reihenfolge auf Mobile === */
    .edit-form {
        display: flex;
        flex-direction: column;
    }

    .form-section-qualitative { order: 1; }
    .form-section-meta        { order: 2; }
    .form-section-technical   { order: 3; }
    .form-actions             { order: 4 !important; }
}

/* === More-Overlay (Mobile) === */
.more-overlay-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 190;
}

.more-overlay-sheet {
    display: none;
    position: fixed;
    bottom: 56px; /* direkt über der Bottom-Nav */
    left: 0;
    right: 0;
    background: #1e293b;
    border-radius: 16px 16px 0 0;
    z-index: 195;
    padding: 8px 0 8px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
}

.more-overlay-sheet.open,
.more-overlay-backdrop.open {
    display: block;
}

.more-overlay-handle {
    width: 36px;
    height: 4px;
    background: #475569;
    border-radius: 2px;
    margin: 0 auto 12px;
}

.more-overlay-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.more-overlay-item:hover,
.more-overlay-item:active {
    background: #334155;
    color: #fff;
}

.more-overlay-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.more-overlay-sep {
    height: 1px;
    background: #334155;
    margin: 6px 0;
}

/* === Strava === */
.strava-powered {
    display: flex;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.strava-powered img {
    max-width: 160px;
    height: auto;
}

/* === Responsive === */
@media (max-width: 640px) {
    .page-main {
        padding: 16px 8px 32px;
    }

    .container {
        padding: 20px 16px;
    }

    .main-nav {
        padding: 0 12px;
    }

    .nav-brand {
        padding-right: 12px;
        margin-right: 4px;
    }

    .nav-link {
        padding: 0 10px;
        font-size: 0.8rem;
        line-height: 44px;
    }

    .nav-brand {
        line-height: 44px;
    }

    .nav-user {
        line-height: 44px;
        font-size: 0.78rem;
    }

    .strava-powered {
        justify-content: center;
    }

    .strava-powered img {
        max-width: 130px;
    }

    .auth-box {
        padding: 28px 20px;
    }
}
