/* Prediction market catalogue */

:root {
    --events-card-height: 180px;
    --events-gap: 12px;
    --events-positive-bg: rgba(24, 201, 116, .12);
    --events-negative-bg: rgba(228, 79, 85, .11);
}

.pe-page {
    width: min(var(--pm-shell-width), calc(100% - (var(--pm-shell-gutter) * 2)));
    margin: 0 auto;
    padding: 22px 0 64px;
}

.pe-page a {
    color: inherit;
    text-decoration: none;
}

.pe-shell {
    display: grid;
    grid-template-columns: 176px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.pe-shell--sports {
    grid-template-columns: 176px minmax(0, 1fr) 292px;
}

.pe-sidebar {
    position: sticky;
    top: 106px;
    display: grid;
    max-height: calc(100vh - 124px);
    gap: 4px;
    overflow-y: auto;
    scrollbar-width: none;
}

.pe-sidebar::-webkit-scrollbar {
    display: none;
}

.pe-side-section {
    display: grid;
    gap: 2px;
    margin-bottom: 12px;
}

.pe-side-kicker {
    margin: 10px 10px 5px;
    color: var(--pm-text-muted);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.pe-side-item {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    min-height: 35px;
    padding: 0 9px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--pm-text-secondary);
    align-items: center;
    gap: 8px;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    transition: color var(--pm-duration-fast) ease,
                background-color var(--pm-duration-fast) ease;
}

.pe-sidebar:not(.pe-sidebar--icons) .pe-side-item {
    grid-template-columns: minmax(0, 1fr) auto;
}

.pe-side-item.is-active {
    background: var(--pm-green-soft);
    color: var(--pm-green);
    font-weight: var(--pm-weight-semibold);
}

@media (hover: hover) {
    .pe-side-item:not(.is-active):hover {
        background: var(--pm-surface-hover);
        color: var(--pm-text);
    }
}

.pe-side-icon {
    display: inline-grid;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: transparent;
    color: var(--pm-green);
    place-items: center;
    overflow: hidden;
}

.pe-side-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pe-side-icon svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pe-side-icon .pe-svg-color {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: none;
}

.pe-side-label {
    min-width: 0;
    overflow: hidden;
    font-weight: var(--pm-weight-medium);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pe-side-count {
    color: var(--pm-text-muted);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    font-variant-numeric: tabular-nums;
}

.pe-side-signal {
    display: inline-flex;
    width: 12px;
    height: 12px;
    gap: 1px;
    align-items: end;
    justify-content: center;
    color: var(--pm-green);
}

.pe-side-signal span {
    width: 2px;
    border-radius: 99px;
    background: currentColor;
}

.pe-side-signal span:nth-child(1) { height: 5px; opacity: .45; }
.pe-side-signal span:nth-child(2) { height: 8px; opacity: .7; }
.pe-side-signal span:nth-child(3) { height: 11px; }

.pe-main {
    min-width: 0;
}

.pe-head {
    display: flex;
    min-height: 40px;
    margin-bottom: 12px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.pe-title {
    margin: 0;
    color: var(--pm-text);
    font-size: 24px;
    font-weight: var(--pm-weight-semibold);
    line-height: 1.2;
}

.pe-actions {
    display: inline-flex;
    gap: 6px;
}

.pe-icon-btn {
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--pm-text-secondary);
    place-items: center;
    cursor: pointer;
    transition: background-color var(--pm-duration-fast) ease,
                color var(--pm-duration-fast) ease;
}

.pe-icon-btn svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (hover: hover) {
    .pe-icon-btn:hover {
        background: var(--pm-surface-hover);
        color: var(--pm-text);
    }
}

.pe-search {
    max-height: 0;
    margin-bottom: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-5px);
    transition: max-height 220ms var(--pm-ease-standard),
                margin-bottom 220ms var(--pm-ease-standard),
                opacity var(--pm-duration-normal) ease,
                transform 220ms var(--pm-ease-standard);
}

.pe-search.is-open {
    max-height: 48px;
    margin-bottom: 12px;
    opacity: 1;
    transform: translateY(0);
}

.pe-search-box {
    display: flex;
    height: 40px;
    border: 1px solid var(--pm-line);
    border-radius: 10px;
    background: var(--pm-control-bg);
    align-items: center;
    transition: border-color var(--pm-duration-fast) ease,
                background-color var(--pm-duration-fast) ease;
}

.pe-search-box:focus-within {
    border-color: var(--pm-green-border);
    background: var(--pm-surface-raised);
}

.pe-search-box > svg {
    width: 16px;
    height: 16px;
    margin-left: 12px;
    color: var(--pm-text-muted);
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.pe-search-input {
    min-width: 0;
    height: 100%;
    padding: 0 10px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--pm-text);
    font-size: 12px;
    flex: 1;
}

.pe-search-input::-webkit-search-cancel-button,
.pe-search-input::-webkit-search-decoration {
    display: none;
    appearance: none;
}

.pe-search-input::placeholder {
    color: var(--pm-text-muted);
}

.pe-search-clear {
    display: grid;
    width: 28px;
    height: 28px;
    margin-right: 6px;
    padding: 6px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--pm-text-muted);
    opacity: 0;
    place-items: center;
    pointer-events: none;
    cursor: pointer;
}

