/* ============================================================
   Betting Tracker — Glavni stylesheet
   Dark mode first, responsive za iPad i PC
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Syne:wght@400;600;700&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg:          #0d1117;
  --bg2:         #161b22;
  --bg3:         #21262d;
  --border:      #30363d;
  --border2:     #444c56;
  --text:        #e6edf3;
  --text2:       #8b949e;
  --text3:       #656d76;
  --accent:      #58a6ff;
  --accent2:     #1f6feb;
  --green:       #3fb950;
  --green-bg:    #0f291a;
  --red:         #f85149;
  --red-bg:      #2c0b0b;
  --yellow:      #d29922;
  --yellow-bg:   #271e08;
  --purple:      #a5a0f5;
  --radius:      8px;
  --radius-lg:   12px;
  --font:        'Syne', sans-serif;
  --mono:        'JetBrains Mono', monospace;
  --shadow:      0 1px 0 rgba(27,31,35,.04), 0 0 0 1px var(--border);
  --transition:  all .18s cubic-bezier(.4,0,.2,1);
}

/* Light mode */
@media (prefers-color-scheme: light) {
  :root {
    --bg:    #f6f8fa;
    --bg2:   #ffffff;
    --bg3:   #eaeef2;
    --border: #d0d7de;
    --border2: #adb5bd;
    --text:  #1f2328;
    --text2: #57606a;
    --text3: #8c959f;
    --accent: #0969da;
    --green-bg: #dafbe1;
    --red-bg:   #ffebe9;
    --yellow-bg: #fff8c5;
  }
}

/* Dark mode override (manual toggle) */
[data-theme="dark"] {
  --bg:#0d1117;--bg2:#161b22;--bg3:#21262d;--border:#30363d;
  --border2:#444c56;--text:#e6edf3;--text2:#8b949e;--text3:#656d76;
  --accent:#58a6ff;--accent2:#1f6feb;--green:#3fb950;--green-bg:#0f291a;
  --red:#f85149;--red-bg:#2c0b0b;--yellow:#d29922;--yellow-bg:#271e08;
}
[data-theme="light"] {
  --bg:#f6f8fa;--bg2:#ffffff;--bg3:#eaeef2;--border:#d0d7de;
  --border2:#adb5bd;--text:#1f2328;--text2:#57606a;--text3:#8c959f;
  --accent:#0969da;--green:#1a7f37;--green-bg:#dafbe1;
  --red:#cf222e;--red-bg:#ffebe9;--yellow:#9a6700;--yellow-bg:#fff8c5;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: var(--font); }

/* ---- Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  letter-spacing: -.3px;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text2);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: var(--transition);
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--accent); }
.nav-item .icon  { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* Main content */
.main-content {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-content { padding: 24px; flex: 1; }

/* ---- Cards ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: .95rem; font-weight: 700; color: var(--text); }

/* ---- Stat Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-label  { font-size: .78rem; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value  { font-size: 1.8rem; font-weight: 700; color: var(--text); font-family: var(--mono); margin: 4px 0 2px; line-height: 1.1; }
.stat-sub    { font-size: .8rem; color: var(--text2); }
.stat-positive .stat-value { color: var(--green); }
.stat-negative .stat-value { color: var(--red); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: var(--transition); white-space: nowrap;
}
.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover  { background: var(--accent2); }
.btn-secondary { background: var(--bg3); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--border2); }
.btn-danger   { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-icon { padding: 7px; aspect-ratio: 1; border-radius: 6px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .9rem; font-family: var(--font);
  transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88,166,255,.15); }
textarea.form-control { min-height: 200px; resize: vertical; font-family: var(--mono); font-size: .82rem; }
select.form-control { cursor: pointer; }

/* ---- Password show/hide toggle ---- */
.pw-field { padding-right: 42px !important; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  background: none; border: none; border-radius: var(--radius);
  font-size: 1.15rem; line-height: 1; cursor: pointer;
  opacity: .85; transition: var(--transition);
}
.pw-toggle:hover { opacity: 1; background: var(--bg3); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}
.table th {
  padding: 10px 14px; text-align: left;
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text3); border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--bg);
  cursor: pointer; user-select: none;
}
.table th:hover { color: var(--text2); }
.table td {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  color: var(--text2); vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg3); color: var(--text); }
.table .mono { font-family: var(--mono); font-size: .82rem; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: .74rem; font-weight: 700; letter-spacing: .03em;
}
.badge-won   { background: var(--green-bg); color: var(--green); }
.badge-lost  { background: var(--red-bg);   color: var(--red); }
.badge-push  { background: var(--yellow-bg); color: var(--yellow); }
.badge-multi { background: rgba(88,166,255,.1); color: var(--accent); }

