/* ============================================
   Event Detail Page Styles
   ============================================ */

.event-detail-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}



/* ============================================
   HEADER ROW (Grid Layout)
   ============================================ */
.single-event-header-grid {
    display: grid;
    /* Columns: Event | Category | Vol | OI | Sources */
    grid-template-columns: minmax(250px, 3.5fr) minmax(80px, 0.8fr) minmax(80px, 0.6fr) minmax(80px, 0.6fr) minmax(90px, 0.8fr);
    gap: 16px;
    align-items: center;
    padding: 20px 24px;
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin-bottom: 32px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

/* Force right alignment for data cells in the header */
.single-event-header-grid .volume-cell {
    justify-content: flex-end;
    text-align: right;
    width: 100%;
}

.event-title-cell h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
    line-height: 1.3;
    margin: 0;
}

.event-description {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-top: 8px;
    line-height: 1.5;
    font-weight: 400;
}

/* Reusing .volume-cell, .source-links from styles.css */
.single-event-header-grid .source-links {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Right align in column mode */
    width: 100%;
}

/* Label Header Row */
.single-event-header-labels {
    display: grid;
    /* Columns: Event | Category | Vol | OI | Sources */
    grid-template-columns: minmax(250px, 3.5fr) minmax(80px, 0.8fr) minmax(80px, 0.6fr) minmax(80px, 0.6fr) minmax(90px, 0.8fr);
    gap: 16px;
    align-items: center;
    padding: 12px 24px;
    margin-bottom: 0;
    font-size: 11px;
    font-weight: 700;
    /* text-transform: uppercase; removed */
    letter-spacing: 0.8px;
    color: var(--color-text-secondary);
    background-color: #fafafa;
    border: 1px solid var(--color-border);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.label-cell.align-right {
    text-align: right;
}

.label-cell.align-center {
    text-align: center;
}

/* ============================================
   MARKETS GRID LAYOUT
   ============================================ */

.markets-section {
    position: relative;
}

.markets-section h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 12px;
}

/* Grid Definition: Market | Yes | Vol | OI | Sources | Status */
.markets-grid-header,
.market-row-grid {
    display: grid;
    /* Columns matched to events page: Market(2.5fr) ODDS(1.1fr) Vol(0.7fr) OI(0.7fr) Result(0.7fr) ViewSources(0.8fr) */
    grid-template-columns: minmax(180px, 2.5fr) minmax(90px, 1.1fr) minmax(70px, 0.7fr) minmax(70px, 0.7fr) minmax(80px, 0.7fr) minmax(110px, 0.8fr);
    gap: 16px;
    align-items: center;
    padding: 12px 16px;
    width: 100%;
}

/* Header Styles */
.markets-grid-header {
    background-color: #fafafa;
    border: 1px solid var(--color-border);
    border-radius: 8px 8px 0 0;
    font-size: 11px;
    font-weight: 600;
    /* text-transform: uppercase; removed */
    letter-spacing: 0.8px;
    color: var(--color-text-secondary);
    position: sticky;
    top: 72px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-cell {
    white-space: nowrap;
}

.header-cell.align-right {
    text-align: right;
}

.header-cell.align-center {
    text-align: center;
}

/* Row Styles */
.market-row-wrapper {
    display: block;
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    border-top: none;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.1s ease;
}

.market-row-wrapper:last-child {
    border-radius: 0 0 8px 8px;
}

.market-row-wrapper:hover {
    background-color: #f8fafc;
}

/* Market Name Cell */
.market-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.market-closed-badge {
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
    background-color: #f3f4f6;
    border-radius: 4px;
}

/* Price Cells */
.price-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* No gap needed here as pill-wrapper handles it */
}

.pill-wrapper {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
}

/* Stacked Sub-Pills */
.sub-price-row {
    display: flex;
    flex-direction: column;
    /* Stack vertical */
    gap: 2px;
    /* Tiny gap between them */
    margin-left: 6px;
}

.sub-price {
    display: flex;
    gap: 3px;
}

.sub-source {
    opacity: 0.7;
}

.sub-val {
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
}

/* Volume Cell */
.volume-cell {
    text-align: right;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Metric Wrapper (for vol/OI with sub-breakdowns) */
.metric-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.metric-wrapper .sub-price-row {
    margin-left: 0;
}


/* Result Pill and Placeholder */
.col-status {
    text-align: right;
    display: flex;
    justify-content: flex-end;
}

.result-placeholder {
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
}

/* Sources Button Cell */
.col-sources-btn {
    text-align: right;
}

.result-pill {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-yes {
    background-color: #065f46;
    color: #ffffff;
}

.result-no {
    background-color: #991b1b;
    color: #ffffff;
}

.mobile-market-metrics {
    display: none;
}

/* Hide mobile header on desktop */
.source-drawer-mobile-header {
    display: none;
}


/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1200px) {

    /* Hide the top header labels on mobile */
    .single-event-header-labels {
        display: none !important;
    }

    .single-event-header-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 16px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        border-radius: 8px;
        border-top: 1px solid var(--color-border);
    }

    .event-title-cell h1 {
        font-size: 18px;
        text-align: center;
        margin-bottom: 8px;
    }

    .event-description {
        text-align: center;
        font-size: 13px;
        margin-bottom: 4px;
    }

    /* Hide desktop table cells explicitly */
    .single-event-header-grid>.category-cell,
    .single-event-header-grid>.volume-cell,
    .single-event-header-grid>.source-links {
        display: none !important;
    }

    /* Hide category cell on mobile (shown in mobile-metrics instead) */
    .single-event-header-grid>.category-cell {
        display: none !important;
    }

    /* Show mobile metrics - matches all events view exactly */
    .mobile-metrics {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        gap: 16px;
        flex-wrap: nowrap;
        width: auto;
        align-self: center;
        box-sizing: border-box;
        background-color: transparent;
        padding: 10px 0 0 0;
        border-top: 1px solid var(--color-border);
        margin-top: 4px;
    }

    .mobile-metric-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        flex: 0 0 auto;
    }

    .mobile-label {
        font-size: 9px;
        font-weight: 600;
        /* text-transform: uppercase; removed */
        letter-spacing: 0.3px;
        color: var(--color-text-muted);
    }

    .mobile-value {
        font-size: 12px;
        font-weight: 600;
        color: var(--color-text);
    }

    /* Sources on the right, stacked vertically */
    .mobile-metrics .source-links {
        display: flex !important;
        flex-direction: column;
        gap: 4px;
        align-items: flex-end;
        margin-left: auto;
    }
}