.pe-side-item[hidden] {
    display: none;
}

.pe-search.has-value .pe-search-clear {
    opacity: 1;
    pointer-events: auto;
}

.pe-tabs {
    display: flex;
    min-height: 36px;
    margin: 0 0 12px;
    gap: 3px;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
}

.pe-tabs::-webkit-scrollbar {
    display: none;
}

.pe-tab {
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--pm-text-muted);
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--pm-duration-fast) ease,
                color var(--pm-duration-fast) ease;
}

.pe-tab.is-active {
    background: var(--pm-green);
    color: var(--pm-text-on-brand);
}

@media (hover: hover) {
    .pe-tab:not(.is-active):hover {
        background: var(--pm-surface-hover);
        color: var(--pm-text-secondary);
    }
}

[data-pe-content] {
    position: relative;
    min-height: var(--events-card-height);
}

[data-pe-content].is-refreshing > :not(.pe-refresh-overlay) {
    opacity: .38;
    pointer-events: none;
}

.pe-grid,
.pe-loading {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--events-gap);
}

.pe-card {
    display: flex;
    min-width: 0;
    min-height: var(--events-card-height);
    padding: 13px 14px 11px;
    border: 1px solid var(--pm-line-soft);
    border-radius: 12px;
    background: var(--pm-surface);
    box-shadow: var(--pm-shadow-card);
    color: var(--pm-text);
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    transition: transform var(--pm-duration-normal) var(--pm-ease-standard),
                border-color var(--pm-duration-normal) ease,
                background-color var(--pm-duration-normal) ease;
}

html.is-dark .pe-card,
body.is-dark .pe-card {
    background: #1a1f23;
}

@media (hover: hover) {
    .pe-card:hover {
        border-color: var(--pm-line-strong);
        background: var(--pm-surface-raised);
        transform: translateY(-2px);
    }

    html.is-dark .pe-card:hover,
    body.is-dark .pe-card:hover {
        background: #1d2327;
    }
}

.pe-card__head {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 9px;
    min-height: 36px;
    align-items: start;
}

.pe-card__icon {
    display: block;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: contain;
}

