/* =========================================================
   Judo Competition Manager Pro — Stylesheet
   Covers: frontend, admin, print
   ========================================================= */

/* ── Reset / Base ─────────────────────────────────────── */
.jcm-wrap *, .jcm-wrap *::before, .jcm-wrap *::after { box-sizing: border-box; }
.jcm-wrap { font-family: 'Segoe UI', Arial, sans-serif; color: #1a1a2e; line-height: 1.5; }

/* ── CSS Variables ────────────────────────────────────── */
:root {
  --jcm-primary:    #1a237e;
  --jcm-primary-lt: #3949ab;
  --jcm-accent:     #e53935;
  --jcm-success:    #2e7d32;
  --jcm-warning:    #f57f17;
  --jcm-bg:         #f5f6fa;
  --jcm-card-bg:    #ffffff;
  --jcm-border:     #dde1f0;
  --jcm-text:       #1a1a2e;
  --jcm-text-muted: #6b7280;
  --jcm-radius:     10px;
  --jcm-shadow:     0 2px 12px rgba(26,35,126,.10);
  --jcm-shadow-lg:  0 8px 32px rgba(26,35,126,.16);
}

/* ── Header ───────────────────────────────────────────── */
.jcm-header {
  background: linear-gradient(135deg, var(--jcm-primary) 0%, var(--jcm-primary-lt) 100%);
  color: #fff;
  padding: 0 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky; top: 0; z-index: 100;
}
.jcm-header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.jcm-logo { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 700; }
.jcm-logo-icon { font-size: 1.5rem; }
.jcm-header-actions { display: flex; gap: 10px; }

/* ── Views ────────────────────────────────────────────── */
.jcm-views { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.jcm-view { display: none; }
.jcm-view.active { display: block; animation: jcmFadeIn .2s ease; }
@keyframes jcmFadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

/* ── Section header ───────────────────────────────────── */
.jcm-section-header {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 20px;
}
.jcm-section-header h2 { margin: 0; font-size: 1.4rem; color: var(--jcm-primary); flex: 1; }
.jcm-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.jcm-filters input[type="date"] {
  border: 1px solid var(--jcm-border); border-radius: 6px;
  padding: 6px 10px; font-size: .85rem;
}
.jcm-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ──────────────────────────────────────────── */
.jcm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: 7px; border: none;
  font-size: .88rem; font-weight: 600; cursor: pointer;
  transition: all .18s ease; text-decoration: none; white-space: nowrap;
}
.jcm-btn:active { transform: scale(.97); }
.jcm-btn-primary  { background: var(--jcm-primary); color: #fff; }
.jcm-btn-primary:hover { background: var(--jcm-primary-lt); color: #fff; }
.jcm-btn-ghost    { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.jcm-btn-ghost:hover { background: rgba(255,255,255,.25); }
.jcm-view .jcm-btn-ghost { background: transparent; color: var(--jcm-text-muted); border-color: var(--jcm-border); }
.jcm-view .jcm-btn-ghost:hover { background: var(--jcm-bg); color: var(--jcm-text); }
.jcm-btn-outline  { background: transparent; color: var(--jcm-primary); border: 1.5px solid var(--jcm-primary); }
.jcm-btn-outline:hover { background: var(--jcm-primary); color: #fff; }
.jcm-btn-success  { background: var(--jcm-success); color: #fff; }
.jcm-btn-success:hover { background: #1b5e20; }
.jcm-btn-danger   { background: var(--jcm-accent); color: #fff; }
.jcm-btn-danger:hover { background: #b71c1c; }
.jcm-btn-sm       { padding: 5px 12px; font-size: .82rem; }
.jcm-btn-xs       { padding: 3px 9px; font-size: .78rem; border-radius: 5px; }

/* ── Grid / Cards ─────────────────────────────────────── */
.jcm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.jcm-card {
  background: var(--jcm-card-bg);
  border: 1px solid var(--jcm-border);
  border-radius: var(--jcm-radius);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow .2s, transform .2s;
  box-shadow: var(--jcm-shadow);
}
.jcm-card:hover, .jcm-card:focus {
  box-shadow: var(--jcm-shadow-lg);
  transform: translateY(-3px);
  border-color: var(--jcm-primary-lt);
  outline: none;
}
.jcm-card-date { font-size: .78rem; color: var(--jcm-text-muted); margin-bottom: 6px; }
.jcm-card-title { font-size: 1.05rem; font-weight: 700; color: var(--jcm-primary); margin-bottom: 10px; }
.jcm-card-meta  { display: flex; flex-direction: column; gap: 4px; font-size: .83rem; color: var(--jcm-text-muted); }

/* ── Competition meta strip ───────────────────────────── */
.jcm-comp-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  background: var(--jcm-card-bg); border: 1px solid var(--jcm-border);
  border-radius: var(--jcm-radius); padding: 14px 20px;
  margin-bottom: 20px; font-size: .9rem;
}
.jcm-comp-meta span { color: var(--jcm-text-muted); }
.jcm-comp-meta b { color: var(--jcm-text); }

/* ── Tabs ─────────────────────────────────────────────── */
.jcm-tabs { display: flex; border-bottom: 2px solid var(--jcm-border); margin-bottom: 20px; gap: 4px; }
.jcm-tab {
  padding: 10px 22px; font-size: .92rem; font-weight: 600;
  background: none; border: none; cursor: pointer;
  color: var(--jcm-text-muted); border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: all .15s;
}
.jcm-tab.active { color: var(--jcm-primary); border-bottom-color: var(--jcm-primary); }
.jcm-tab:hover { color: var(--jcm-primary); }
.jcm-tab-content { display: none; }
.jcm-tab-content.active { display: block; }

/* ── Toolbar ──────────────────────────────────────────── */
.jcm-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ── Table ────────────────────────────────────────────── */
.jcm-table-scroll { overflow-x: auto; border-radius: var(--jcm-radius); border: 1px solid var(--jcm-border); }
.jcm-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.jcm-table thead tr { background: var(--jcm-primary); color: #fff; }
.jcm-table th { padding: 11px 14px; text-align: left; font-weight: 600; white-space: nowrap; }
.jcm-table td { padding: 10px 14px; border-bottom: 1px solid var(--jcm-border); vertical-align: middle; }
.jcm-table tbody tr:last-child td { border-bottom: none; }
.jcm-table tbody tr:hover { background: #f0f3ff; }
.jcm-actions { white-space: nowrap; }

/* ── Badges ───────────────────────────────────────────── */
.jcm-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600; text-transform: capitalize; }
.jcm-badge-male   { background: #e3f0ff; color: #1565c0; }
.jcm-badge-female { background: #fce4ec; color: #ad1457; }

/* ── Brackets ─────────────────────────────────────────── */
.jcm-bracket-section { margin-bottom: 32px; background: var(--jcm-card-bg); border: 1px solid var(--jcm-border); border-radius: var(--jcm-radius); overflow: hidden; }
.jcm-bracket-title { background: var(--jcm-primary); color: #fff; padding: 12px 20px; font-size: 1rem; font-weight: 700; }
.jcm-round { padding: 16px 20px; }
.jcm-round-title { font-size: .9rem; font-weight: 700; color: var(--jcm-text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.jcm-vs { text-align: center; font-weight: 700; color: var(--jcm-accent); }
.jcm-winner-select { padding: 4px 8px; border-radius: 5px; border: 1px solid var(--jcm-border); font-size: .85rem; }

/* ── Modals ───────────────────────────────────────────── */
.jcm-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 9999;
  align-items: center; justify-content: center;
  padding: 16px;
}
.jcm-modal-overlay.active { display: flex; }
.jcm-modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 540px;
  box-shadow: var(--jcm-shadow-lg); animation: jcmModalIn .22s ease;
  max-height: 90vh; overflow-y: auto;
}
.jcm-modal-sm { max-width: 380px; }
@keyframes jcmModalIn { from{opacity:0;transform:scale(.94)} to{opacity:1;transform:none} }
.jcm-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--jcm-border);
}
.jcm-modal-header h3 { margin: 0; font-size: 1.1rem; color: var(--jcm-primary); }
.jcm-modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--jcm-text-muted); line-height: 1; padding: 0 4px; }
.jcm-modal-close:hover { color: var(--jcm-accent); }
.jcm-modal-body { padding: 20px 22px; }
.jcm-modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--jcm-border); }

/* ── Forms ────────────────────────────────────────────── */
.jcm-form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.jcm-form-group label { font-size: .85rem; font-weight: 600; color: var(--jcm-text); }
.jcm-form-group input,
.jcm-form-group select,
.jcm-form-group textarea {
  padding: 9px 12px; border: 1.5px solid var(--jcm-border); border-radius: 7px;
  font-size: .92rem; color: var(--jcm-text); transition: border-color .15s;
}
.jcm-form-group input:focus,
.jcm-form-group select:focus { outline: none; border-color: var(--jcm-primary-lt); }
.jcm-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.jcm-optional { font-weight: 400; color: var(--jcm-text-muted); font-size: .82rem; }

/* ── Clubs view ───────────────────────────────────────── */
.jcm-clubs-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.jcm-clubs-form input { flex: 1; min-width: 180px; padding: 9px 12px; border: 1.5px solid var(--jcm-border); border-radius: 7px; font-size: .92rem; }
.jcm-clubs-form input:focus { outline: none; border-color: var(--jcm-primary-lt); }















/* ── Forms ────────────────────────────────────────────── */
.jcm-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.jcm-form-group label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--jcm-text);
}

.jcm-form-group input,
.jcm-form-group select,
.jcm-form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--jcm-border);
  border-radius: 7px;
  font-size: .92rem;
  color: var(--jcm-text);
  transition: border-color .15s;
  background-color: rebeccapurple; /* CHANGED */
}

.jcm-form-group input:focus,
.jcm-form-group select:focus {
  outline: none;
  border-color: var(--jcm-primary-lt);
}

.jcm-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.jcm-optional {
  font-weight: 400;
  color: var(--jcm-text-muted);
  font-size: .82rem;
}

/* ── Clubs view ───────────────────────────────────────── */
.jcm-clubs-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.jcm-clubs-form input {
  flex: 1;
  min-width: 180px;
  padding: 9px 12px;
  border: 1.5px solid var(--jcm-border);
  border-radius: 7px;
  font-size: .92rem;
  background-color: rebeccapurple; /* CHANGED */
}

.jcm-clubs-form input:focus {
  outline: none;
  border-color: var(--jcm-primary-lt);
}














/* ── States ───────────────────────────────────────────── */
.jcm-loading { text-align: center; padding: 40px; color: var(--jcm-text-muted); font-size: .92rem; }
.jcm-empty   { text-align: center; padding: 48px 20px; }
.jcm-empty p { color: var(--jcm-text-muted); font-size: .95rem; }
.jcm-hint    { color: var(--jcm-text-muted); font-size: .9rem; padding: 20px 0; }

/* ── Toast ────────────────────────────────────────────── */
.jcm-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 99999;
  padding: 12px 22px; border-radius: 8px; font-size: .9rem; font-weight: 600;
  color: #fff; box-shadow: 0 4px 20px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(12px); transition: all .25s ease;
  pointer-events: none;
}
.jcm-toast-visible { opacity: 1; transform: none; }
.jcm-toast-success { background: var(--jcm-success); }
.jcm-toast-error   { background: var(--jcm-accent); }
.jcm-toast-info    { background: var(--jcm-primary-lt); }

/* ── Admin styles ─────────────────────────────────────── */
.jcm-admin-wrap { padding: 20px; }
.jcm-admin-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin: 24px 0; }
.jcm-admin-card { background: #fff; border: 1px solid #dde1f0; border-radius: 10px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.jcm-admin-card h3 { margin: 0 0 8px; font-size: .95rem; color: #555; }
.jcm-stat { font-size: 2.2rem; font-weight: 800; color: #1a237e; margin-bottom: 10px; }
.jcm-admin-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; }
.jcm-admin-info { background: #f0f3ff; border: 1px solid #c5cae9; border-radius: 10px; padding: 16px 20px; margin-top: 24px; }
.jcm-admin-info h3 { margin: 0 0 8px; }
.jcm-admin-info code { background: #fff; border: 1px solid #c5cae9; padding: 6px 14px; border-radius: 6px; font-size: 1rem; display: block; margin-bottom: 8px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
  .jcm-section-header { flex-direction: column; align-items: flex-start; }
  .jcm-form-row { grid-template-columns: 1fr; }
  .jcm-header-inner { height: auto; padding: 10px 0; flex-wrap: wrap; gap: 8px; }
  .jcm-card-title { font-size: .97rem; }
  .jcm-views { padding: 14px 12px; }
}

/* =========================================================
   PRINT STYLES
   ========================================================= */
.jcm-print-area { display: none; }

@media print {
  /* hide everything except print area */
  body > *:not(.jcm-wrap),
  .jcm-header,
  .jcm-views,
  .jcm-toast,
  .jcm-modal-overlay { display: none !important; }

  .jcm-print-area {
    display: block !important;
    font-family: 'Times New Roman', serif;
    color: #000;
    font-size: 11pt;
  }

  .jcm-print-doc { position: relative; }

  /* Watermark */
  .jcm-print-watermark {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 60pt; color: rgba(26,35,126,.07);
    font-weight: 900; white-space: nowrap;
    pointer-events: none; z-index: -1;
    direction: rtl;
  }

  .jcm-print-header { text-align: center; border-bottom: 3px solid #1a237e; padding-bottom: 14px; margin-bottom: 20px; }
  .jcm-print-header h1 { font-size: 18pt; color: #1a237e; margin: 0 0 8px; }
  .jcm-print-info { display: flex; justify-content: center; flex-wrap: wrap; gap: 20px; font-size: 10pt; }

  .jcm-print-section { margin-bottom: 24px; }
  .jcm-print-section h2 { font-size: 13pt; background: #1a237e; color: #fff; padding: 6px 12px; margin: 0 0 8px; border-radius: 4px; }
  .jcm-print-section h3 { font-size: 10pt; color: #555; margin: 10px 0 4px; }

  .jcm-print-table {
    width: 100%; border-collapse: collapse;
    font-size: 9pt; margin-bottom: 12px;
    page-break-inside: avoid;
  }
  .jcm-print-table th { background: #1a237e; color: #fff; padding: 5px 8px; text-align: left; }
  .jcm-print-table td { padding: 5px 8px; border: 1px solid #ccc; }
  .jcm-print-table tr:nth-child(even) td { background: #f5f5f5; }
  .jcm-winner-cell { font-weight: 700; color: #1b5e20; }
  .jcm-vs { text-align: center; font-weight: 700; color: #e53935; }

  .jcm-print-footer { text-align: center; margin-top: 30px; font-size: 8pt; color: #888; border-top: 1px solid #ddd; padding-top: 8px; direction: rtl; }

  @page { size: A4; margin: 1.5cm; }
}

/* =========================================================
   IJF BRACKET PRINT STYLES
   ========================================================= */
.jcm-bracket-sheet { width: 100%; }
.jcm-bracket-sheet svg { display: block; width: 100%; }

@media print {
  /* override all non-print content */
  .jcm-header, .jcm-tabs, .jcm-toolbar, .jcm-tab-content,
  .jcm-section-header, .jcm-comp-meta, .jcm-views > *:not(#jcm-view-detail),
  .jcm-modal-overlay, .jcm-toast, .jcm-btn-back,
  #jcm-tab-players, .jcm-detail-actions { display: none !important; }

  .jcm-wrap { padding: 0 !important; }
  .jcm-views { padding: 0 !important; max-width: none !important; }

  #jcm-print-area {
    display: block !important;
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important;
    background: white;
    z-index: 99999;
  }

  #jcm-print-area .jcm-bracket-sheet { page-break-after: always; }
  #jcm-print-area .jcm-bracket-sheet:last-child { page-break-after: auto; }

  @page {
    size: A4 landscape;
    margin: 6mm;
  }
}
