/* ────────────────────────────────────────────────────────────────
   BetLinePro — style.css   (dark analytics theme, BLA-faithful)
   ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0d1117;
    --bg-card:   #161b22;
    --bg-input:  #1c2128;
    --border:    #30363d;
    --text:      #e6edf3;
    --muted:     #7d8590;
    --accent:    #2f81f7;
    --accent-h:  #388bfd;
    --green:     #3fb950;
    --red:       #f85149;
    --orange:    #d29922;
    --live:      #ff7b54;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

input, select, button { font-family: inherit; font-size: 14px; }
a { text-decoration: none; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-card); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Utils ──────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════════ */
.auth-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 40% at 50% -10%, rgba(47,129,247,.12) 0%, transparent 70%);
}

.auth-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 36px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}
.logo-text { font-size: 22px; font-weight: 700; color: var(--text); }
.logo-text span { color: var(--accent); }

.auth-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 28px;
}

/* Tab bar */
.tab-bar {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 24px;
}
.tab {
    flex: 1;
    padding: 7px 0;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    color: var(--muted);
    transition: all .15s;
}
.tab.active { background: var(--accent); color: #fff; }
.tab:not(.active):hover { color: var(--text); }

/* Auth Form */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
    font-size: 12px; font-weight: 500; color: var(--muted);
    text-transform: uppercase; letter-spacing: .4px;
}
.field input {
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }

.form-msg { font-size: 12px; border-radius: 6px; padding: 8px 12px; min-height: 0; }
.form-msg:empty { display: none; }
.form-msg.error:not(:empty) { display: block; color: var(--red); background: rgba(248,81,73,.08); border: 1px solid rgba(248,81,73,.25); }
.form-msg.success:not(:empty) { display: block; color: var(--green); background: rgba(63,185,80,.08); border: 1px solid rgba(63,185,80,.25); }

