/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2d3148;
  --text:      #e2e8f0;
  --text-muted:#8892a4;
  --green:     #22c55e;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --yellow:    #eab308;
  --purple:    #a855f7;
  --orange:    #f97316;
  --radius:    8px;
  --radius-lg: 12px;
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Navbar ===== */
#navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
}
.nav-logo { font-size: 1.3rem; }

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
  flex: 1;
}
.nav-links a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--surface2);
  text-decoration: none;
}
.nav-links a.active { color: var(--blue); }

.nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  white-space: nowrap;
}
.nav-username {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.nav-logout {
  font-size: 0.8rem;
  padding: 4px 10px;
}

/* ===== Main ===== */
#main-content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

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

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #000; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-ghost   { background: var(--surface2); color: var(--text); }
.btn-sm      { padding: 4px 10px; font-size: 0.8rem; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead th {
  padding: 10px 8px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
thead th:hover { color: var(--text); }
thead th.sorted-asc::after  { content: ' ▲'; color: var(--blue); }
thead th.sorted-desc::after { content: ' ▼'; color: var(--blue); }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 10px 8px; }

/* ===== Skill Badges ===== */
.skill-val {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 0.9rem;
}
.skill-val .diff-pos { color: var(--green); font-size: 0.75rem; }
.skill-val .diff-neg { color: var(--red); font-size: 0.75rem; }

/* ===== Diff Arrows ===== */
.diff-up   { color: var(--green); font-size: 0.75rem; margin-left: 2px; }
.diff-down { color: var(--red); font-size: 0.75rem; margin-left: 2px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-pos   { background: #14532d; color: var(--green); }
.badge-nega  { background: #450a0a; color: var(--red); }
.badge-info  { background: #1e3a5f; color: var(--blue); }
.badge-warn  { background: #422006; color: var(--yellow); }
.badge-gray  { background: var(--surface2); color: var(--text-muted); }

.pos-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: var(--surface2);
  color: var(--blue);
}

/* ===== Loading / Error ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 1rem;
  gap: 12px;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  background: #450a0a;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.success-msg {
  background: #14532d;
  border: 1px solid var(--green);
  color: var(--green);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== Team selector ===== */
.team-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.team-selector label { color: var(--text-muted); font-size: 0.9rem; }
.team-selector select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
}

/* ===== Player detail ===== */
.player-header {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.player-meta { flex: 1; min-width: 200px; }
.player-meta h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.player-meta .meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

.skill-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.skill-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.skill-card .skill-name { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.skill-card .skill-number { font-size: 1.6rem; font-weight: 700; color: var(--blue); }
.skill-card .skill-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.skill-card .skill-diff { font-size: 0.8rem; margin-top: 4px; }

/* ===== Charts ===== */
.chart-container {
  position: relative;
  margin-bottom: 24px;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 16px;
}
.chart-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); }

/* ===== Import ===== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone.drag-over {
  border-color: var(--blue);
  background: rgba(59,130,246,0.05);
}
.dropzone-icon { font-size: 3rem; margin-bottom: 12px; }
.dropzone p { color: var(--text-muted); margin-top: 8px; font-size: 0.9rem; }
.dropzone strong { color: var(--text); font-size: 1.05rem; }
#file-input { display: none; }

.import-result { margin-top: 20px; }
.diff-list { margin-top: 12px; }
.diff-item {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.diff-item .player-name { font-weight: 600; }
.diff-change { font-size: 0.85rem; color: var(--text-muted); }
.diff-change .arrow { color: var(--blue); }

/* ===== Training ===== */
.training-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.training-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.training-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.training-type-name { font-size: 1.2rem; font-weight: 700; color: var(--blue); }
.training-strategy { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; }
.training-card-body { padding: 16px 20px; }
.training-score-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  margin: 8px 0 16px;
  overflow: hidden;
}
.training-score-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 99px;
  transition: width 0.4s;
}
.training-explanation { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; }

/* Focipálya ábra */
.field-diagram {
  background: #0a3d1a;
  border: 2px solid #1a5e2a;
  border-radius: var(--radius);
  padding: 12px 8px;
  margin-bottom: 16px;
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.field-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 4px 0;
}
.field-player {
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 4px;
  text-align: center;
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}
.field-player.primary   { background: rgba(34,197,94,0.25); border: 1px solid var(--green); color: var(--green); }
.field-player.secondary { background: rgba(59,130,246,0.2); border: 1px solid var(--blue); color: var(--blue); }
.field-player.osmosis   { background: rgba(100,100,100,0.2); border: 1px solid #555; color: #888; }
.field-label { font-size: 0.65rem; color: rgba(255,255,255,0.4); text-align: center; margin-top: 2px; }

.forecast-toggle { margin-bottom: 12px; }
.forecast-table { width: 100%; font-size: 0.75rem; }
.forecast-table th, .forecast-table td { padding: 4px 6px; }

.transfer-list { margin-top: 12px; }
.transfer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

/* ===== Import Log ===== */
.import-log-item {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.import-log-item:hover { background: #2a2f48; }
.import-log-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 0.9rem; }
.import-log-date { font-weight: 600; }
.import-log-details { margin-top: 10px; display: none; }
.import-log-details.open { display: block; }

/* ===== Settings ===== */
.settings-form { max-width: 480px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.875rem; color: var(--text-muted); margin-bottom: 6px; }
.form-group select,
.form-group input[type=range] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.form-group input[type=range] { padding: 4px 0; cursor: pointer; }
.range-val { font-weight: 600; color: var(--blue); margin-left: 8px; }

/* ===== Back link ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 16px;
  cursor: pointer;
  background: none;
  border: none;
}
.back-link:hover { color: var(--text); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #navbar { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 12px; }
  .nav-links { display: none; flex-direction: column; width: 100%; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; margin-left: auto; }
  #main-content { padding: 16px; }
  .training-cards { grid-template-columns: 1fr; }
  .skill-cards { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* ===== Radar modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 420px;
  width: 90%;
}
.modal-box h3 { margin-bottom: 12px; font-size: 1.1rem; }
.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}

/* ===== No data ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }
