/* Batut / Trampoline registration — application-batut.html */

:root {
  --primary: #667eea;
  --primary-dark: #5568d3;
  --primary-light: #eef1fb;
  --accent: #0b3b72;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --text: #1a1a2e;
  --muted: #6c757d;
  --border: #d0d7de;
  --danger: #dc3545;
  --success: #28a745;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(135deg, #e8eef8 0%, #f5f7fb 50%, #e0e8f4 100%);
  min-height: 100vh;
}

a { color: var(--primary); }

.muted { color: var(--muted); }

.hidden { display: none !important; }

/* ── Layout ─────────────────────────────────────────────── */

.form-container {
  max-width: 980px;
  margin: 16px auto 24px;
  padding: 24px 28px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(102, 126, 234, 0.12);
}

#page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 8px;
  text-align: center;
}

.login-hint {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 6px;
}

#competitionTitle {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 500;
}

.section {
  margin: 20px 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
}

.section:first-of-type { border-top: none; padding-top: 0; }

.section h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 12px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.form-group {
  margin-bottom: 12px;
  flex: 1 1 200px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 4px;
  color: #374151;
}

/* ── Inputs ───────────────────────────────────────────── */

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fafbfc;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
  background: #fff;
}

input.error, select.error, textarea.error {
  border-color: var(--danger);
  background: #fff5f5;
}

textarea { resize: vertical; min-height: 100px; }

/* ── Buttons ──────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

.btn:active:not(:disabled) { transform: translateY(0); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  box-shadow: none;
}

.btn.ghost:hover:not(:disabled) {
  background: var(--primary-light);
  box-shadow: none;
}

.btn.secondary {
  background: #6c757d;
}

.btn-icon { font-size: 1.1em; }

/* ── Country ──────────────────────────────────────────── */

.country-row { display: flex; flex-direction: column; gap: 8px; }

.country-preview {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--primary-light);
  border-radius: 8px;
  font-size: 0.9rem;
}

.country-flag .flag-icon,
.flag-icon {
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  vertical-align: middle;
}

/* ── Participants / dynamic blocks ───────────────────── */

.participant-item,
.group-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.remove-participant-btn {
  margin-top: 10px;
  padding: 8px 14px;
  background: #fff;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
}

.remove-participant-btn:hover {
  background: #fde8ea;
}

/* ── Disciplines panel ────────────────────────────────── */

.subjects-panel,
.group-subjects-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.subject-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e8ecf0;
}

.subject-btn {
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.subject-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

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

.subject-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.note {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ── Pills & badges ───────────────────────────────────── */

.pill {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 0.875rem;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 6px;
}

/* ── Tables (registered) ────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #f6f8fa;
  font-weight: 600;
  color: #374151;
}

.data-table tr:hover td { background: #fafbfc; }

.td-num { width: 48px; text-align: center; color: var(--muted); }

.table-caption {
  margin: 16px 0 8px;
  font-weight: 600;
}

.table-caption .cat { color: var(--accent); }

.country-cell { white-space: nowrap; }

.country-cell .flag { margin-right: 6px; }

.name { font-weight: 500; }

/* ── Modals ───────────────────────────────────────────── */

#login-mask,
#register-mask,
#edit-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#login-mask > div,
#register-mask > div,
#edit-modal > div,
.modal-content {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

#edit-modal > div { max-width: 900px; max-height: 85vh; overflow-y: auto; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Toast ────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  padding: 12px 18px;
  border-radius: 8px;
  color: #fff;
  background: #333;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast-success { background: var(--success) !important; }
.toast-error   { background: var(--danger) !important; }
.toast-warning { background: #ffc107 !important; color: #212529 !important; }
.toast-info    { background: #17a2b8 !important; }

/* ── Top bar (sticky, holds nav/auth on the left, language switcher on the right) ── */

.top-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  padding: 10px 20px;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.2);
}

.top-bar .muted {
  color: rgba(255, 255, 255, 0.85);
}

.top-bar .btn.ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.65);
}

.top-bar .btn.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.top-bar .btn:not(.ghost) {
  background: #fff;
  color: var(--accent);
  box-shadow: none;
}

.top-bar .btn:not(.ghost):hover:not(:disabled) {
  background: #f0f4f8;
  box-shadow: none;
}

.top-bar-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.lang-switcher {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.lang-btn {
  width: 40px;
  height: 40px;
  border: 3px solid transparent;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  padding: 0;
}

.lang-btn:hover {
  transform: scale(1.08);
}

.lang-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}

.lang-btn .fi {
  font-size: 22px;
  line-height: 1;
}

/* ── Brand (logo + app name) ──────────────────────────── */

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: #fff;
  font-weight: 800;
  margin-right: 8px;
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.35);
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  display: block;
}