.btn-submit {
    width: 100%;
    padding: 11px;
    margin-top: 4px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-submit:hover { background: var(--accent-h); }
.btn-submit:disabled { opacity: .55; cursor: not-allowed; }

.auth-footer { margin-top: 24px; font-size: 12px; color: var(--muted); }

/* ═══════════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.app-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ─── Header ─────────────────────────────────────────────────── */
.header {
    height: 48px;
    min-height: 48px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 100;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand-text { font-size: 16px; font-weight: 700; color: var(--text); }
.brand-text span { color: var(--accent); }

/* Toolbar buttons */
.header-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.toolbar-btn {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.toolbar-btn:hover { color: var(--text); border-color: var(--muted); }
.toolbar-btn.btn-danger { color: var(--orange); border-color: rgba(210,153,34,.35); }
.toolbar-btn.btn-danger:hover { background: rgba(210,153,34,.12); }
.toolbar-btn .badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 3px;
    min-width: 16px;
    text-align: center;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-pill {
    font-size: 12px;
    color: var(--muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 12px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-logout {
    padding: 4px 12px;
    font-size: 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ─── Loading Overlay ────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13,17,23,.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-box {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--muted); }
.progress-bar {
    width: 200px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width .3s ease;
    width: 0;
}

/* ─── Table area ─────────────────────────────────────────────── */
.table-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.table-scroll-wrap {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN TABLE — BLA-faithful
   ═══════════════════════════════════════════════════════════════ */
.main-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

/* Group header row */
.main-table thead tr:first-child th {
    padding: 4px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    text-align: center;
    background: var(--bg-card);
    border-bottom: 2px solid var(--accent);
    border-right: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 12;
}
.main-table thead tr:first-child th.group-header { color: var(--text); }

/* Column headers */
.col-header {
    padding: 4px 5px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    text-align: center;
    color: var(--muted);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid rgba(48,54,61,.5);
    white-space: nowrap;
    position: sticky;
    top: 27px;
    z-index: 11;
    cursor: default;
    user-select: none;
    min-width: 40px;
    max-width: 60px;
}
.col-header.sortable { cursor: pointer; }
.col-header.sortable:hover { color: var(--text); }

/* Strategy header (odds columns) */
.col-header.strategy-header { cursor: pointer; transition: background .15s; }
.col-header.strategy-header:hover { background: rgba(47,129,247,.12); }
.col-header.strategy-active {
    background: rgba(47,129,247,.18) !important;
    color: var(--accent) !important;
    box-shadow: inset 0 -2px 0 var(--accent);
}
.col-header.strategy-filtered {
    background: rgba(63,185,80,.14) !important;
    color: var(--green) !important;
    box-shadow: inset 0 -2px 0 var(--green);
}

/* Filter row */
.filter-row th {
    padding: 2px 2px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid rgba(48,54,61,.5);
    position: sticky;
    top: 50px;
    z-index: 10;
    min-width: 40px;
    max-width: 60px;
}
.filter-row th.filter-cell { vertical-align: middle; }

/* Filter wrapper (BLA pattern: input + clear button) */
.filter-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.filter-input {
    width: 100%;
    height: 22px;
    padding: 0 16px 0 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text);
    font-size: 11px;
    outline: none;
    transition: border-color .15s;
    color-scheme: dark;
}
.filter-input:focus { border-color: var(--accent); }
.filter-input::placeholder { color: rgba(125,133,144,.5); }

.filter-clear {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    display: none;
    border-radius: 3px;
}
.filter-clear:hover { color: var(--red); background: rgba(248,81,73,.12); }
.filter-wrapper.has-value .filter-clear { display: block; }
.filter-wrapper.has-value .filter-input { border-color: var(--accent); background: rgba(47,129,247,.06); }

/* ── Data rows ── */
.main-table tbody tr {
    transition: background .1s;
}
.main-table tbody tr:last-child td { border-bottom: none; }
.main-table tbody tr:hover { background: rgba(255,255,255,.04); }

.main-table tbody td {
    padding: 3px 5px;
    vertical-align: middle;
    white-space: nowrap;
    color: var(--text);
    font-size: 12px;
    border-right: 1px solid rgba(48,54,61,.4);
    border-bottom: 1px solid rgba(48,54,61,.6);
    background: var(--bg);
    min-width: 40px;
    max-width: 60px;
}
.main-table tbody td:last-child { border-right: none; }

/* ── Column size classes (BLA-faithful) ── */
td.wide, th.wide       { min-width: 170px; max-width: 170px; }
td.medium, th.medium    { min-width: 145px; max-width: 145px; }
td.small, th.small      { min-width: 90px;  max-width: 90px;  }
td.font-bold            { font-weight: 700; }

/* ── Sticky left columns ── */
.sticky-left {
    position: sticky !important;
    background-color: var(--bg-card);
    z-index: 3;
}
.col-header.sticky-left,
.filter-row th.sticky-left { z-index: 20 !important; }
.group-header.sticky-left   { z-index: 21 !important; }

/* Cell types */
.td-date { color: var(--muted); font-size: 11px; }
.td-time { color: var(--muted); font-size: 11px; text-align: center; }
.td-day  { color: var(--muted); font-size: 10px; text-align: center; }
.td-country { font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.td-league  { font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.td-team {
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.td-score {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .5px;
    min-width: 50px;
}
.td-ht { font-size: 11px; color: var(--muted); text-align: center; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; min-width: 44px; }
.td-num.has-val { color: #c9d1d9; }
.td-bold { font-weight: 700; }

/* Cell clickability */
.main-table tbody td[data-field] { cursor: pointer; }
.main-table tbody td[data-field]:hover { background: rgba(47,129,247,.06); }

/* Strategy highlights on odds cells */
.winning-bet { background: rgba(63,185,80,.18) !important; color: var(--green) !important; }
.losing-bet  { background: rgba(248,81,73,.06) !important; color: var(--muted) !important; }
.push-bet    { background: rgba(125,133,144,.10) !important; color: var(--muted) !important; }

/* Score cell combo highlight */
.strategy-win  { background: rgba(63,185,80,.22) !important; color: var(--green) !important; }
.strategy-push { background: rgba(125,133,144,.15) !important; }

/* Row highlighting */
.highlighted-row { background: rgba(47,129,247,.10) !important; }
.bookmarked { border-left: 3px solid var(--orange) !important; }

/* Sort arrow */
.sort-arrow {
    display: inline-block;
    margin-left: 3px;
    font-size: 9px;
    opacity: .7;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════════
   FILTER STATS PANEL (BLA port)
   ═══════════════════════════════════════════════════════════════ */
.filter-stats-panel {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 8px 16px;
    overflow-x: auto;
}
.filter-stats-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}
.filter-stats-content {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.stat-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    min-width: 120px;
    font-size: 11px;
}
.stat-item.success { border-color: rgba(63,185,80,.4); }
.stat-item.warning { border-color: rgba(210,153,34,.4); }
.stat-item.danger  { border-color: rgba(248,81,73,.3); }
.stat-header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.stat-market { font-weight: 600; color: var(--text); }
.stat-odds   { color: var(--muted); }
.stat-footer { display: flex; justify-content: space-between; gap: 8px; }
.stat-result { color: var(--muted); }
.stat-percentage { font-weight: 700; }
.stat-item.success .stat-percentage { color: var(--green); }
.stat-item.warning .stat-percentage { color: var(--orange); }
.stat-item.danger  .stat-percentage { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════
   PROFIT PANEL (BLA port)
   ═══════════════════════════════════════════════════════════════ */
.profit-panel {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 6px 16px;
}
.profit-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
}
.profit-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.profit-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.profit-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: .3px;
}
.profit-value {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.profit-value.positive { color: var(--green); }
.profit-value.negative { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════════════ */
.footer-bar {
    height: 36px;
    min-height: 36px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    justify-content: space-between;
    gap: 12px;
    z-index: 10;
}
.footer-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}
.fstat b { color: var(--text); }
.fstat-sep { color: var(--border); }

.footer-center {
    display: flex;
    align-items: center;
    gap: 3px;
}

.pg-btn {
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--muted);
    cursor: pointer;
    transition: all .15s;
}
.pg-btn:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pg-btn:disabled { opacity: .35; cursor: not-allowed; }
.pg-dots { color: var(--muted); font-size: 11px; padding: 0 2px; }
.pg-info { font-size: 11px; color: var(--muted); margin-left: 8px; }

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.72);
    backdrop-filter: blur(3px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
}
.modal-close {
    width: 26px; height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 5px;
    cursor: pointer;
    transition: all .15s;
}
.modal-close:hover { border-color: var(--red); color: var(--red); }
.modal-body {
    overflow-y: auto;
    padding: 12px;
}

/* Bookmark items (shared for match & filter bookmarks) */
.bm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
.bm-item:last-child { border-bottom: none; }
.bm-item:hover { background: rgba(255,255,255,.03); }
.bm-info {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}
.bm-name { font-size: 13px; font-weight: 600; color: var(--text); }
.bm-desc { font-size: 11px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-date { font-size: 10px; color: var(--border); margin-top: 2px; }
.bm-del {
    width: 24px; height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
}
.bm-del:hover { border-color: var(--red); color: var(--red); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
    .header { padding: 0 10px; gap: 8px; }
    .header-brand { display: none; }
    .header-user .user-pill { display: none; }
    .filter-stats-content { flex-wrap: nowrap; overflow-x: auto; }
}
