/* Andorra Esportiu Scores v1.1 */
:root {
    --ae-primary: #f5c518;
    --ae-dark: #111111;
    --ae-mid: #222222;
    --ae-light: #f4f4f4;
    --ae-border: #e0e0e0;
    --ae-text: #222222;
    --ae-muted: #777777;
    --ae-live: #e31c1c;
    --ae-champions: #1a6fc4;
    --ae-europa: #e87722;
    --ae-descens: #cc2222;
}

/* ===================== BASE ===================== */
.ae-widget {
    font-family: inherit;
    margin: 0 0 2rem;
    background: #fff;
    border: 1px solid var(--ae-border);
    border-radius: 4px;
    overflow: hidden;
}

.ae-widget-header {
    background: var(--ae-dark);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ae-widget-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ae-league-logo { width: 28px; height: 28px; object-fit: contain; }
.ae-team-logo-lg { width: 32px; height: 32px; object-fit: contain; }

/* ===================== CLASSIFICACIÓ ===================== */
.ae-table-wrap { overflow-x: auto; }

.ae-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.ae-table thead tr {
    background: var(--ae-light);
    border-bottom: 2px solid var(--ae-primary);
}

.ae-table th {
    padding: 8px 6px;
    text-align: center;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--ae-muted);
}

.ae-table th.ae-team-col { text-align: left; padding-left: 12px; }

.ae-table tbody tr {
    border-bottom: 1px solid var(--ae-border);
    transition: background 0.15s;
}

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

.ae-table td {
    padding: 7px 6px;
    text-align: center;
    color: var(--ae-text);
}

.ae-table td.ae-team-col {
    text-align: left;
    padding-left: 12px;
}

.ae-team-col-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ae-team-logo { width: 20px; height: 20px; object-fit: contain; }
.ae-pts { font-weight: 700; color: var(--ae-dark); }
.ae-pos { font-weight: 600; color: var(--ae-muted); width: 28px; }

.ae-zona-champions td:first-child { border-left: 3px solid var(--ae-champions); }
.ae-zona-europa td:first-child { border-left: 3px solid var(--ae-europa); }
.ae-zona-descens td:first-child { border-left: 3px solid var(--ae-descens); }

