/* ============================================================
   MatchAnalytics Data Extractor – Premium Dashboard v2
   ============================================================ */

/* ── Custom Properties (Variables) ─────────────────────── */
:root {
    --map-bg-main: #ffffff;
    --map-bg-secondary: #f8fafc;
    --map-bg-tertiary: #f1f5f9;
    --map-bg-hover: #eff6ff;
    
    --map-border: #e2e8f0;
    --map-border-focus: #cbd5e1;
    
    --map-text-main: #0f172a;
    --map-text-secondary: #334155;
    --map-text-muted: #64748b;
    --map-text-accent: #2563eb;
    
    --map-shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --map-shadow-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    --map-team-home: #1e40af;
    --map-team-away: #b91c1c;

    --map-radius-sm: 6px;
    --map-radius-md: 10px;
    --map-radius-lg: 14px;
}

/* ── Dark Mode ─────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root {
        --map-bg-main: #0f172a;
        --map-bg-secondary: #1e293b;
        --map-bg-tertiary: #334155;
        --map-bg-hover: #1e293b;
        
        --map-border: #334155;
        --map-border-focus: #475569;
        
        --map-text-main: #f8fafc;
        --map-text-secondary: #cbd5e1;
        --map-text-muted: #94a3b8;
        --map-text-accent: #60a5fa;

        --map-shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
        --map-shadow-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.6);

        --map-team-home: #60a5fa;
        --map-team-away: #f87171;
    }
}

/* ── Wrapper ───────────────────────────────────────────────── */
.wp-block-match_analytics-match-data,
.match_analytics-block-container,
.match_analytics-match-data-view,
.map-wrapper {
    max-width: 900px;
    margin: 1.5rem auto;
    padding: 0;
    box-sizing: border-box;
    line-height: 1.6;
}

.match_analytics-match-data-view *,
.match_analytics-match-data-view *::before,
.match_analytics-match-data-view *::after,
.map-wrapper *,
.map-wrapper *::before,
.map-wrapper *::after {
    box-sizing: inherit;
}

/* ── Placeholder & Loading ─────────────────────────────────── */
.match_analytics-placeholder {
    padding: 60px 20px;
    text-align: center;
    color: var(--map-text-muted);
    border: 2px dashed var(--map-border);
    border-radius: var(--map-radius-lg);
    background: var(--map-bg-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.map-loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--map-border);
    border-top-color: var(--map-text-accent);
    border-radius: 50%;
    animation: map-spin 1s linear infinite;
}
@keyframes map-spin {
    to { transform: rotate(360deg); }
}

/* Data display container */
.match_analytics-data-display {
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ── Match Header (Prediction Box) ── */
.map-prediction-box {
    background: linear-gradient(135deg, var(--map-bg-secondary), var(--map-bg-main));
    border-radius: var(--map-radius-lg);
    border: 1px solid var(--map-border);
    box-shadow: var(--map-shadow-card);
    padding: 24px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.map-match-header {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.map-match-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--map-text-muted);
    font-weight: 600;
}
.map-match-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}
.map-weather img {
    height: 24px;
    width: auto;
}
.map-match-teams {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
}
.map-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 10px;
    text-align: center;
}
.map-team-crest {
    height: 70px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
@media (prefers-color-scheme: dark) {
    .map-team-crest {
        filter: drop-shadow(0 2px 4px rgba(255,255,255,0.05));
        background: rgba(255,255,255,0.03);
        border-radius: 8px;
        padding: 4px;
    }
}
.map-team-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--map-text-main);
}
.map-match-vs {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--map-text-muted);
    padding: 0 20px;
}

