/*
  preview_widgets.css
  ===================
  Self-contained styles for the mini-app preview widgets on /scripts.
  Loaded as a second stylesheet after scripts_page.css.
  No external fonts, no CDN dependencies.
  System font stack throughout.
*/

/* ─── Base widget shell ──────────────────────────────────────────────────── */

.widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    margin: 4px 0 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    position: relative;
}

.widget-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #6b7280;
    margin: 0 0 14px;
}

.widget-subtitle {
    font-size: 0.82rem;
    color: #6b7280;
    margin: 0 0 12px;
}

.widget-footer {
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
    text-align: right;
}

/* ─── Lottery balls ──────────────────────────────────────────────────────── */

.ball-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 6px 0;
}

.lottery-ball {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    user-select: none;
}

/* Default — SA Lotto yellow/amber */
.lottery-ball {
    background: linear-gradient(145deg, #fde047, #f59e0b);
    color: #1f2937;
    text-shadow: none;
}

/* Bonus ball — green */
.lottery-ball.bonus {
    background: linear-gradient(145deg, #4ade80, #16a34a);
    color: #fff;
}

/* Powerball ball — orange-red */
.lottery-ball.powerball {
    background: linear-gradient(145deg, #fb923c, #ea580c);
    color: #fff;
}

/* Hot ball — red */
.lottery-ball.hot {
    background: linear-gradient(145deg, #f87171, #dc2626);
    color: #fff;
}

/* Cold ball — blue */
.lottery-ball.cold {
    background: linear-gradient(145deg, #60a5fa, #2563eb);
    color: #fff;
}

/* UK49s booster — purple */
.lottery-ball.booster {
    background: linear-gradient(145deg, #c084fc, #7c3aed);
    color: #fff;
}

/* Small badge label next to a special ball */
.ball-label {
    font-size: 0.72rem;
    color: #6b7280;
    font-style: italic;
    align-self: center;
}

.ball-divider {
    font-size: 1.2rem;
    color: #d1d5db;
    align-self: center;
    line-height: 1;
}

/* ─── Widget: latest_results ─────────────────────────────────────────────── */

.widget-latest .game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.widget-latest .game-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
}

.widget-latest .game-card-name {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #374151;
    margin: 0 0 2px;
}

.widget-latest .game-card-meta {
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0 0 10px;
}

/* ─── Widget: results_by_game ────────────────────────────────────────────── */

.widget-game .draw-header {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px;
}

.widget-game .draw-meta {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0 0 14px;
}

/* ─── Widget: uk49s ──────────────────────────────────────────────────────── */

.widget-uk49s {
    border-top: 4px solid #7c3aed;
}

.widget-uk49s .draw-header {
    font-size: 1rem;
    font-weight: 700;
    color: #5b21b6;
    margin: 0 0 4px;
}

.widget-uk49s .draw-meta {
    font-size: 0.8rem;
    color: #7c3aed;
    margin: 0 0 14px;
}

/* ─── Widget: hot_cold ───────────────────────────────────────────────────── */

.widget-hotcold .hc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.widget-hotcold .hc-column-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 500px) {
    .widget-hotcold .hc-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Widget: number_frequencies bar chart ───────────────────────────────── */

.widget-frequencies .freq-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
}

.widget-frequencies .freq-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(145deg, #fde047, #f59e0b);
    color: #1f2937;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.widget-frequencies .freq-bar-wrap {
    flex: 1;
    background: #f3f4f6;
    border-radius: 4px;
    height: 14px;
    overflow: hidden;
}

.widget-frequencies .freq-bar {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #fde047);
    border-radius: 4px;
    min-width: 4px;
    transition: none;
}

.widget-frequencies .freq-count {
    font-size: 0.78rem;
    color: #6b7280;
    min-width: 40px;
    text-align: right;
    white-space: nowrap;
}

/* ─── Widget: number_pairs ───────────────────────────────────────────────── */

.widget-pairs .pair-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
}

.widget-pairs .pair-row:last-child {
    border-bottom: none;
}

.widget-pairs .pair-arrow {
    font-size: 1rem;
    color: #d1d5db;
    flex-shrink: 0;
}

.widget-pairs .pair-freq {
    font-size: 0.78rem;
    color: #6b7280;
    margin-left: auto;
    white-space: nowrap;
}

/* ─── Widget: random_numbers ─────────────────────────────────────────────── */

.widget-random .lucky-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px;
}

.widget-random .lucky-tagline {
    font-size: 0.78rem;
    color: #9ca3af;
    margin: 10px 0 0;
    font-style: italic;
}

/* ─── Widget: text_to_lucky ──────────────────────────────────────────────── */

.widget-textlucky .input-box {
    display: inline-block;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 5px 10px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 0.85rem;
    color: #374151;
    margin-bottom: 10px;
    max-width: 100%;
    overflow-wrap: break-word;
}

.widget-textlucky .arrow-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.widget-textlucky .arrow-row .input-box {
    margin-bottom: 0;
}

.widget-textlucky .ttl-arrow {
    font-size: 1.2rem;
    color: #9ca3af;
    flex-shrink: 0;
}

/* ─── Widget: check_played ───────────────────────────────────────────────── */

.widget-check .check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
}

.widget-check .check-row-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    min-width: 55px;
    flex-shrink: 0;
}

