/* Arrivi Ciclismo - Accordion Styles */

.afd-accordion {
    width: 100%;
}

/* Header */
.afd-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
}

.afd-accordion-header:hover {
    opacity: 0.9;
}

.afd-header-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.afd-race-name {
    font-weight: 700;
    line-height: 1.3;
}

.afd-race-meta {
    display: flex;
    gap: 12px;
    font-size: 0.85em;
    opacity: 0.85;
    flex-wrap: wrap;
}

.afd-accordion-icon {
    width: 20px;
    height: 20px;
    position: relative;
    flex-shrink: 0;
    margin-left: 10px;
}

.afd-accordion-icon::before,
.afd-accordion-icon::after {
    content: '';
    position: absolute;
    background-color: currentColor;
    transition: transform 0.3s ease;
}

.afd-accordion-icon::before {
    top: 50%;
    left: 3px;
    right: 3px;
    height: 2px;
    transform: translateY(-50%);
}

.afd-accordion-icon::after {
    left: 50%;
    top: 3px;
    bottom: 3px;
    width: 2px;
    transform: translateX(-50%);
}

.afd-accordion-item.active .afd-accordion-icon::after {
    transform: translateX(-50%) rotate(90deg);
    opacity: 0;
}

/* Body */
.afd-accordion-body {
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

/* Race info */
.afd-race-info {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

.afd-race-info-narrow {
    font-size: 0.85em;
    margin-bottom: 8px;
    opacity: 0.7;
}

/* Wide layout - table */
.afd-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.afd-results-table th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 2px solid #ddd;
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
}

.afd-results-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #eee;
}

.afd-results-table .afd-pos {
    width: 45px;
    font-weight: 700;
    text-align: center;
}

.afd-results-table .afd-gap {
    white-space: nowrap;
    opacity: 0.7;
}

/* Narrow layout - list */
.afd-results-list {
    display: flex;
    flex-direction: column;
}

.afd-results-list .afd-result-row {
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85em;
    line-height: 1.4;
}

.afd-results-list .afd-result-row:last-child {
    border-bottom: none;
}

.afd-results-list .afd-pos {
    font-weight: 700;
    min-width: 25px;
    display: inline-block;
}

.afd-results-list .afd-rider {
    font-weight: 500;
}

.afd-results-list .afd-gap {
    opacity: 0.6;
    font-size: 0.9em;
}

/* Layout narrow adjustments */
.afd-layout-narrow .afd-header-content {
    gap: 2px;
}

.afd-layout-narrow .afd-race-name {
    font-size: 0.9em;
}

.afd-layout-narrow .afd-race-meta {
    font-size: 0.8em;
    gap: 8px;
}

/* No results */
.afd-no-results {
    text-align: center;
    padding: 20px;
    opacity: 0.6;
    font-style: italic;
}

/* Pagination */
.afd-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.afd-page-numbers {
    display: contents;
}

.afd-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    color: #888;
    user-select: none;
}

.afd-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
    background: #f0f0f0;
    color: #1a1a2e;
    cursor: pointer;
    padding: 0 10px;
    font-size: 14px;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    text-decoration: none;
}

.afd-page-btn:hover:not(:disabled):not(.is-active) {
    background-color: #1a1a2e;
    color: #ffffff;
}

.afd-page-btn.is-active {
    background-color: #1a8ad8;
    color: #ffffff;
    border-color: #1a8ad8;
    cursor: default;
}

.afd-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Loading state during AJAX */
.afd-accordion.afd-loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Loading placeholder (initial AJAX load) */
.afd-loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px 20px;
    color: #888;
    font-style: italic;
}

.afd-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-top-color: #1a8ad8;
    border-radius: 50%;
    animation: afd-spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes afd-spin {
    to { transform: rotate(360deg); }
}

/* Mobile: stack the wide-layout results table as a list */
@media (max-width: 600px) {
    .afd-layout-wide .afd-results-table,
    .afd-layout-wide .afd-results-table thead,
    .afd-layout-wide .afd-results-table tbody {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .afd-layout-wide .afd-results-table thead {
        display: none;
    }

    .afd-layout-wide .afd-results-table tr {
        display: grid;
        grid-template-columns: auto 1fr auto;
        column-gap: 8px;
        row-gap: 2px;
        padding: 8px 4px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .afd-layout-wide .afd-results-table td {
        padding: 0;
        border: none;
        text-align: left;
    }

    .afd-layout-wide .afd-results-table .afd-pos {
        grid-column: 1;
        grid-row: 1;
        font-weight: 700;
    }
    .afd-layout-wide .afd-results-table .afd-pos::after {
        content: '°';
    }

    .afd-layout-wide .afd-results-table .afd-rider {
        grid-column: 2;
        grid-row: 1;
        font-weight: 600;
    }

    .afd-layout-wide .afd-results-table .afd-gap {
        grid-column: 3;
        grid-row: 1;
        font-size: 0.85em;
        opacity: 0.75;
        white-space: nowrap;
    }
    .afd-layout-wide .afd-results-table .afd-gap:empty {
        display: none;
    }

    .afd-layout-wide .afd-results-table .afd-team {
        grid-column: 2 / -1;
        grid-row: 2;
        font-size: 0.9em;
        opacity: 0.8;
    }

    /* Race info row: wrap nicely */
    .afd-layout-wide .afd-race-info {
        flex-wrap: wrap;
        gap: 8px;
    }
}
