/* AmarVote prediction markets — Kalshi-style UI
   Layered on top of style.css. Reuses AmarVote design tokens. */

:root {
    --predict-yes: #059669;
    --predict-no: #DC2626;
    --predict-yes-bg: #ECFDF5;
    --predict-no-bg: #FEF2F2;
    --predict-yes-border: #A7F3D0;
    --predict-no-border: #FECACA;
    --predict-chart-line: #2563EB;
    --ap-gold: #F59E0B;
    --ap-gold-bg: #FFFBEB;
    --predict-card-border: #E2E8F0;
    --predict-muted: #64748B;
    --predict-radius: 12px;
}

/* ---------- AP balance pill ---------- */

.ap-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ap-gold-bg);
    color: var(--ap-gold);
    border: 1px solid #FCD34D;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
}
.ap-pill::before {
    content: '◈';
    font-size: 1rem;
}

/* ---------- Hero ---------- */

.predict-hero {
    text-align: center;
    padding: 56px 16px 40px;
    border-bottom: 1px solid var(--predict-card-border);
    margin-bottom: 32px;
}
.predict-hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 12px;
    background: linear-gradient(135deg, #0F172A 0%, #2563EB 50%, #0EA5E9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.predict-hero p {
    font-size: 1.15rem;
    color: var(--predict-muted);
    max-width: 580px;
    margin: 0 auto 24px;
}
.predict-hero .cta-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- Category tabs ---------- */

.cat-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0 16px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--predict-card-border);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    min-height: 40px;
    border-radius: 999px;
    border: 1px solid var(--predict-card-border);
    background: white;
    color: #1E293B;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.cat-tab:hover {
    border-color: #2563EB;
    color: #2563EB;
}
.cat-tab.active {
    background: #0F172A;
    color: white;
    border-color: #0F172A;
}

/* ---------- Section headings ---------- */

.predict-section {
    margin-bottom: 40px;
}
.predict-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #0F172A;
}
.predict-section-title .count {
    font-size: 0.85rem;
    color: var(--predict-muted);
    font-weight: 500;
}

/* ---------- Market grid ---------- */

.market-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.market-card {
    background: white;
    border: 1px solid var(--predict-card-border);
    border-radius: var(--predict-radius);
    padding: 16px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.15s ease;
    position: relative;
}
.market-card:hover {
    border-color: #94A3B8;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}
.market-card.featured {
    border: 2px solid #FCD34D;
    background: linear-gradient(180deg, #FFFBEB 0%, white 30%);
}

.market-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #F1F5F9;
    color: #475569;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}
.sponsor-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--ap-gold-bg);
    color: var(--ap-gold);
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid #FCD34D;
}

.market-question {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
    color: #0F172A;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.price-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.price-btn {
    border: 1.5px solid;
    background: white;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: all 0.1s ease;
}
.price-btn .label { font-size: 0.75rem; }
.price-btn .price { font-size: 1.1rem; font-weight: 800; }

.price-btn.yes {
    color: var(--predict-yes);
    border-color: var(--predict-yes-border);
}
.price-btn.yes:hover, .price-btn.yes.active {
    background: var(--predict-yes);
    color: white;
    border-color: var(--predict-yes);
}
.price-btn.no {
    color: var(--predict-no);
    border-color: var(--predict-no-border);
}
.price-btn.no:hover, .price-btn.no.active {
    background: var(--predict-no);
    color: white;
    border-color: var(--predict-no);
}

.market-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--predict-muted);
    padding-top: 8px;
    border-top: 1px solid #F1F5F9;
}

/* ---------- Market detail page ---------- */

.market-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 32px;
    align-items: start;
}
@media (max-width: 900px) {
    .market-detail {
        grid-template-columns: 1fr;
    }
}

.market-detail-main h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 16px 0 8px;
    line-height: 1.3;
}
.market-detail-main .question-en {
    color: var(--predict-muted);
    font-size: 1rem;
    margin: 0 0 24px;
}

.market-stats-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 16px 0;
    border-top: 1px solid var(--predict-card-border);
    border-bottom: 1px solid var(--predict-card-border);
    margin-bottom: 24px;
}
.market-stat .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--predict-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}
.market-stat .stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0F172A;
}
.market-stat .stat-value.yes { color: var(--predict-yes); }
.market-stat .stat-value.no { color: var(--predict-no); }

.price-chart-wrap {
    background: white;
    border: 1px solid var(--predict-card-border);
    border-radius: var(--predict-radius);
    padding: 16px;
    margin-bottom: 24px;
}
.price-chart-wrap canvas { width: 100% !important; height: 200px !important; }

.market-section {
    background: white;
    border: 1px solid var(--predict-card-border);
    border-radius: var(--predict-radius);
    padding: 20px;
    margin-bottom: 16px;
}
.market-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px;
    color: #0F172A;
}
.market-section p, .market-section li {
    color: #334155;
    line-height: 1.6;
    font-size: 0.92rem;
}

.recent-trades {
    list-style: none;
    padding: 0;
    margin: 0;
}
.recent-trades li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #F1F5F9;
    font-size: 0.88rem;
}
.recent-trades li:last-child { border-bottom: none; }
.trader-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--avatar-color, #94A3B8);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.trade-side-yes { color: var(--predict-yes); font-weight: 600; }
.trade-side-no { color: var(--predict-no); font-weight: 600; }
.trade-when { color: var(--predict-muted); margin-left: auto; font-size: 0.78rem; }

