/**
 * Ergebnisse_Live Shortcode Styles
 * Responsive grid layout for live results display
 */

.lbwsw-ergebnisse-live {
    width: 100%;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 4px;
}

/* ====== Event Selector (Accordion) ====== */

.ergebnisse-live__event-selector {
    margin-bottom: 2rem;
}

.accordion {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: white;
}

.accordion__summary {
    padding: 1rem;
    background: #f5f5f5;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s;
}

.accordion__summary:hover {
    background: #efefef;
}

.accordion__summary::after {
    content: "▼";
    display: inline-block;
    margin-left: 0.5rem;
    transition: transform 0.2s;
}

details[open] .accordion__summary::after {
    transform: rotate(180deg);
}

.event-label {
    font-size: 1.1rem;
    color: #333;
}

.accordion__content {
    padding: 1rem;
    border-top: 1px solid #ddd;
    background: white;
}

.event-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.event-select:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

/* ====== Competitions Grid ====== */

.ergebnisse-live__grid {
    display: grid;
    gap: 1.5rem;
    margin-top: 2rem;
}

/* Responsive grid: Auto-calculate columns based on available space */
/* Each card: min 300px width, max 5 cards per row */
.ergebnisse-live__grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-auto-rows: auto;
}

/* Explicit breakpoints for better distribution */
@media (max-width: 1600px) {
    .ergebnisse-live__grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1400px) {
    .ergebnisse-live__grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1000px) {
    .ergebnisse-live__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .ergebnisse-live__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .ergebnisse-live__grid {
        grid-template-columns: 1fr;
    }
}

.ergebnisse-live__grid .loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #999;
    font-style: italic;
}

.ergebnisse-live__grid .error {
    grid-column: 1 / -1;
    padding: 2rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    color: #c33;
}

/* ====== Competition Card ====== */

.competition-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.competition-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.competition-card__header {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #3d8b40;
}

.competition-card__header h3 {
    margin: 0;
    font-size: 1.2rem;
    word-break: break-word;
}

.status-badge {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    white-space: nowrap;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.status-badge.live {
    background: rgba(255, 100, 100, 0.6);
    animation: pulse-live 1s infinite;
}

.status-badge.finished {
    background: rgba(100, 200, 100, 0.6);
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.competition-card.finished .competition-card__header {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    border-bottom-color: #1565c0;
}

.competition-card__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ====== Top 3 Section (Live Mode) ====== */

.top3-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.top3-gender {
    min-width: 0;
}

.top3-gender h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #333;
    font-weight: 600;
    text-align: center;
}

.top3-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
}

.rank-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.rank-item .platz {
    font-weight: bold;
    color: #4CAF50;
    font-size: 0.9rem;
}

.rank-item .name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-item .time {
    font-family: monospace;
    color: #666;
    font-size: 0.8rem;
}

.rank-item .badges {
    display: flex;
    gap: 0.25rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.rank-item .badges span {
    background: #f0f0f0;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    color: #666;
}

.rank-item.empty {
    text-align: center;
    padding: 1rem 0.5rem;
    color: #999;
    font-style: italic;
}

.rank-item.loading {
    text-align: center;
    padding: 1rem 0.5rem;
    color: #999;
}

/* ====== Finishers Section (Live Mode) ====== */

.finishers-section {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.finishers-section h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #333;
    font-weight: 600;
}

.finishers-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.finisher-item {
    padding: 0.5rem;
    background: #f9f9f9;
    border-left: 3px solid #4CAF50;
    border-radius: 3px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    overflow: hidden;
}

.finisher-item .gender-marker {
    font-weight: bold;
    font-size: 0.9rem;
    min-width: 20px;
}

.finisher-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.finisher-item .time {
    font-family: monospace;
    color: #666;
    font-size: 0.8rem;
    white-space: nowrap;
}

.finisher-item .badges {
    display: flex;
    gap: 0.25rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
    white-space: nowrap;
}

.finisher-item .badges span {
    background: white;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    border: 1px solid #ddd;
    color: #666;
}

.finishers-list .empty {
    text-align: center;
    padding: 1rem 0;
    color: #999;
    font-style: italic;
}

.finishers-list .loading {
    text-align: center;
    padding: 1rem 0;
    color: #999;
}

/* ====== AK Scroller Section (Finished Mode) ====== */

.ak-scroller {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    overflow: auto;
}

.ak-section {
    flex: 1;
}

.ak-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    color: #333;
    font-weight: 600;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 0.5rem;
}

.ak-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.ak-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
}

.ak-table tbody tr:hover {
    background: #fafafa;
}

.ak-table td {
    padding: 0.5rem 0.4rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ak-table td.ak-rank {
    font-weight: bold;
    color: #4CAF50;
    width: 40px;
    text-align: center;
}

.ak-table td.ak-name {
    flex: 1;
    min-width: 0;
}

.ak-table td.ak-time {
    font-family: monospace;
    color: #666;
    width: 80px;
    text-align: right;
}

.ak-scroller .error {
    padding: 1rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    color: #c33;
    text-align: center;
}

.ak-scroller .loading {
    text-align: center;
    padding: 2rem 1rem;
    color: #999;
    font-style: italic;
}

/* ====== Utilities ====== */

.empty {
    text-align: center;
    padding: 1rem;
    color: #999;
    font-style: italic;
}

.error {
    color: #c33;
    padding: 1rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
}

/* Scrollbar styling for internal scrollable areas */
.finishers-section::-webkit-scrollbar,
.ak-scroller::-webkit-scrollbar {
    width: 6px;
}

.finishers-section::-webkit-scrollbar-track,
.ak-scroller::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.finishers-section::-webkit-scrollbar-thumb,
.ak-scroller::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.finishers-section::-webkit-scrollbar-thumb:hover,
.ak-scroller::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ====== Accessibility ====== */

@media (prefers-reduced-motion: reduce) {
    .status-badge.live {
        animation: none;
        opacity: 0.8;
    }

    .competition-card {
        transition: none;
    }
}

/* ====== Print Styles ====== */

@media print {
    .ergebnisse-live__event-selector {
        display: none;
    }

    .competition-card {
        page-break-inside: avoid;
    }
}