@media (max-width: 1200px) {
    .event-detail-page {
        padding: 16px;
    }

    /* MARKETS LIST MOBILE */

    /* Hide header row */
    .markets-grid-header {
        display: none !important;
    }

    /* Card Layout for Market Row */
    .market-row-wrapper {
        border: 1px solid var(--color-border);
        border-radius: 8px;
        margin-bottom: 10px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
        background: var(--color-white);
    }

    .market-row-grid {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        padding: 12px 14px;
        gap: 0;
    }

    /* === Market Title - Centered at top, full width === */
    .col-market {
        order: 1;
        flex: 0 0 100%;
        text-align: center;
        padding: 0;
        margin-bottom: 10px;
    }

    .market-title {
        font-size: 14px;
        font-weight: 600;
        white-space: normal;
        text-align: center;
        display: block;
        -webkit-line-clamp: unset;
        line-clamp: unset;
    }

    .market-closed-badge {
        display: block;
        margin: 6px auto 0;
        width: fit-content;
    }

    /* === Metrics (ODDS, VOL, OI) - Appear in horizontal row === */
    .col-yes {
        order: 2;
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 12px;
        margin: 0;
        border: none;
    }

    .col-yes:empty {
        display: none !important;
    }

    .col-yes::before {
        content: "Odds";
        font-size: 9px;
        font-weight: 700;
        color: #9ca3af;
        /* text-transform: uppercase; removed */
        letter-spacing: 0.5px;
        margin-bottom: 4px;
    }

    .col-vol {
        order: 3;
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 12px;
        margin: 0;
        border: none;
    }

    .col-vol:empty {
        display: none !important;
    }

    .col-vol::before {
        content: "24h Vol";
        font-size: 9px;
        font-weight: 700;
        color: #9ca3af;
        /* text-transform: uppercase; removed */
        letter-spacing: 0.5px;
        margin-bottom: 4px;
    }

    .col-oi {
        order: 4;
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 12px;
        margin: 0;
        border: none;
    }

    .col-oi:empty {
        display: none !important;
    }

    .col-oi::before {
        content: "Open Int";
        font-size: 9px;
        font-weight: 700;
        color: #9ca3af;
        /* text-transform: uppercase; removed */
        letter-spacing: 0.5px;
        margin-bottom: 4px;
    }

    /* === Result/Status for Closed Markets === */
    .col-status {
        order: 5;
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 12px;
        margin: 0;
        border: none;
    }

    .col-status:empty {
        display: none !important;
    }

    .col-status::before {
        content: "Result";
        font-size: 9px;
        font-weight: 700;
        color: #9ca3af;
        /* text-transform: uppercase; removed */
        letter-spacing: 0.5px;
        margin-bottom: 4px;
    }

    /* Sources button - full width below */
    .col-sources-btn {
        order: 10;
        flex: 0 0 100%;
        display: flex;
        justify-content: center;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--color-border);
    }

    .col-sources-btn:empty {
        display: none !important;
        border-top: none;
        margin-top: 0;
        padding-top: 0;
    }

    /* Pill styling for mobile */
    .pill-wrapper {
        justify-content: center;
        width: auto;
    }

    .price-cell {
        align-items: center;
    }

    .volume-cell {
        font-size: 13px;
        font-weight: 600;
        color: var(--color-text);
        text-align: center;
    }

    /* Result pill */
    .result-pill {
        margin-top: 0;
        padding: 3px 10px;
        font-size: 11px;
    }

    .result-placeholder {
        display: none;
    }

    /* === Mobile Source Drawer Improvements === */
    /* Centered grid layout for drawer */
    .source-drawer {
        display: grid;
        grid-template-columns: auto auto auto auto;
        justify-content: center;
        gap: 8px 16px;
        padding: 12px;
        width: 100%;
    }

    .source-drawer-mobile-header {
        display: contents;
    }

    /* Force rows to be part of the parent grid */
    .source-drawer-row {
        display: contents;
    }

    /* Headers */
    .mobile-header-label {
        font-size: 10px;
        font-weight: 600;
        color: #9ca3af;
        /* text-transform: uppercase; removed */
        text-align: left;
        margin-bottom: 4px;
        align-self: end;
    }

    /* Hide desktop-only columns (empty spans) in drawer */
    .source-drawer-row>span:nth-child(5),
    .source-drawer-row>span:nth-child(6),
    .source-drawer-mobile-header>span:nth-child(5),
    .source-drawer-mobile-header>span:nth-child(6) {
        display: none;
    }

    /* Left align values */
    .drawer-val {
        text-align: left !important;
    }

}