/* ---------- Order ticket (right column / bottom sheet) ---------- */

.order-ticket {
    position: sticky;
    top: 80px;
    background: white;
    border: 1px solid var(--predict-card-border);
    border-radius: var(--predict-radius);
    padding: 20px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}
.order-ticket h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 16px;
}

.side-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
    background: #F1F5F9;
    padding: 4px;
    border-radius: 8px;
}
.side-toggle button {
    background: transparent;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    color: #475569;
    font-size: 0.95rem;
    transition: all 0.1s ease;
}
.side-toggle button.active.yes {
    background: var(--predict-yes);
    color: white;
}
.side-toggle button.active.no {
    background: var(--predict-no);
    color: white;
}

.ticket-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ticket-input {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--predict-card-border);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    box-sizing: border-box;
    margin-bottom: 8px;
}
.ticket-input:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.quick-amounts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}
.quick-amounts button {
    background: white;
    border: 1px solid var(--predict-card-border);
    padding: 6px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    color: #475569;
}
.quick-amounts button:hover {
    background: #F8FAFC;
    border-color: #2563EB;
    color: #2563EB;
}

.ticket-preview {
    background: #F8FAFC;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 0.88rem;
}
.ticket-preview .row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}
.ticket-preview .row strong { color: #0F172A; font-weight: 700; }
.ticket-preview .roi { color: var(--predict-yes); font-weight: 700; }

.btn-predict {
    width: 100%;
    background: linear-gradient(135deg, #2563EB 0%, #0EA5E9 100%);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.btn-predict:hover:not(:disabled) { opacity: 0.92; }
.btn-predict:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.balance-line {
    text-align: center;
    margin-top: 12px;
    color: var(--predict-muted);
    font-size: 0.85rem;
}
.balance-line strong { color: var(--ap-gold); font-weight: 700; }

.login-prompt {
    text-align: center;
    padding: 16px;
    background: #F8FAFC;
    border-radius: 8px;
    color: #475569;
}
.login-prompt a {
    color: #2563EB;
    font-weight: 700;
    text-decoration: none;
}

/* ---------- Portfolio ---------- */

.portfolio-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 32px;
}
.summary-card {
    background: white;
    border: 1px solid var(--predict-card-border);
    border-radius: var(--predict-radius);
    padding: 16px;
    text-align: center;
}
.summary-card .label {
    font-size: 0.78rem;
    color: var(--predict-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.summary-card .value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0F172A;
}
.summary-card .value.gold { color: var(--ap-gold); }
.summary-card .value.green { color: var(--predict-yes); }

.position-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.position-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    padding: 14px;
    background: white;
    border: 1px solid var(--predict-card-border);
    border-radius: 10px;
    align-items: center;
    text-decoration: none;
    color: inherit;
}
.position-row:hover {
    border-color: #94A3B8;
}
.position-row .question {
    font-weight: 600;
    color: #0F172A;
    font-size: 0.95rem;
}
.position-row .meta {
    font-size: 0.78rem;
    color: var(--predict-muted);
    margin-top: 2px;
}
.position-side {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
}
.position-side.yes { background: var(--predict-yes-bg); color: var(--predict-yes); }
.position-side.no { background: var(--predict-no-bg); color: var(--predict-no); }
.position-pnl {
    text-align: right;
    font-weight: 700;
}
.position-pnl.up { color: var(--predict-yes); }
.position-pnl.down { color: var(--predict-no); }

/* ---------- Login form ---------- */

.predict-auth-card {
    max-width: 440px;
    margin: 32px auto;
    background: white;
    border: 1px solid var(--predict-card-border);
    border-radius: var(--predict-radius);
    padding: 32px;
}
.predict-auth-card h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
    font-weight: 800;
    text-align: center;
}
.predict-auth-card .subtitle {
    text-align: center;
    color: var(--predict-muted);
    margin: 0 0 24px;
    font-size: 0.95rem;
}

/* ---------- Empty state ---------- */

.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--predict-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ---------- Mobile tweaks ---------- */

@media (max-width: 600px) {
    .predict-hero h1 { font-size: 1.8rem; }
    .predict-hero p { font-size: 1rem; }
    .market-detail-main h1 { font-size: 1.3rem; }
    .order-ticket {
        position: static;
        margin-top: 16px;
    }
    .market-grid { grid-template-columns: 1fr; }
}

/* Position rows stack on narrow phones — question full width, side+pnl on row 2 */
@media (max-width: 480px) {
    .position-row {
        grid-template-columns: 1fr auto;
        grid-template-areas: "q q" "side pnl";
        gap: 8px;
        padding: 12px;
    }
    .position-row > div:first-child { grid-area: q; min-width: 0; }
    .position-row .question { font-size: 0.92rem; line-height: 1.35; }
    .position-row .position-side { grid-area: side; justify-self: start; }
    .position-row .position-pnl { grid-area: pnl; }
    .portfolio-summary { grid-template-columns: repeat(2, 1fr); }
    .summary-card { padding: 12px; }
    .summary-card .value { font-size: 1.3rem; }
}

/* ---------- Banner / flash ---------- */

.predict-banner {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    color: #92400E;
    padding: 10px 16px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.88rem;
    margin-bottom: 24px;
    font-weight: 500;
}
.predict-banner.error { background: var(--predict-no-bg); color: var(--predict-no); }
.predict-banner.success { background: var(--predict-yes-bg); color: var(--predict-yes); }