.ae-forma { white-space: nowrap; }
.ae-forma-dot {
    display: inline-block;
    width: 18px; height: 18px;
    border-radius: 50%;
    font-size: 10px; font-weight: 700;
    text-align: center; line-height: 18px;
    margin: 0 1px; color: #fff;
}
.ae-w { background: #2e7d32; }
.ae-d { background: #f57c00; }
.ae-l { background: #c62828; }

.ae-llegenda {
    padding: 8px 12px;
    display: flex; gap: 16px;
    font-size: 11px;
    background: var(--ae-light);
    border-top: 1px solid var(--ae-border);
}

.ae-llegenda-item {
    display: flex; align-items: center; gap: 5px;
    color: var(--ae-muted);
}

.ae-llegenda-item::before {
    content: '';
    display: inline-block;
    width: 10px; height: 10px; border-radius: 2px;
}

.ae-zona-champions.ae-llegenda-item::before { background: var(--ae-champions); }
.ae-zona-europa.ae-llegenda-item::before { background: var(--ae-europa); }
.ae-zona-descens.ae-llegenda-item::before { background: var(--ae-descens); }

/* ===================== PARTITS (resultats/calendari) ===================== */
.ae-match {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ae-border);
}
.ae-match:last-child { border-bottom: none; }

.ae-match-date {
    font-size: 11px; color: var(--ae-muted);
    margin-bottom: 6px;
    display: flex; align-items: center; gap: 8px;
}

.ae-match-teams {
    display: flex; align-items: center;
    justify-content: space-between; gap: 8px;
}

.ae-team {
    display: flex; align-items: center; gap: 8px;
    flex: 1; font-size: 14px; font-weight: 500;
}
.ae-team img { width: 24px; height: 24px; object-fit: contain; }
.ae-team-away { flex-direction: row-reverse; text-align: right; }
.ae-winner { font-weight: 700; }

.ae-score {
    display: flex; align-items: center; gap: 4px;
    font-size: 20px; font-weight: 700;
    min-width: 70px; justify-content: center;
    background: var(--ae-dark); color: var(--ae-primary);
    padding: 4px 10px; border-radius: 3px;
}
.ae-score-sep { color: #fff; font-weight: 300; }

.ae-match-time { font-size: 13px; font-weight: 600; color: var(--ae-dark); }
.ae-match-round {
    font-size: 11px; color: var(--ae-muted);
    background: var(--ae-light);
    padding: 2px 6px; border-radius: 3px;
}

.ae-live { background: #fff5f5; }

.ae-live-badge {
    background: var(--ae-live); color: #fff;
    font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 3px;
    text-transform: uppercase;
    animation: ae-pulse 1.5s infinite;
}

@keyframes ae-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.ae-match-minute {
    text-align: center; font-size: 12px;
    font-weight: 700; color: var(--ae-live); margin-top: 4px;
}

/* ===================== PLANTILLA ===================== */
.ae-pos-group { padding: 0 16px 16px; }

.ae-pos-title {
    font-size: 12px; font-weight: 700;
    text-transform: uppercase; color: var(--ae-muted);
    letter-spacing: 1px;
    padding: 10px 0 6px;
    border-bottom: 2px solid var(--ae-primary);
    margin: 0 0 8px;
}

.ae-players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
}

.ae-player {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px;
    background: var(--ae-light);
    border-radius: 3px; font-size: 13px;
}

.ae-player-num {
    width: 24px; height: 24px;
    background: var(--ae-dark); color: var(--ae-primary);
    border-radius: 50%; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.ae-player-info { display: flex; flex-direction: column; }
.ae-player-name { font-weight: 600; color: var(--ae-text); }
.ae-player-age { font-size: 11px; color: var(--ae-muted); }

/* ===================== PÀGINA DIRECTE (estil AS) ===================== */
.ae-directe-page {
    font-family: inherit;
    max-width: 800px;
}

.ae-day-tabs {
    display: flex; gap: 0;
    border-bottom: 2px solid var(--ae-primary);
    margin-bottom: 0;
    overflow-x: auto;
}

.ae-day-tab {
    flex: 1; min-width: 80px;
    padding: 10px 12px;
    background: #fff;
    border: none; border-bottom: none;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center;
    font-size: 12px; color: var(--ae-muted);
    transition: background 0.15s;
}

.ae-day-tab:hover { background: var(--ae-light); }

.ae-day-tab.ae-active {
    background: var(--ae-dark);
    color: #fff;
}

.ae-tab-label { font-weight: 700; font-size: 13px; }
.ae-tab-date { font-size: 11px; opacity: 0.7; }

.ae-sport-tabs {
    display: flex; gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--ae-border);
    margin-bottom: 12px;
}

.ae-sport-tab {
    padding: 5px 14px;
    border: 1px solid var(--ae-border);
    border-radius: 20px;
    background: #fff;
    font-size: 13px; font-weight: 500;
    cursor: pointer; color: var(--ae-text);
    transition: all 0.15s;
}

.ae-sport-tab:hover { border-color: var(--ae-dark); }

.ae-sport-tab.ae-active {
    background: var(--ae-dark);
    color: var(--ae-primary);
    border-color: var(--ae-dark);
}

/* Grup per lliga */
.ae-grup-lliga {
    margin-bottom: 16px;
    border: 1px solid var(--ae-border);
    border-radius: 4px;
    overflow: hidden;
}

.ae-grup-header {
    background: var(--ae-dark);
    color: #fff;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    display: flex; align-items: center; gap: 8px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.ae-esport-badge { font-size: 16px; }

/* Cada partit */
.ae-directe-match {
    display: grid;
    grid-template-columns: 48px 1fr auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--ae-border);
    font-size: 14px;
}

.ae-directe-match:last-child { border-bottom: none; }
.ae-directe-match.ae-live { background: #fff5f5; }
.ae-directe-match.ae-fi { background: #fafafa; }

.ae-dm-hora {
    text-align: center;
    font-size: 13px; font-weight: 600;
    color: var(--ae-muted);
    min-width: 40px;
}

.ae-live-min {
    color: var(--ae-live); font-weight: 700;
    animation: ae-pulse 1.5s infinite;
}

.ae-fi-label { color: var(--ae-muted); font-size: 12px; }

.ae-dm-home {
    display: flex; align-items: center;
    justify-content: flex-end; gap: 8px;
    font-weight: 500;
}

.ae-dm-away {
    display: flex; align-items: center;
    justify-content: flex-start; gap: 8px;
    font-weight: 500;
}

.ae-dm-home img, .ae-dm-away img {
    width: 22px; height: 22px; object-fit: contain;
}

.ae-dm-home.ae-winner, .ae-dm-away.ae-winner { font-weight: 700; }

.ae-dm-score {
    display: flex; align-items: center; gap: 3px;
    background: var(--ae-dark); color: var(--ae-primary);
    padding: 4px 10px; border-radius: 3px;
    font-size: 17px; font-weight: 700;
    min-width: 64px; justify-content: center;
}

.ae-sc { color: var(--ae-primary); }
.ae-sc-sep { color: #fff; font-weight: 300; }
.ae-sc-vs { color: #fff; font-size: 12px; font-weight: 400; }

.ae-dm-round {
    grid-column: 1 / -1;
    font-size: 11px; color: var(--ae-muted);
    padding-top: 2px;
}

.ae-loading {
    padding: 24px;
    text-align: center;
    color: var(--ae-muted);
    font-size: 14px;
}

.ae-no-partits {
    padding: 24px;
    text-align: center;
    color: var(--ae-muted);
    font-size: 14px;
}

.ae-error {
    padding: 12px 16px;
    color: var(--ae-live);
    font-size: 13px;
}

/* Responsive */
@media (max-width: 600px) {
    .ae-forma { display: none; }
    .ae-table th:nth-child(7), .ae-table td:nth-child(7),
    .ae-table th:nth-child(8), .ae-table td:nth-child(8) { display: none; }

    .ae-directe-match {
        grid-template-columns: 36px 1fr auto 1fr;
        font-size: 12px;
    }
    .ae-dm-round { display: none; }
    .ae-dm-score { font-size: 14px; padding: 3px 7px; min-width: 52px; }
}

/* ===================== NAVEGACIÓ JORNADES ===================== */
.ae-jornada-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--ae-light);
    border-bottom: 1px solid var(--ae-border);
}

.ae-jornada-btn {
    background: var(--ae-dark);
    color: var(--ae-primary);
    border: none;
    width: 28px; height: 28px;
    border-radius: 3px;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.15s;
}
.ae-jornada-btn:hover { opacity: 0.8; }

.ae-jornada-select {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--ae-border);
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ae-text);
    background: #fff;
    cursor: pointer;
}

/* ===================== PLAYER STATS MODAL ===================== */
.ae-player-clickable {
    cursor: pointer;
    transition: background 0.15s;
}
.ae-player-clickable:hover { background: #e8f0fe; }

.ae-player-arrow {
    margin-left: auto;
    color: var(--ae-muted);
    font-size: 18px;
}

.ae-player-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ae-modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
}

.ae-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1;
}

.ae-modal-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--ae-muted);
    line-height: 1;
}

