/* =========================================================
   FLip Your Luck — Shared Styles
   Covers: main list (ui.js), compare view (compare.js), game view (games.js)
========================================================= */

/* ---------- Design tokens ---------- */
:root {
    /* Core brand feel */
    --bg: #f1f5fb;                /* soft blue-gray background */
    --card: #ffffff;
    --text: #0b1f3a;              /* deeper navy for contrast */
    --muted: #4b6a9b;             /* blue-tinted muted text */
    --line: #d6e0f0;

    /* Accents (Florida Lottery–inspired) */
    --primary: #0057b8;           /* bold Florida blue */
    --primary-soft: #e6f0ff;

    --gold: #f5b700;              /* sunshine gold */
    --gold-soft: #fff4cc;

    --red: #d61f26;
    --red-soft: #fde8ea;

    /* UI polish */
    --shadow: 0 10px 28px rgba(0, 40, 100, 0.18);
    --radius: 14px;
    --pad: 16px;

    /* Status */
    --green-bg: #e9fbf2;
    --green-line: #34c38f;

    --amber-bg: #fff6d8;
    --orange-bg: #fff0e6;
    --red-bg: #fdeaea;

    /* Charts / bars */
    --bar-bg: #e9eef7;
    --bar-fill: linear-gradient(90deg, #3b82f6, #0057b8);
}


/* ---------- Base reset ---------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    margin: 0;
    padding: 24px;                 /* gives compare/games their original spacing */
    color: var(--text);
    background: var(--bg);
}

/* ---------- Typography helpers ---------- */
h1 {
    margin: 0;
    font-size: 26px;
    letter-spacing: -0.02em;
}

.app-title {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin: 0;
}

.title-fl {
    font-weight: 700;
}

.app-subtitle {
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.75;
    letter-spacing: 0;
    margin-top: 0.25rem;
}

h2 {
    margin: 18px 0 8px;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.hint {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Links ---------- */
a {
    color: inherit;                 /* works well for compare/games */
    text-decoration: none;
    font-weight: 600;
}

a:hover { text-decoration: underline; }

/* ---------- Page shell (used by ui.js) ---------- */
.page {
    max-width: 1200px;
    margin: 0 auto;                 /* body padding already provides outer spacing */
    padding: 0 16px;
}

/* Optional header layout if you use <header> on any page */
header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

/* ---------- Global nav ---------- */
.app-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 10px 0 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.app-nav .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
}

.app-nav .brand img {
    height: 56px;
    width: auto;
    border-radius: 6px;
}

.app-nav .brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-nav .brand-title {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    letter-spacing: -0.5px;
    font-size: 1.75rem;
    line-height: 1.2;
}

.app-nav .brand-subtitle {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.75;
    letter-spacing: 0;
}

.app-nav .nav-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.app-nav .nav-links a,
.app-nav .nav-links form button,
.app-nav .nav-links .secondary {
    font-weight: 600;
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 999px;
    background: transparent;
}

.app-nav .nav-links a.active,
.app-nav .nav-links a:hover,
.app-nav .nav-links .secondary:hover,
.app-nav .nav-links .secondary.active,
.app-nav .nav-links form button:hover {
    background: var(--primary-soft);
    text-decoration: none;
}

.app-nav .nav-links a.primary {
    background: var(--primary);
    color: #fff;
}

.app-nav .nav-links a.primary:hover,
.app-nav .nav-links a.primary.active {
    background: #004a9e;
}

/* ---------- Auth pages ---------- */
.auth-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 10px 0 20px;
}

.auth-logo img {
    height: 72px;
    width: auto;
}

.auth-nav {
    display: inline-flex;
    gap: 12px;
}

.auth-nav a {
    padding: 6px 16px;
    border-radius: 999px;
    color: var(--primary);
    background: var(--primary-soft);
}

.auth-nav a.active,
.auth-nav a:hover {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
}