/* ---- Profit cells ---- */
.profit-pos { color: var(--green); font-family: var(--mono); font-weight: 500; }
.profit-neg { color: var(--red);   font-family: var(--mono); font-weight: 500; }
.profit-zero { color: var(--text3); font-family: var(--mono); }

/* ---- Filters bar ---- */
.filters-bar {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.filter-label { font-size: .75rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; }

/* ---- Pagination ---- */
.pagination {
  display: flex; align-items: center; gap: 6px;
  justify-content: center; margin-top: 20px; flex-wrap: wrap;
}
.page-btn {
  padding: 6px 12px; border-radius: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: .85rem; cursor: pointer;
  transition: var(--transition); font-family: var(--font);
}
.page-btn:hover { color: var(--text); border-color: var(--border2); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Toast notifications ---- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 600; max-width: 340px;
  animation: toastIn .25s ease;
  border: 1px solid transparent;
}
.toast-success { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.toast-error   { background: var(--red-bg);   color: var(--red);   border-color: var(--red); }
.toast-info    { background: rgba(88,166,255,.1); color: var(--accent); border-color: var(--accent); }
@keyframes toastIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: none; } }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(.97); } to { opacity:1; transform: none; } }
.modal-header {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title  { font-size: 1rem; font-weight: 700; }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ---- Period tabs ---- */
.period-tabs { display: flex; gap: 4px; background: var(--bg3); padding: 4px; border-radius: var(--radius); }
.period-tab {
  padding: 5px 12px; border-radius: 5px;
  font-size: .8rem; font-weight: 700; cursor: pointer;
  border: none; background: none; color: var(--text2);
  transition: var(--transition);
}
.period-tab.active { background: var(--bg2); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.2); }

/* ---- Charts ---- */
.chart-wrap { position: relative; height: 220px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }

/* ---- Parser preview ---- */
.preview-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.preview-item {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.preview-event { font-weight: 700; font-size: .9rem; flex: 1; min-width: 200px; }
.preview-meta  { font-size: .8rem; color: var(--text2); }

/* ---- Hamburger (mobile) ---- */
.hamburger { display: none; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .charts-grid { grid-template-columns: 1fr; }
  .stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 16px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filters-bar { flex-direction: column; }
  .filter-group { min-width: 100%; }
  .topbar { padding: 10px 16px; }
  .table { font-size: .8rem; }
  .table td, .table th { padding: 8px 10px; }
}

/* ---- Print / PDF ---- */
@media print {
  .sidebar, .topbar, .filters-bar, .pagination,
  .btn, .toast-container, .hamburger { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { border: 1px solid #ccc !important; break-inside: avoid; }
  body { background: #fff !important; color: #000 !important; font-size: 11pt; }
  .table th, .table td { color: #000 !important; border-color: #ccc !important; }
  .profit-pos { color: #1a7f37 !important; }
  .profit-neg { color: #cf222e !important; }
  @page { margin: 1.5cm; }
}

/* ---- Misc helpers ---- */
.text-mono  { font-family: var(--mono); }
.text-sm    { font-size: .82rem; }
.text-muted { color: var(--text2); }
.text-dim   { color: var(--text3); }
.flex       { display: flex; }
.flex-wrap  { flex-wrap: wrap; }
.gap-8      { gap: 8px; }
.gap-12     { gap: 12px; }
.mt-8       { margin-top: 8px; }
.mt-16      { margin-top: 16px; }
.mb-16      { margin-bottom: 16px; }
.mb-24      { margin-bottom: 24px; }
.hidden     { display: none !important; }
.divider    { height: 1px; background: var(--border); margin: 16px 0; }
.flag       { font-size: .95rem; }

.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; color: var(--text3); gap: 10px;
}
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text3);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }
