/**
 * Al-Hadaf Smart Embeds & Match Hub Universal Stylesheet
 * 
 * Works 100% autonomously across Blogger, WordPress, and any custom web platform.
 * Gracefully inherits existing Blogger CSS variables while providing rock-solid modern fallbacks.
 *
 * @version 2.2.0
 * @author Al-Hadaf Architecture Team
 */

@import url('https://fonts.googleapis.com/css2?family=Changa:wght@400;500;600;700;800&display=swap');

:root {
    --BG: #059669;
    --BG2: #ffffff;
    --BP: #f8fafc;
    --CO: #1e293b;
    --GD: #f1f5f9;
    --BORDER: #e2e8f0;
    --alh-font: 'Changa', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ====================================================
   1. Interactive Date Switcher & Navigation Bar
==================================================== */
.alhadaf-schedule-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--BG2, #ffffff);
    border: 1px solid var(--BORDER, #e2e8f0);
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    font-family: var(--alh-font);
    direction: rtl;
    flex-wrap: wrap;
    gap: 10px;
}

.alhadaf-nav-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.alhadaf-nav-buttons::-webkit-scrollbar {
    display: none;
}

.alhadaf-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    color: var(--CO, #334155);
    background: var(--GD, #f1f5f9);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}

.alhadaf-nav-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.alhadaf-nav-btn.active {
    background: var(--BG, #059669) !important;
    color: #ffffff !important;
    border-color: var(--BG, #059669);
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.alhadaf-nav-btn .live-dot-pulse {
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
    display: inline-block;
    animation: alhPulse 1.2s infinite ease-in-out;
}

.alhadaf-nav-btn.active .live-dot-pulse {
    background-color: #ffffff;
}

.alhadaf-calendar-picker-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.alhadaf-cal-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--GD, #f1f5f9);
    border: 1px solid var(--BORDER, #cbd5e1);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--CO, #334155);
    cursor: pointer;
    transition: all 0.2s ease;
}

.alhadaf-cal-label:hover {
    background: #e2e8f0;
}

.alhadaf-custom-date-input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: var(--CO, #1e293b);
    cursor: pointer;
    outline: none;
    direction: ltr;
}

/* ====================================================
   2. Match Cards Container & Layout
==================================================== */
.alhadaf-embed-matches {
    direction: rtl;
    font-family: var(--alh-font);
    width: 100%;
}

.containerMatch {
    position: relative;
    background: var(--BG2, #ffffff);
    border: 1px solid var(--BORDER, #e2e8f0);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    overflow: hidden;
    font-family: var(--alh-font);
}

.containerMatch:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
    border-color: #cbd5e1;
}

.containerMatch a {
    text-decoration: none !important;
    color: inherit !important;
    display: block;
}

.containerMatch a .Match {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 6px 0;
}

.containerMatch a .Match .fareq {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    min-width: 0;
}

.containerMatch a .Match .fareq .Imagee {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.containerMatch a .Match .fareq .Imagee img,
.containerMatch a .Match .fareq img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
    transition: transform 0.2s ease;
}

.containerMatch:hover a .Match .fareq img {
    transform: scale(1.06);
}

.containerMatch a .Match .fareq .asm {
    font-size: 15px;
    font-weight: 700;
    color: var(--CO, #1e293b);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
    margin: 0;
}

/* Center Score & Match Status */
.containerMatch a .Match .Nateja {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    text-align: center;
}

.containerMatch a .Match .matchHour {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: var(--CO, #0f172a);
    margin: 0 0 6px 0 !important;
    direction: ltr;
    letter-spacing: 0.5px;
}

.containerMatch a .Match .natej {
    font-size: 26px !important;
    font-weight: 800 !important;
    color: var(--CO, #0f172a);
    margin: 0 0 6px 0 !important;
    direction: ltr;
    letter-spacing: 4px;
}

/* ====================================================
   3. Match Status Badges & Animations
==================================================== */
.Match .matchDate {
    font-size: 12px !important;
    font-weight: 700 !important;
    padding: 6px 14px !important;
    border-radius: 50px !important;
    color: #ffffff !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    transition: all 0.25s ease-in-out;
    white-space: nowrap;
}

/* Not Started */
.containerMatch.Not .matchDate,
.Match .matchDate.not {
    background: #52616b !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Starting Soon (< 15 mins) */
.containerMatch.Soon .matchDate,
.Match .matchDate.soon {
    background: #e67e22 !important;
    animation: soonPulse 1.8s infinite;
}

/* Live Ongoing */
.containerMatch.Live .matchDate,
.Match .matchDate.live {
    background: #e74c3c !important;
    animation: livePulse 1.2s infinite ease-in-out;
}

.containerMatch.Live .matchDate::before,
.Match .matchDate.live::before {
    content: '';
    width: 7px;
    height: 7px;
    background-color: #ffffff;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
    animation: blinkDot 1s infinite alternate;
}

/* Half-Time Break (HT) */
.containerMatch .matchDate.ht,
.Match .matchDate.ht {
    background: #d97706 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.35);
}

/* Extra Time (ET) */
.containerMatch .matchDate.et,
.Match .matchDate.et {
    background: #7c3aed !important;
    color: #ffffff !important;
    animation: livePulse 1.2s infinite ease-in-out;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.35);
}
.containerMatch .matchDate.et::before,
.Match .matchDate.et::before {
    content: '';
    width: 7px;
    height: 7px;
    background-color: #ffffff;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
    animation: blinkDot 1s infinite alternate;
}

/* Penalty Shootout (PEN) */
.containerMatch .matchDate.pen,
.Match .matchDate.pen {
    background: #0891b2 !important;
    color: #ffffff !important;
    animation: livePulse 1.2s infinite ease-in-out;
    box-shadow: 0 2px 6px rgba(8, 145, 178, 0.35);
}
.containerMatch .matchDate.pen::before,
.Match .matchDate.pen::before {
    content: '';
    width: 7px;
    height: 7px;
    background-color: #ffffff;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
    animation: blinkDot 1s infinite alternate;
}

/* Stoppage / Added Minutes */
.containerMatch .matchDate.stoppage,
.Match .matchDate.stoppage {
    background: #b91c1c !important;
    color: #ffffff !important;
    animation: livePulse 0.9s infinite ease-in-out;
    box-shadow: 0 2px 6px rgba(185, 28, 28, 0.4);
}

/* Finished Match */
.containerMatch.End .matchDate,
.Match .matchDate.end {
    background: #2c3e50 !important;
    color: #ffffff !important;
    opacity: 0.95;
}

@keyframes livePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(231, 76, 60, 0);
        transform: scale(1.02);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
        transform: scale(1);
    }
}

@keyframes soonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

@keyframes blinkDot {
    0% { opacity: 0.2; }
    100% { opacity: 1; }
}

@keyframes alhPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Bottom Metadata Bar (League, Channel, Commentator) */
.containerMatch a ul {
    display: flex;
    align-items: center;
    justify-content: space-around;
    list-style: none;
    margin: 8px 0 0 0;
    padding: 8px 0 0 0;
    border-top: 1px dashed var(--BORDER, #f1f5f9);
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.containerMatch a ul li {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.containerMatch a ul li:first-child::before {
    content: '🏆 ';
}
.containerMatch a ul li:nth-child(2)::before {
    content: '📺 ';
}
.containerMatch a ul li:nth-child(3)::before {
    content: '🎙️ ';
}

/* ====================================================
   4. Loading & Empty Notice Elements
==================================================== */
.alhadaf-loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 14px;
    font-weight: 700;
    gap: 12px;
}

.spinner-ball {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--BG, #059669);
    border-radius: 50%;
    animation: alhSpin 0.8s linear infinite;
}

@keyframes alhSpin {
    to { transform: rotate(360deg); }
}

.alhadaf-empty-box {
    text-align: center;
    padding: 40px 20px;
    background: var(--BG2, #ffffff);
    border: 1px dashed var(--BORDER, #cbd5e1);
    border-radius: 12px;
    color: #64748b;
    font-size: 14px;
    font-weight: 700;
}

/* ====================================================
   5. Comprehensive Match Hub Styles (.kora-hub-wrap)
==================================================== */
.kora-hub-wrap {
    width: 100%;
    margin: 20px 0;
    font-family: var(--alh-font);
    background: var(--BG2, #ffffff);
    border: 1px solid var(--BORDER, #e2e8f0);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    direction: rtl;
}

/* Nav Bar */
.kh-nav-bar {
    display: flex;
    background: var(--GD, #f8fafc);
    padding: 8px;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    border-bottom: 1px solid var(--BORDER, #e2e8f0);
}
.kh-nav-bar::-webkit-scrollbar { display: none; }

.kh-btn {
    background: transparent;
    border: none !important;
    color: var(--CO, #334155);
    opacity: 0.8;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-family: inherit !important;
}
.kh-btn:hover {
    opacity: 1;
    background: #e2e8f0;
}
.kh-btn.active {
    background: var(--BG, #059669);
    color: #ffffff !important;
    opacity: 1;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

/* Content Body */
.kh-body {
    padding: 16px;
}
.kh-pane {
    display: none;
}
.kh-pane.active {
    display: block;
    animation: khFade 0.25s ease-in-out;
}
@keyframes khFade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Match Overview Grid */
.kh-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.kh-info-box {
    background: var(--BP, #f8fafc);
    border: 1px solid var(--BORDER, #e2e8f0);
    padding: 12px 14px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kh-badge-title {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}
.kh-badge-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--CO, #0f172a);
}

/* Events Timeline */
.kh-events-timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.kh-event-item {
    display: flex;
    align-items: center;
    background: var(--BP, #f8fafc);
    border: 1px solid var(--BORDER, #e2e8f0);
    padding: 10px 14px;
    border-radius: 8px;
    transition: background 0.15s ease;
}
.kh-event-item:hover {
    background: #f1f5f9;
}
.kh-min {
    width: 44px;
    font-weight: 800;
    font-size: 13px;
    color: var(--BG, #059669);
    direction: ltr;
}
.kh-event-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}
.kh-score {
    background: var(--BG, #059669);
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 800;
    direction: ltr;
}
.kh-act-icon { font-size: 16px; }
.kh-act-card {
    width: 11px;
    height: 15px;
    border-radius: 2px;
    display: inline-block;
}
.kh-act-card.yellow { background: #f59e0b; }
.kh-act-card.red { background: #ef4444; }
.kh-act-txt {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    font-weight: 700;
    color: var(--CO, #1e293b);
}
.kh-act-txt small {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
}
.kh-break {
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    padding: 8px;
    background: var(--GD, #f1f5f9);
    color: var(--CO, #334155);
    border-radius: 6px;
    margin: 4px 0;
}

/* Tactical Pitch */
.kh-pitch {
    position: relative;
    background: radial-gradient(circle, #2d5a27 0%, #1a3a16 100%);
    border-radius: 10px;
    min-height: 520px;
    overflow: hidden;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.pitch-marking.half-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.25);
}
.pitch-marking.center-spot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70px;
    height: 70px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
.pitch-marking.box-top {
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 55px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-top: none;
}
.pitch-marking.box-bottom {
    position: absolute;
    bottom: 0;
    left: 30%;
    right: 30%;
    height: 55px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-bottom: none;
}
.pitch-side {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.team-plan {
    background: rgba(0, 0, 0, 0.65);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    display: inline-block;
    margin-right: 8px;
    width: fit-content;
}
.team-plan.bottom { margin-top: 6px; }
.p-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.ply {
    position: relative;
    text-align: center;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
}
.p-num {
    width: 26px;
    height: 26px;
    line-height: 26px;
    background: #ffffff;
    color: #0f172a;
    border-radius: 50%;
    display: block;
    margin: 0 auto 4px;
    font-weight: 800;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.p-name {
    display: block;
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Match Statistics */
.kh-stats-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.kh-stat-row {
    background: var(--BP, #f8fafc);
    border: 1px solid var(--BORDER, #e2e8f0);
    padding: 10px 14px;
    border-radius: 8px;
}
.kh-stat-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--CO, #1e293b);
}
.kh-stat-bars {
    display: flex;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    overflow: hidden;
    gap: 2px;
}
.kh-stat-bar.home {
    background: var(--BG, #059669);
    transition: width 0.4s ease;
}
.kh-stat-bar.away {
    background: #3b82f6;
    transition: width 0.4s ease;
}

/* ====================================================
   6. Responsive Layout Breakpoints
==================================================== */
@media screen and (max-width: 640px) {
    .containerMatch a .Match .fareq .Imagee {
        width: 48px;
        height: 48px;
    }
    .containerMatch a .Match .fareq .asm {
        font-size: 13px;
        max-width: 95px;
    }
    .containerMatch a .Match .matchHour {
        font-size: 16px !important;
    }
    .containerMatch a .Match .natej {
        font-size: 22px !important;
        letter-spacing: 2px;
    }
    .Match .matchDate {
        font-size: 11px !important;
        padding: 5px 10px !important;
    }
    .containerMatch a ul li:nth-child(2) {
        display: none;
    }
    .alhadaf-schedule-nav {
        flex-direction: column;
        align-items: stretch;
    }
    .alhadaf-calendar-picker-wrap {
        justify-content: center;
    }
}