.widget-check .result-banner {
    margin-top: 14px;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: center;
}

.widget-check .result-banner.win {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.widget-check .result-banner.loss {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.widget-check .match-detail {
    font-size: 0.8rem;
    font-weight: 400;
    margin-left: 6px;
    opacity: 0.8;
}

/* ─── Widget: bulk_check ─────────────────────────────────────────────────── */

.widget-bulk .bulk-header {
    font-size: 0.85rem;
    color: #374151;
    margin: 0 0 12px;
}

.widget-bulk .bulk-header strong {
    color: #111827;
}

.widget-bulk table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.widget-bulk th {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
    padding: 6px 10px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}

.widget-bulk td {
    padding: 8px 10px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    color: #374151;
}

.widget-bulk tr:last-child td {
    border-bottom: none;
}

.widget-bulk .bulk-balls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.widget-bulk .mini-ball {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(145deg, #fde047, #f59e0b);
    color: #1f2937;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.widget-bulk .status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}

.widget-bulk .status-badge.win {
    background: #dcfce7;
    color: #15803d;
}

.widget-bulk .status-badge.loss {
    background: #f3f4f6;
    color: #6b7280;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .widget {
        padding: 14px;
    }

    .lottery-ball {
        width: 34px;
        height: 34px;
        font-size: 0.8rem;
    }

    .widget-latest .game-grid {
        grid-template-columns: 1fr;
    }

    .widget-frequencies .freq-count {
        min-width: 30px;
    }

    .widget-bulk table {
        font-size: 0.75rem;
    }

    .widget-bulk th,
    .widget-bulk td {
        padding: 5px 6px;
    }
}

/* ─── Widget: check_balance ──────────────────────────────────────────────── */

.widget-balance {
    border-top: 4px solid #1d4ed8;
}

.widget-balance .balance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.widget-balance .balance-tier {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
}

.balance-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.balance-badge.active   { background: #dcfce7; color: #15803d; }
.balance-badge.inactive { background: #fee2e2; color: #b91c1c; }

.widget-balance .balance-quota {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}

.widget-balance .balance-big {
    font-size: 2.4rem;
    font-weight: 800;
    color: #1d4ed8;
    line-height: 1;
}

.widget-balance .balance-unit {
    font-size: 0.85rem;
    color: #6b7280;
}

.widget-balance .balance-bar-wrap {
    background: #e5e7eb;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 4px;
}

.widget-balance .balance-bar {
    height: 100%;
    background: linear-gradient(90deg, #1d4ed8, #60a5fa);
    border-radius: 4px;
    min-width: 4px;
    transition: width 0.4s ease;
}

.widget-balance .balance-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #9ca3af;
    margin-bottom: 8px;
}

.widget-balance .balance-msg {
    font-size: 0.88rem;
    color: #4b5563;
    line-height: 1.5;
    padding: 8px 0;
}

.widget-balance .balance-warning {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
    font-size: 0.82rem;
    color: #78350f;
    margin-top: 10px;
}