.page-content {
    max-width: 480px;
    margin: 0 auto;
    background: var(--card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-content form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.page-content input {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-size: 1rem;
}

.page-content button {
    padding: 10px 14px;
    border-radius: 999px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.page-content button:hover {
    background: #004a9e;
}

.error-message {
    margin: 8px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--red-soft);
    color: var(--red);
    font-weight: 600;
}

.helper-text {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.app-nav .nav-links form {
    margin: 0;
}

.app-nav .nav-links form button {
    appearance: none;
    border: none;
    cursor: pointer;
    display: inline-block;
    font: inherit;
    line-height: 1;
    min-height: 0;
}

.app-nav .nav-links .user-capsule {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.app-nav .nav-links .user-email {
    font-size: 0.95rem;
}

.app-nav .nav-links .user-capsule form {
    margin: 0;
}

.app-nav .nav-links .logout-button {
    appearance: none;
    border: none;
    background: transparent;
    padding: 0;
    display: inline-flex;
    align-items: center;
    color: inherit;
    cursor: pointer;
}

.app-nav .nav-links .logout-button svg {
    width: 16px;
    height: 16px;
}

.app-nav .nav-links .logout-button:hover {
    color: #004a9e;
}

/* ---------- Card ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--pad);
}

/* ---------- Pills / badges ---------- */
.pill {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    background: #f9fafb;
}

.win {
    margin-left: 8px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--green-line);
    background: var(--green-bg);
}

/* ---------- Buttons (both <button> and .btn links) ---------- */
button,
.btn {
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    min-height: 38px;
    text-decoration: none; /* for <a class="btn"> */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: inherit;
}

button:hover,
.btn:hover {
    border-color: #cbd5e1;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
    text-decoration: none;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Back links in games.js */
.back {
    margin-bottom: 12px;
    display: inline-block;
}

button.primary,
.btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

button.primary:hover,
.btn.primary:hover {
    filter: brightness(1.05);
}

/* ---------- Forms / controls (ui.js) ---------- */
.controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
}

.field label {
    font-size: 12px;
    color: #334155;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.field .subhint {
    font-size: 12px;
    color: var(--muted);
}

.controls select,
.controls input {
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    outline: none;
    min-height: 38px;
}

.controls select:focus,
.controls input:focus {
    border-color: #94a3b8;
    box-shadow: var(--focus, 0 0 0 3px rgba(148, 163, 184, 0.35));
}

.spacer { flex: 1; }

.actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    align-items: center;
}

.toast {
    display: none;
    margin-left: 8px;
    color: #065f46;
    font-weight: 600;
}

/* ---------- Tables ---------- */
/* Generic table styling (covers games.js tier table) */
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    vertical-align: middle;
    font-size: 14px;
}

th {
    text-align: left;
    font-size: 13px;
    color: #374151;
    white-space: nowrap;
}

/* Main list table wrapper (ui.js) */
.table-meta {
    margin-top: 16px;
    padding: 0 4px;
}

.table-wrap {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: auto;
    background: #fff;
}

/* Keep UI table usable with many columns */
.table-wrap table {
    min-width: 920px;
}

/* Sticky header only inside .table-wrap */
.table-wrap thead th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
    z-index: 1;
    border-bottom: 1px solid var(--line);
}

/* Zebra/hover only for large list tables (safer scoped) */
.table-wrap tbody tr:nth-child(even) { background: #fafafa; }
.table-wrap tbody tr:hover { background: #f8fafc; }

/* Top-3 highlights (ui.js) */
tr.top1 {
    background: linear-gradient(
            90deg,
            #fff1c1,
            #ffffff 60%
    ) !important;
    border-left: 4px solid #f5b700;
}

tr.top2 {
    background: linear-gradient(
            90deg,
            #beffe7,
            #ffffff 60%
    ) !important;
    border-left: 4px solid #1d724a;
}

tr.top3 {
    background: linear-gradient(
            90deg,
            #ffc1f2,
            #ffffff 60%
    ) !important;
    border-left: 4px solid #da4e9d;
}

/* Checkbox column tighter (ui.js) */
.table-wrap td:first-child,
.table-wrap th:first-child {
    width: 36px;
}

/* ---------- Score pill (ui.js) ---------- */
.score-pill{
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 2px 10px;
    border-radius: 999px;

    border: 1px solid var(--line);
    background: #fff;              /* JS can still override background inline */
    color: var(--text);

    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 56px;
    line-height: 20px;             /* helps the pill look consistent */
}

tr.top1 .score-pill {
    background: #fff6d6;
    border-color: #f5b700;
}

tr.top2 .score-pill {
    background: #dff9ef;
    border-color: #1d724a;
}

tr.top3 .score-pill {
    background: #ffe2f4;
    border-color: #da4e9d;
}

/* ---------- Sort indicators (ui.js) ---------- */
th[data-key] {
    position: relative;
    padding-right: 22px;
    user-select: none;
    cursor: pointer;
    color: var(--text);
    font-weight: 700;
}

th[data-key]::after {
    content: "⇅";
    position: absolute;
    right: 8px;
    color: #94a3b8;
    font-size: 12px;
}

th.sorted-asc::after { content: "▲"; color: var(--text); }
th.sorted-desc::after { content: "▼"; color: var(--text); }

/* ---------- Compare page (compare.js) ---------- */
.topbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.wrap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

/* Compare card header bits */
.title {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 4px;
}

.sub {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 10px;
}

/* Compare metrics */
.wrap .grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.metric {
    border: 1px solid #f0f1f3;
    border-radius: 12px;
    padding: 10px;
    background: #fff;
}

.metric.winner {
    background: var(--green-bg);
    border-color: var(--green-line);
}

.label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 2px;
}

.value {
    font-weight: 700;
    font-size: 14px;
}

.section { margin-top: 10px; }
.sectionTitle {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 6px;
}

.tier { margin-bottom: 8px; }
.tierLine {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
}
.tierAmt { font-weight: 600; }
.tierPct { color: var(--muted); }

.smallLink {
    font-size: 12px;
    color: #374151;
}

/* ---------- Bars (compare.js + games.js) ---------- */
.barwrap {
    height: 10px;
    background: var(--bar-bg);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 4px;
}

.bar {
    height: 100%;
    background: var(--bar-fill);
}

/* ---------- Game detail page (games.js) ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.grid .card {
    /* keep shared .card styles */
}

.top-tier {
    background: #f9fafb;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
    /* ui.js controls */
    .field { min-width: 160px; }
    .controls { align-items: stretch; }
    button, .btn { width: 100%; }
    .spacer { display: none; }

    /* ui.js table */
    .table-wrap table { min-width: 860px; }
}

@media (max-width: 520px) {
    .grid { grid-template-columns: 1fr; }
}