/* Form Badges */
.map-team-form {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 4px;
}
.map-form-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
    cursor: default;
}
.map-f-win { background-color: #10b981; }  /* Green */
.map-f-draw { background-color: #6b7280; } /* Gray */
.map-f-loss { background-color: #ef4444; } /* Red */
.map-f-unk { background-color: #374151; }

.map-ht-score {
    opacity: 0.7;
    font-size: 0.75em;
    margin-left: 4px;
}

.map-icon-yellow-card {
    fill: #fbbf24 !important;
}

.map-icon-red-card {
    fill: #ef4444 !important;
}

/* ── Match Intro (description) — WordPress Standart Stilleri ─ */
/* itemprop="description" div'i tema stillerini kullanır;       */
/* plugin wrapper'ının font/color override'ları burada sıfırlanır */
[itemprop="description"] {
    font-family: inherit;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
    all: revert;
    margin-bottom: 24px;
}

/* ── Section Wrappers (Cards) ──────────────────────────────── */
.map-section {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--map-text-main);
    background: var(--map-bg-main);
    border-radius: var(--map-radius-lg);
    border: 1px solid var(--map-border);
    box-shadow: var(--map-shadow-card);
    margin-bottom: 24px;
    overflow: hidden;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.map-section:hover {
    box-shadow: var(--map-shadow-hover);
    border-color: var(--map-border-focus);
}

.map-section-title {
    margin: 0;
    padding: 16px 20px;
    font-size: 1rem;
    font-weight: 700;
    background: var(--map-bg-secondary);
    color: var(--map-text-main);
    border-bottom: 1px solid var(--map-border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.map-section-title svg {
    width: 18px;
    height: 18px;
    min-width: 18px;
    flex-shrink: 0;
    display: inline-block;
    fill: var(--map-text-muted);
}

/* ── Tables (Semantic H2H & Recent Matches) ────────────────── */
.map-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.map-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; /* Force minimum width to prevent weird squishing */
}

/* ── Table Rows & Cells ── */
.map-table th,
.map-table td {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--map-bg-tertiary);
    vertical-align: middle;
}

.map-table tbody tr {
    transition: background-color 0.2s ease;
}
.map-table tbody tr:hover {
    background-color: var(--map-bg-hover);
}
.map-table tbody tr:last-child td {
    border-bottom: none;
}

/* Header Cells */
.map-table th {
    background: var(--map-bg-secondary);
    color: var(--map-text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-align: center;
}

/* Cell alignment */
.map-date {
    color: var(--map-text-muted);
    text-align: center;
    font-size: 0.85rem;
    width: 100px;
}
.map-team-home {
    text-align: right;
    font-weight: 600;
    width: 35%;
}
.map-team-away {
    text-align: left;
    font-weight: 600;
    width: 35%;
}
.map-score {
    text-align: center;
    width: 100px;
}
.map-score-badge {
    display: inline-block;
    background: var(--map-bg-tertiary);
    color: var(--map-text-main);
    font-weight: 800;
    padding: 6px 12px;
    border-radius: var(--map-radius-sm);
    white-space: nowrap;
}

/* ── Standings Table ───────────────────────────────────────── */
.map-standings-table {
    min-width: 100%;
}
.map-standings-table th, 
.map-standings-table td {
    text-align: center;
    padding: 12px 10px;
}
.map-standings-table td.rank {
    font-weight: 700;
    color: var(--map-text-muted);
}
.map-standings-table td.team {
    text-align: left;
    font-weight: 600;
}
.map-standings-table td.points {
    font-weight: 800;
    color: var(--map-text-accent);
}

/* ── Overall Stats Grid ────────────────────────────────────── */
.map-stats-container {
    display: flex;
    flex-direction: column;
}
.map-stat-header {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid var(--map-border);
    background: var(--map-bg-secondary);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--map-text-muted);
}
.map-stat-home-name { text-align: right; color: var(--map-team-home); }
.map-stat-center-name { text-align: center; }
.map-stat-away-name { text-align: left; color: var(--map-team-away); }

.map-stat-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--map-bg-tertiary);
    gap: 12px;
    transition: background-color 0.2s ease;
}
.map-stat-row:hover {
    background-color: var(--map-bg-hover);
}
.map-stat-row:last-child {
    border-bottom: none;
}

.map-stat-home { 
    text-align: right; 
    color: var(--map-team-home);
    font-weight: 700;
}
.map-stat-away { 
    text-align: left; 
    color: var(--map-team-away);
    font-weight: 700;
}

/* Stat Label Pill */
.map-stat-label {
    background: var(--map-bg-secondary);
    color: var(--map-text-secondary);
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--map-border);
}
.map-stat-label svg {
    width: 14px;
    height: 14px;
    min-width: 14px;
    flex-shrink: 0;
    display: inline-block;
    fill: currentColor;
}

/* ── Progress Bars ─────────────────────────────────────────── */
.map-progress-wrap {
    width: 100%;
    margin-top: 8px;
    position: relative;
    display: flex;
    align-items: center;
}
.map-progress-home { justify-content: flex-end; }
.map-progress-away { justify-content: flex-start; }

.map-progress-track {
    width: 100%;
    height: 6px;
    background: var(--map-border);
    border-radius: 10px;
    overflow: hidden;
}
.map-progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s ease-out;
    width: var(--map-progress, 0%);
}
.map-progress-home .map-progress-fill {
    background: var(--map-team-home);
    float: right;
}
.map-progress-away .map-progress-fill {
    background: var(--map-team-away);
}

