/* ---- Import Controls ---- */
.iv-import-controls {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
}
.iv-file-input { display: none; }

/* ---- Offline / Sync info ---- */
.iv-sync-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: #64748b;
    min-height: 1.4em;
    margin-top: 0.75rem;
}
.iv-offline-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #15803d;
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
}

/* ---- Status ---- */
.iv-status {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    display: none;
}
.iv-status.success {
    display: block;
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #15803d;
}
.iv-status.error {
    display: block;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
}
.iv-status.info {
    display: block;
    background: #f0f9ff;
    border: 1px solid #7dd3fc;
    color: #0369a1;
}

/* ---- Race info ---- */
.iv-race-info-container {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-top: 1.5rem;
    animation: ivFadeIn 0.3s ease-out;
}
.iv-event-title {
    display: block;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}
.iv-subtitle {
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.iv-info-layout { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: 1rem; }
.iv-info-group {
    flex: 1;
    min-width: 280px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.iv-group-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}
.iv-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0;
    border-bottom: 1px dashed var(--border-color);
    gap: 0.5rem;
}
.iv-info-item:last-child { border-bottom: none; }
.iv-info-label {
    font-size: 0.82rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .03em;
    flex: 0 0 auto;
}
.iv-info-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: right;
    word-break: break-word;
    max-width: 60%;
}
.iv-info-value--highlight { color: var(--primary-color) !important; }

/* ---- Analysis log ---- */
.iv-analysis-log {
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.88rem;
    color: var(--text-color);
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    line-height: 1.6;
}

/* ---- No data message ---- */
.iv-no-data {
    color: #94a3b8;
    font-style: italic;
    padding: 1rem 0;
}