.ae-player-stats-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--ae-primary);
}

.ae-player-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--ae-primary);
}

.ae-player-stats-info h3 {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
}

.ae-player-stats-info p {
    margin: 2px 0;
    font-size: 13px;
    color: var(--ae-muted);
}

.ae-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.ae-stat-item {
    background: var(--ae-light);
    border-radius: 6px;
    padding: 10px 8px;
    text-align: center;
}

.ae-stat-val {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--ae-dark);
    line-height: 1;
    margin-bottom: 4px;
}

.ae-stat-label {
    display: block;
    font-size: 11px;
    color: var(--ae-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ae-stat-team {
    font-size: 12px;
    color: var(--ae-muted);
    text-align: center;
    margin-top: 8px;
}

/* ===================== MILLORA MODAL JUGADOR ===================== */
.ae-player-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.ae-modal-content {
    background: #fff !important;
    border-radius: 12px !important;
    padding: 0 !important;
    width: 92% !important;
    max-width: 500px !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3) !important;
}

.ae-modal-close {
    position: sticky !important;
    top: 0 !important;
    float: right !important;
    margin: 8px 8px 0 0 !important;
    background: rgba(0,0,0,0.1) !important;
    border: none !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    font-size: 18px !important;
    cursor: pointer !important;
    color: #333 !important;
    z-index: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.ae-player-stats {
    padding: 16px !important;
}

.ae-player-stats-header {
    display: flex !important;
    gap: 16px !important;
    align-items: center !important;
    margin-bottom: 20px !important;
    padding-bottom: 16px !important;
    border-bottom: 3px solid var(--ae-primary) !important;
}

.ae-player-photo {
    width: 80px !important;
    height: 80px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 3px solid var(--ae-primary) !important;
    flex-shrink: 0 !important;
}

.ae-player-stats-info h3 {
    margin: 0 0 6px !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #111 !important;
}

.ae-player-stats-info p {
    margin: 2px 0 !important;
    font-size: 13px !important;
    color: #666 !important;
}

.ae-stats-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
}

.ae-stat-item {
    background: #f5f5f5 !important;
    border-radius: 8px !important;
    padding: 12px 8px !important;
    text-align: center !important;
    border-bottom: 3px solid var(--ae-primary) !important;
}

.ae-stat-val {
    display: block !important;
    font-size: 24px !important;
    font-weight: 800 !important;
    color: #111 !important;
    line-height: 1 !important;
    margin-bottom: 6px !important;
}

.ae-stat-label {
    display: block !important;
    font-size: 10px !important;
    color: #888 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    font-weight: 600 !important;
}

.ae-stat-team {
    font-size: 12px !important;
    color: #999 !important;
    text-align: center !important;
    margin-top: 8px !important;
    padding-top: 8px !important;
    border-top: 1px solid #eee !important;
}