.pe-card__title {
    display: -webkit-box;
    min-width: 0;
    margin: 1px 0 0;
    overflow: hidden;
    color: var(--pm-text);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.pe-ring {
    position: relative;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
}

.pe-ring svg {
    width: 42px;
    height: 42px;
    transform: rotate(-90deg);
}

.pe-ring circle {
    fill: none;
    stroke-width: 3.2;
}

.pe-ring__track { stroke: var(--pm-control-bg); }
.pe-ring__fill { stroke: var(--pm-green); stroke-linecap: round; transition: stroke-dasharray 420ms var(--pm-ease-standard); }

.pe-ring__txt {
    position: absolute;
    inset: 0;
    display: flex;
    color: var(--pm-text);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    line-height: 1;
}

.pe-ring__txt span {
    margin-top: 2px;
    color: var(--pm-text-muted);
    font-size: 10px;
    font-weight: var(--pm-weight-medium);
}

.pe-list {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.pe-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px auto;
    min-height: 34px;
    gap: 7px;
    align-items: center;
}

.pe-row__main {
    display: flex;
    min-width: 0;
    gap: 7px;
    align-items: center;
}

.pe-row__flag {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: transparent;
    flex: 0 0 24px;
    object-fit: contain;
}

.pe-row__label {
    min-width: 0;
    overflow: hidden;
    color: var(--pm-text-secondary);
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pe-row__pct {
    color: var(--pm-text);
    font-size: 13px;
    font-weight: var(--pm-weight-semibold);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pe-row__actions {
    display: flex;
    gap: 5px;
}

.pe-chip {
    display: inline-flex;
    min-width: 38px;
    height: 28px;
    padding: 0 9px;
    border-radius: 7px;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    cursor: pointer;
}

.pe-chip--yes { background: var(--events-positive-bg); color: var(--pm-green); }
.pe-chip--no { background: var(--events-negative-bg); color: var(--pm-red); }

.pe-card__buttons {
    display: grid;
    gap: 7px;
    margin-top: auto;
}

.pe-btn {
    display: flex;
    min-width: 0;
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    line-height: 1;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.pe-btn--yes { background: var(--events-positive-bg); color: var(--pm-green); }
.pe-btn--no { background: var(--events-negative-bg); color: var(--pm-red); }
.pe-btn--mid { background: var(--pm-control-bg); color: var(--pm-text-secondary); }

.pe-foot {
    display: flex;
    min-height: 18px;
    margin-top: auto;
    color: var(--pm-text-muted);
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
}

.pe-foot__left {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pe-foot__icons {
    display: inline-flex;
    gap: 8px;
}

.pe-foot__icons svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
}

.pe-live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 5px;
    border-radius: 50%;
    background: var(--pm-red);
    box-shadow: 0 0 0 3px var(--pm-red-soft);
}

/* Sports list */

.pe-sports-live,
.pe-starting-list {
    display: grid;
    gap: 10px;
}

.pe-section-title {
    margin: 22px 0 10px;
    color: var(--pm-text);
    font-size: 22px;
    font-weight: var(--pm-weight-semibold);
    line-height: 1.2;
}

.pe-match {
    display: grid;
    padding: 13px 14px;
    border: 1px solid var(--pm-line-soft);
    border-radius: 12px;
    background: var(--pm-surface);
    gap: 10px;
    transition: border-color var(--pm-duration-normal) ease,
                background-color var(--pm-duration-normal) ease;
}

html.is-dark .pe-match,
body.is-dark .pe-match {
    background: #1a1f23;
}

@media (hover: hover) {
    .pe-match:hover {
        border-color: var(--pm-line-strong);
        background: var(--pm-surface-raised);
    }
}

.pe-match__meta {
    display: flex;
    gap: 8px;
    color: var(--pm-text-muted);
    align-items: center;
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
}

.pe-match__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 12px;
    align-items: center;
}

.pe-match__teams {
    display: grid;
    gap: 7px;
}

.pe-match__team {
    display: flex;
    min-width: 0;
    gap: 8px;
    color: var(--pm-text-secondary);
    align-items: center;
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
}

.pe-match__price-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
}

.pe-odds {
    display: flex;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    background: var(--pm-control-bg);
    color: var(--pm-text-secondary);
    align-items: center;
    justify-content: space-between;
    gap: 7px;
    overflow: hidden;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    white-space: nowrap;
    cursor: pointer;
}

.pe-odds--team { background: var(--pe-team-bg, var(--events-positive-bg)); color: var(--pe-team-color, var(--pm-green)); }
.pe-odds--blue { background: rgba(78, 142, 232, .16); color: var(--pm-blue); }
.pe-odds--orange { background: rgba(232, 179, 65, .16); color: var(--pm-amber); }
.pe-odds--draw { background: var(--pm-control-bg); color: var(--pm-text-secondary); }

.pe-odds__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pe-odds__price {
    margin-left: auto;
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}

/* Compact trade companion */

.pe-trade-card {
    position: sticky;
    top: 106px;
    padding: 16px;
    border: 1px solid var(--pm-line-soft);
    border-radius: 14px;
    background: var(--pm-surface);
    box-shadow: var(--pm-shadow-card);
}

html.is-dark .pe-trade-card,
body.is-dark .pe-trade-card {
    background: #1a1f23;
}

.pe-trade-card[data-event-link] {
    cursor: pointer;
}

.pe-trade-card__head {
    display: flex;
    min-width: 0;
    margin-bottom: 12px;
    gap: 9px;
    align-items: center;
}

.pe-trade-card__head img {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    object-fit: cover;
}

.pe-trade-card__title {
    display: -webkit-box;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--pm-text);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.pe-trade-card__tabs {
    display: flex;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--pm-line-soft);
    justify-content: space-between;
}

.pe-trade-card__tabs span {
    padding-bottom: 8px;
    color: var(--pm-text-muted);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
}

.pe-trade-card__tabs span:first-child {
    border-bottom: 2px solid var(--pm-green);
    color: var(--pm-text);
}