/* ---- Table overrides ---- */
.data-table { width: 100%; border-collapse: collapse; text-align: left; min-width: 800px; }
.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
    font-size: 0.875rem;
}
.data-table th:hover { background: #f1f5f9; }
.data-table tbody tr { background: var(--card-bg); }
.data-table tbody tr:hover td { background: #f1f5f9; }

/* Right-aligned table columns (Zeit, RPkt, etc.) */
.data-table th.text-right,
.data-table td.text-right,
#competitorTable th[data-col="TimeTotal"],
#competitorTable td[data-col="TimeTotal"],
#competitorTable th[data-col="RPts"],
#competitorTable td[data-col="RPts"],
#competitorTable th[data-col="SPkt"],
#competitorTable td[data-col="SPkt"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Highlighted category rows (found in XML) */
.data-table tr.highlighted td { background: #fefce8; }
.data-table tr.highlighted:hover td { background: #fef08a; }

/* Sort indicators */
.sort-asc::after { content: ' ▲'; font-size: 0.75em; color: var(--primary-color); }
.sort-desc::after { content: ' ▼'; font-size: 0.75em; color: var(--primary-color); }

/* Category group header rows */
.data-table tr.kat-group-header td {
    background: #fff5f6;
    border-top: 2px solid var(--primary-color);
    border-bottom: 1px solid #fecdd3;
    padding: 0.5rem 1rem;
}
.data-table tr.kat-group-header:hover td { background: #fff5f6; }
.kat-group-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kat-group-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: .08em;
}
.kat-group-count {
    font-size: 0.75rem;
    font-weight: 600;
    background: #fecdd3;
    color: var(--primary-color);
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
}

/* Nr column */
.cat-nr-col {
    width: 48px;
    text-align: center;
    cursor: default !important;
    color: #94a3b8 !important;
}
.cat-nr-cell { text-align: center; color: #94a3b8; font-size: 0.82rem; }

/* ---- Zuschlag meta strip ---- */
.iv-zmeta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2.5rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.75rem;
}
.iv-zmeta-item { display: flex; flex-direction: column; gap: 0.15rem; }
.iv-zmeta-label { font-size: 0.72rem; color: #94a3b8; text-transform: uppercase; letter-spacing: .06em; }
.iv-zmeta-item strong { font-size: 1rem; font-weight: 700; color: var(--text-color); }

/* ---- Zuschlag gender sections ---- */
.iv-zuschlag-sections { display: flex; flex-direction: column; gap: 2rem; }
.iv-zuschlag-section-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.iv-zuschlag-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: .06em;
}
.iv-gender-icon { font-size: 1.3rem; color: var(--primary-color); }

/* ---- Zuschlag Table ---- */
.zuschlag-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    table-layout: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}
.zuschlag-table thead th {
    background: #e0f2fe;
    color: #0369a1;
    padding: 0.6rem 1rem;
    font-weight: 700;
    text-align: left;
}
.zt-th-num { text-align: right !important; }
.zuschlag-table tbody tr { border-bottom: 1px solid var(--border-color); }
.zuschlag-table tbody tr:hover td { background: #f1f5f9; }
.zuschlag-table td { padding: 0.5rem 1rem; }

.zt-rang,    .zt-th-rang  { width: 46px;  color: #94a3b8; font-weight: 600; }
.zt-pnr,     .zt-th-pnr   { width: 68px;  color: #64748b; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.zt-name,    .zt-th-name  { width: auto;  color: var(--text-color); overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-size: 0.92rem; }
.zt-jg-col               { width: 52px;  color: #64748b; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.zt-club-col             { white-space: nowrap; color: #64748b; font-size: 0.85rem; }
.zt-punkte, .zt-th-num   { width: 82px;  text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-color); }
.zt-sel                  { width: 82px;  text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: #0369a1; }

/* Struck rows (eliminated from calculation) */
.z-row-struck .zt-rang,
.z-row-struck .zt-pnr,
.z-row-struck .zt-name { color: #22c55e; }
.z-row-struck .zt-punkte { color: #22c55e; text-decoration: line-through; }
.z-row-kept .zt-rang,
.z-row-kept .zt-name { color: var(--text-color); }

/* Footer rows */
.zt-sep-row td { height: 5px; background: #f8fafc; border: none; padding: 0; }
.zt-summe-row td,
.zt-calc-row td,
.zt-app-row td { padding: 0.4rem 1rem; border-bottom: 1px solid var(--border-color); }
.zt-foot-label { text-align: right; color: #64748b; font-size: 0.85rem; }
.zt-calc-row .zt-foot-label,
.zt-app-row .zt-foot-label { font-size: 1rem; font-weight: 700; color: var(--text-color); }
.zt-divisor { text-align: right; color: #64748b; font-size: 0.85rem; }
.zt-summe-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: #0369a1; }
.zt-calc-val { text-align: right; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--text-color); }
.zt-app-val { text-align: right; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--primary-color); }
.z-no-data { color: #94a3b8; font-style: italic; padding: 0.75rem 0; }

/* ---- Modal ---- */
.iv-modal-content {
    background: var(--card-bg);
    padding: 2rem 2.5rem;
    border-radius: var(--radius);
    border: 1px solid #fca5a5;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .iv-card { padding: 1rem; }
    .iv-import-controls { flex-direction: column; }
    .btn-action { width: 100%; justify-content: center; }

    /* Tables: horizontal scroll like Punkteliste (no card-stacking) */
    .table-container { margin-bottom: 0; }
    .data-table th {
        position: sticky;
        top: 0;
        z-index: 10;
        font-size: 0.8rem;
        padding: 0.55rem 0.65rem;
    }
    .data-table td {
        font-size: 0.82rem;
        padding: 0.55rem 0.65rem;
        white-space: nowrap;
    }
    /* Hide columns after 6th on mobile */
    .data-table th:nth-child(n+7),
    .data-table td:nth-child(n+7) { display: none; }

    /* Kat group header: spans the visible columns nicely */
    .data-table tr.kat-group-header td:nth-child(n+7) { display: table-cell; }

    /* Info layout: stack on mobile */
    .iv-info-layout { flex-direction: column; gap: 1rem; }
    .iv-info-group { min-width: 0; }

    /* Zuschlag */
    .iv-zuschlag-sections { gap: 1.5rem; }
    .zt-pnr, .zt-th-pnr,
    .zt-jg-col, .zt-club-col { display: none; }
    .iv-zuschlag-section { overflow-x: auto; }
    .zuschlag-table { font-size: 0.78rem; width: 100% !important; table-layout: auto !important; }
    .zuschlag-table th { padding: 0.45rem 0.5rem; font-size: 0.72rem; letter-spacing: 0; }
    .zuschlag-table td { padding: 0.4rem 0.5rem; }
    .zt-name, .zt-th-name { font-size: inherit; }
    .zt-rang  { width: 38px; }
    .zt-calc-val, .zt-app-val { font-size: 0.9rem; }
    .zt-foot-label { font-size: 0.75rem; }
    .zt-calc-row .zt-foot-label,
    .zt-app-row .zt-foot-label { font-size: 0.85rem; }

    /* ---- Kategorien-Tabelle: alle Spalten immer sichtbar ---- */
    #catTable {
        min-width: 0;          /* globales min-width:800px aufheben */
        width: 100%;
        table-layout: fixed;   /* gleichmäßige Spaltenverteilung */
    }
    /* alle Spalten anzeigen (Override der n+7-Regel) */
    #catTable th,
    #catTable td { display: table-cell; }
    #catTable th {
        font-size: 0.7rem;
        padding: 0.4rem 0.3rem;
        white-space: normal;
        word-break: break-word;
        line-height: 1.2;
    }
    #catTable td {
        font-size: 0.72rem;
        padding: 0.4rem 0.3rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Nr-Spalte sehr schmal */
    #catTable .cat-nr-col,
    #catTable .cat-nr-cell { width: 28px; min-width: 28px; }
    /* Code-Spalte schmal */
    #catTable th[data-col="Code"] { width: 52px; min-width: 52px; }
    #catTable td[data-label="Code"] { font-variant-numeric: tabular-nums; }
    /* G (Geschlecht) sehr schmal */
    #catTable th[data-col="G"] { width: 28px; min-width: 28px; text-align: center; }
    #catTable td[data-label="G"] { text-align: center; }
    /* Kat (Kategoriename) breiter */
    #catTable th[data-col="Kat"],
    #catTable td[data-label="Kat"] { width: auto; min-width: 80px; }
    /* JG von / JG bis kompakt */
    #catTable th[data-col="JG von"],
    #catTable th[data-col="JG bis"] { width: 46px; min-width: 46px; text-align: center; }
    #catTable td[data-label="JG von"],
    #catTable td[data-label="JG bis"] { text-align: center; font-variant-numeric: tabular-nums; }

    /* ---- Rangliste: alle Spalten immer sichtbar (horizontales Scrollen) ---- */
    #competitorTable th,
    #competitorTable td { display: table-cell; }
}