/* ── Mobile (≤ 768px) ──────────────────────────────────────── */
@media (max-width: 768px) {

    /* ── Match Header Teams ── */
    .map-match-teams {
        flex-direction: row;
        gap: 8px;
        padding: 0;
    }
    .map-team-name {
        font-size: 0.85rem;
    }
    .map-team-crest {
        height: 48px;
    }
    .map-match-vs {
        font-size: 1rem;
        padding: 0 8px;
    }

    /* ── Match Table: Horizontal Card Layout ── */
    .map-table {
        min-width: 0;
        width: 100%;
    }

    /* Hide the standard thead */
    .map-table thead {
        display: none;
    }

    /* Each row becomes a flex row card */
    .map-table tbody tr {
        display: flex;
        flex-direction: row;
        align-items: center;
        padding: 10px 12px;
        gap: 6px;
        border-bottom: 1px solid var(--map-bg-tertiary);
        position: relative;
    }
    .map-table tbody tr:last-child {
        border-bottom: none;
    }

    /* All cells inline */
    .map-table tbody td {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border: none;
        font-size: 0.78rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Date column — compact */
    .map-table tbody td.map-date {
        flex: 0 0 54px;
        min-width: 54px;
        max-width: 54px;
        font-size: 0.7rem;
        color: var(--map-text-muted);
        text-align: center;
        justify-content: center;
        line-height: 1.2;
        white-space: normal;
        word-break: break-word;
    }

    /* Home team — left aligned, truncated */
    .map-table tbody td.map-team-home {
        flex: 1 1 0;
        min-width: 0;
        text-align: right;
        justify-content: flex-end;
        font-size: 0.8rem;
        font-weight: 600;
        width: auto;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Score badge — fixed center */
    .map-table tbody td.map-score {
        flex: 0 0 auto;
        width: auto;
        min-width: 72px;
        text-align: center;
        justify-content: center;
    }
    .map-score-badge {
        font-size: 0.78rem;
        padding: 4px 8px;
        white-space: nowrap;
    }

    /* Away team — right aligned, truncated */
    .map-table tbody td.map-team-away {
        flex: 1 1 0;
        min-width: 0;
        text-align: left;
        justify-content: flex-start;
        font-size: 0.8rem;
        font-weight: 600;
        width: auto;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Overall Stats Mobile ── */
    .map-stat-header {
        display: flex;
        justify-content: space-between;
        padding: 12px;
        font-size: 0.85rem;
    }
    .map-stat-center-name { display: none; }

    .map-stat-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 16px 12px;
    }
    .map-stat-label {
        order: -1;
        width: 100%;
        margin: 0 0 10px 0;
        background: var(--map-bg-tertiary);
        border: none;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    .map-stat-home,
    .map-stat-away {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }
    .map-stat-home::before {
        content: "Ev:";
        color: var(--map-text-muted);
        font-size: 0.8rem;
        margin-right: 10px;
    }
    .map-stat-away::before {
        content: "Dep:";
        color: var(--map-text-muted);
        font-size: 0.8rem;
        margin-right: 10px;
    }

    .map-progress-wrap {
        width: 60%;
        margin-top: 0;
    }
    .map-progress-home,
    .map-progress-away {
        justify-content: flex-end;
    }
    .map-progress-home .map-progress-fill { float: left; }

    /* ── Prediction Box ── */
    .map-prediction-box {
        padding: 16px 12px;
    }
    .map-match-meta {
        gap: 10px;
        font-size: 0.78rem;
    }
    .map-section-title {
        font-size: 0.9rem;
        padding: 12px 14px;
    }
}