.brand-name {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  line-height: 1;
}

.brand-tld {
  color: #c3e05a;
  font-weight: 700;
}

/* ── Auth bar ─────────────────────────────────────────── */

#auth-userbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ── Filter bar ───────────────────────────────────────── */

.registered-filter-bar {
  margin: 10px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.registered-flags-bar,
.registered-clubs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.filter-bar-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 2px;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: #f6f8fa;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
  color: inherit;
}

.filter-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

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

.filter-btn-flag .fi { font-size: 18px; line-height: 1; }

/* ── Utilities ────────────────────────────────────────── */

.input-warning {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: none;
}

input.invalid-input {
  border-color: var(--danger) !important;
  background-color: #fff5f5 !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.form-text {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.25rem;
  display: block;
}

.qty { width: 64px !important; flex: 0 0 64px !important; }

/* ── Mobile ───────────────────────────────────────────── */

@media (max-width: 768px) {
  html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

  body { font-size: 16px; }

  /* Top bar: center both groups and let them wrap onto their own rows */
  .top-bar {
    padding: 8px 12px;
    justify-content: center;
    gap: 8px;
  }

  .top-bar-nav {
    width: 100%;
    justify-content: center;
  }

  .top-bar-nav .btn,
  .top-bar-nav a {
    font-size: 0.8rem;
    padding: 7px 10px;
  }

  .brand-link {
    flex: 1 1 100%;
    justify-content: center;
    margin: 0 0 6px;
    padding: 0 0 6px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  }

  .brand-logo { width: 30px; height: 30px; }

  .brand-name { font-size: 1.05rem; }

  .lang-switcher {
    width: 100%;
    justify-content: center;
  }

  .lang-btn {
    width: 36px;
    height: 36px;
  }

  .lang-btn .fi {
    font-size: 18px;
  }

  #login-section {
    margin-top: 8px !important;
    padding: 0 10px;
  }

  #show-login-btn { width: 100%; min-height: 48px; }

  .form-container {
    width: 100%;
    max-width: 100%;
    margin: 4px 0 !important;
    padding: 14px 12px !important;
    border-radius: 12px;
  }

  #page-title {
    font-size: 1.3rem;
    line-height: 1.25;
  }

  .login-hint { font-size: 0.8rem; }

  .section { margin: 16px 0; padding-top: 14px; }

  .section h2 { font-size: 1rem; }

  .row {
    flex-direction: column;
    gap: 10px;
  }

  .form-group {
    margin-bottom: 10px;
    flex: 1 1 auto !important;
  }

  input, select, textarea, button.btn, .btn {
    width: 100%;
    min-height: 46px;
    font-size: 16px;
  }

  textarea { min-height: 80px; }

  .btn { padding: 12px 16px; }

  .participant-item, .group-item {
    padding: 12px 10px;
    border-radius: 10px;
  }

  .remove-participant-btn {
    width: 100%;
    text-align: center;
    min-height: 42px;
  }

  .subject-row {
    padding: 10px;
    gap: 8px;
  }

  .subject-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
    flex: 1 1 auto;
    min-height: 42px;
  }

  .country-preview {
    width: 100%;
    justify-content: center;
  }

  /* Tables: keep readable columns, allow horizontal scroll on tiny screens */
  #participantsTables,
  #coachesTable,
  #judgesTable {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -2px;
  }

  .data-table { min-width: 480px; font-size: 0.85rem; }

  .data-table th, .data-table td { padding: 8px 10px; }

  .table-caption { font-size: 0.9rem; }

  #login-mask > div,
  #register-mask > div,
  #edit-modal > div,
  .modal-content {
    width: calc(100vw - 20px) !important;
    max-width: 100% !important;
    padding: 16px !important;
  }

  .modal-actions { flex-direction: column; }

  .modal-actions .btn { width: 100%; }

  .toast-container {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }

  #edit-mode-bar > div,
  #edit-modal > div > div:first-child {
    flex-wrap: wrap !important;
  }

  #edit-mode-bar .btn { font-size: 0.85rem; padding: 8px 10px; }

  .registered-filter-bar { gap: 10px; }

  .filter-btn { padding: 7px 14px; font-size: 13px; }

  .filter-bar-label { width: 100%; }
}

@media (max-width: 380px) {
  #page-title { font-size: 1.15rem; }

  .lang-btn { width: 32px; height: 32px; }

  .lang-btn .fi { font-size: 16px; }

  .top-bar-nav .btn, .top-bar-nav a { font-size: 0.75rem; padding: 6px 8px; }

  .brand-logo { width: 26px; height: 26px; }

  .brand-name { font-size: 0.95rem; }
}