.pe-trade-card__buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.pe-trade-card__buttons button {
    min-width: 0;
    height: 46px;
    border: 0;
    border-radius: 9px;
    overflow: hidden;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.pe-trade-card__buttons button:first-child { background: var(--pm-green); color: var(--pm-text-on-brand); }
.pe-trade-card__buttons button:last-child { background: var(--events-negative-bg); color: var(--pm-red); }

.pe-trade-card__amount {
    display: grid;
    height: 76px;
    color: var(--pm-text-disabled);
    place-items: center;
    font-size: 34px;
    font-weight: var(--pm-weight-medium);
}

.pe-trade-card__submit {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 9px;
    background: var(--pm-green);
    color: var(--pm-text-on-brand);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    cursor: pointer;
}

/* Loading */

.pe-refresh-overlay {
    position: absolute;
    z-index: 4;
    inset: 0;
    opacity: .62;
    pointer-events: none;
    animation: eventsFadeIn var(--pm-duration-fast) ease both;
}

.pe-append-loader {
    display: flex;
    min-height: 52px;
    color: var(--pm-text-muted);
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
}

.pe-append-loader::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid var(--pm-line);
    border-top-color: var(--pm-green);
    border-radius: 50%;
    animation: eventsSpin .72s linear infinite;
}

.pe-skeleton {
    position: relative;
    min-height: var(--events-card-height);
    border-radius: 12px;
    background: var(--pm-surface-subtle);
    overflow: hidden;
}

.pe-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 22%, rgba(255, 255, 255, .20) 42%, transparent 62%);
    transform: translateX(-100%);
    animation: eventsSkeleton 1.25s ease-in-out infinite;
}

html.is-dark .pe-skeleton::after,
body.is-dark .pe-skeleton::after {
    background: linear-gradient(105deg, transparent 22%, rgba(255, 255, 255, .035) 42%, transparent 62%);
}

.pe-card.is-entering,
.pe-match.is-entering {
    animation: eventsCardIn 420ms var(--pm-ease-emphasized) both;
    animation-delay: var(--pe-enter-delay, 0ms);
}

.pe-empty {
    display: none;
    padding: 36px 20px;
    color: var(--pm-text-muted);
    font-size: 12px;
    text-align: center;
}

[data-pe-content] [data-card-market] {
    cursor: pointer;
}

[data-pe-content] [data-card-probability].is-live-tick,
[data-pe-content] .pe-ring.is-live-tick .pe-ring__txt {
    animation: eventsLiveTick 520ms var(--pm-ease-emphasized);
}

[data-pe-content] [data-card-probability].is-live-up { color: var(--pm-green); }
[data-pe-content] [data-card-probability].is-live-down { color: var(--pm-red); }

@keyframes eventsSpin { to { transform: rotate(360deg); } }
@keyframes eventsFadeIn { from { opacity: 0; } to { opacity: .62; } }
@keyframes eventsSkeleton { to { transform: translateX(100%); } }
@keyframes eventsCardIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes eventsLiveTick {
    0%, 100% { transform: scale(1); }
    46% { transform: scale(1.06); }
}

@media (max-width: 1220px) {
    .pe-shell--sports {
        grid-template-columns: 164px minmax(0, 1fr) 270px;
        gap: 16px;
    }

    .pe-grid,
    .pe-loading {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1040px) {
    .pe-shell,
    .pe-shell--sports {
        grid-template-columns: 1fr;
    }

    .pe-sidebar {
        position: static;
        display: flex;
        max-height: none;
        margin-inline: calc(var(--pm-shell-gutter) * -1);
        padding-inline: var(--pm-shell-gutter);
        padding-bottom: 4px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .pe-side-section {
        display: contents;
    }

    .pe-side-kicker {
        display: none;
    }

    .pe-side-item {
        min-width: max-content;
        flex: 0 0 auto;
    }

    .pe-trade-card {
        position: static;
        display: none;
    }
}

@media (max-width: 780px) {
    :root {
        --events-card-height: 176px;
    }

    .pe-page {
        padding-top: 16px;
    }

    .pe-grid,
    .pe-loading {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pe-match__body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .pe-title {
        font-size: 22px;
    }

    .pe-grid,
    .pe-loading {
        grid-template-columns: 1fr;
    }

    .pe-tabs {
        margin-inline: calc(var(--pm-shell-gutter) * -1);
        padding-inline: var(--pm-shell-gutter);
    }

    .pe-match__price-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pe-card,
    .pe-match,
    .pe-refresh-overlay,
    .pe-append-loader,
    .pe-skeleton,
    .pe-ring__fill {
        animation: none;
        transition: none;
        transform: none;
    }
}
