/* ============================================================
   MED — My Escrime Data  |  style.css
   Thème   : Épée — navy #1e3a5f  |  gold #d4a017  |  bg #f0f4f8
   Police  : Inter
   Icônes  : trait fin (stroke-width 1.5) sauf entraînement (plein)
   Logo    : pictogramme olympique escrime
   ============================================================ */

:root {
  --primary:   #1e3a5f;
  --primary-d: #122540;
  --accent:    #d4a017;
  --accent-d:  #b8870e;
  --bg:        #f0f4f8;
  --card:      #ffffff;
  --text:      #1a1a2e;
  --muted:     #6b7a90;
  --border:    #dde3ec;
  --danger:    #c0392b;
  --success:   #27ae60;
  --victory:   #1a7a3c;
  --defeat:    #c0392b;
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 2px 14px rgba(30,58,95,.11);
  --font:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Utilitaires ─────────────────────────────────────────── */
.hidden { display: none !important; }
.opt { color: var(--muted); font-weight: 400; font-size: .85em; }
.flex-1 { flex: 1; }

/* ── Header ─────────────────────────────────────────────── */
header {
  background: var(--primary);
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(0,0,0,.22);
}

.logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 26px; height: 26px; fill: var(--primary); display: block; }

.header-text { flex: 1; }
.header-title { font-size: 1.3rem; font-weight: 800; letter-spacing: .07em; color: var(--accent); line-height: 1; }
.header-user  { font-size: 1.3rem; font-weight: 800; letter-spacing: .07em; color: var(--accent); opacity: .7; }
.header-sub   { font-size: .68rem; opacity: .55; margin-top: 2px; font-weight: 500; }
.header-date  { font-size: .75rem; opacity: .65; text-align: right; line-height: 1.4; font-weight: 500; }

/* ── Tab bar ─────────────────────────────────────────────── */
.tab-bar { display: flex; background: var(--primary-d); }

.tab {
  flex: 1; padding: 10px 4px; border: none; background: transparent;
  color: rgba(255,255,255,.45); font-family: var(--font); font-size: .8rem;
  font-weight: 700; cursor: pointer; border-bottom: 3px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: color .2s, border-color .2s;
}
.tab svg { width: 15px; height: 15px; flex-shrink: 0; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Tab content ─────────────────────────────────────────── */
.tab-content { padding: 14px; }

/* ── Screen header ───────────────────────────────────────── */
.screen-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.screen-title { font-size: 1.05rem; font-weight: 800; color: var(--primary); }
.screen-header-text { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.form-hint { font-size: 0.72rem; color: #b0bcc8; margin: 0; font-style: italic; }

.btn-back {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--card); cursor: pointer; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
  transition: border-color .2s;
}
.btn-back svg { width: 16px; height: 16px; color: var(--primary); }
.btn-back:hover { border-color: var(--primary); }

.btn-add {
  display: flex; align-items: center; gap: 5px; padding: 7px 12px;
  background: var(--primary); color: #fff; border: none; border-radius: 20px;
  font-family: var(--font); font-size: .82rem; font-weight: 700; cursor: pointer;
  flex-shrink: 0; transition: background .2s;
}
.btn-add svg { width: 14px; height: 14px; }
.btn-add:hover { background: var(--primary-d); }

/* ── Cards list ──────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 10px; max-width: 600px; margin: 0 auto; }

.empty-msg { text-align: center; color: var(--muted); padding: 48px 0; font-size: .9rem; }

/* ── Compétition card (liste) ────────────────────────────── */
.comp-card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: flex; gap: 12px; align-items: flex-start;
  border-left: 4px solid var(--primary); cursor: pointer;
  transition: box-shadow .15s;
}
.comp-card:hover { box-shadow: 0 4px 20px rgba(30,58,95,.18); }
.comp-card.terminee { border-left-color: var(--muted); opacity: .75; }

.comp-date-col { min-width: 46px; text-align: center; }
.comp-day  { font-size: 1.3rem; font-weight: 800; color: var(--primary); line-height: 1; }
.comp-month { font-size: .68rem; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.comp-body { flex: 1; min-width: 0; }
.comp-nom { font-size: .97rem; font-weight: 700; margin-bottom: 4px; }
.comp-meta { font-size: .75rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.comp-badge {
  padding: 2px 7px; border-radius: 20px; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  background: #e8f0fe; color: var(--primary);
}
.comp-badge.terminee { background: #eee; color: var(--muted); }
.comp-badge.en-cours { background: #fef3e2; color: #8a5c00; }

/* ── Assault card (entraînement / historique) ────────────── */
.assault-card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: flex; gap: 12px; align-items: flex-start;
  border-left: 4px solid var(--primary);
}
.assault-meta { min-width: 50px; display: flex; flex-direction: column; align-items: center; }
.assault-time  { font-size: .78rem; font-weight: 700; color: var(--primary); }
.assault-badge {
  margin-top: 5px; padding: 3px 7px; border-radius: 20px;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.badge-entrainement { background: #e8f0fe; color: var(--primary); }
.badge-competition  { background: #fef3e2; color: #8a5c00; }

.assault-body { flex: 1; min-width: 0; }
.assault-date  { font-size: .75rem; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.assault-notes { font-size: .92rem; line-height: 1.52; white-space: pre-wrap; }
.assault-notes.empty { color: var(--muted); font-style: italic; }

.del-btn {
  background: none; border: none; color: #d0d8e4; cursor: pointer;
  padding: 4px; border-radius: 6px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; transition: color .2s;
}
.del-btn svg { width: 16px; height: 16px; }
.del-btn:hover { color: var(--danger); }

/* ── Form card ───────────────────────────────────────────── */
.form-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); max-width: 600px; margin: 0 auto;
}

/* ── Champs ──────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

.field-input, .field-textarea {
  font-family: var(--font); font-size: .95rem; color: var(--text);
  background: var(--bg); border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%;
  transition: border-color .2s, background .2s;
}
.field-input:focus, .field-textarea:focus {
  outline: none; border-color: var(--primary); background: var(--card);
}
.field-textarea { min-height: 90px; resize: vertical; line-height: 1.55; padding-right: 50px; }
select.field-input { cursor: pointer; }

.field-row { display: flex; gap: 10px; }
.field-row .field-group { flex: 1; }

/* ── Radio / Toggle buttons ──────────────────────────────── */
.radio-row, .toggle-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.radio-row.wrap { flex-wrap: wrap; }

.radio-btn, .toggle-btn {
  flex: 1; padding: 9px 6px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card);
  color: var(--muted); font-family: var(--font); font-weight: 700;
  font-size: .82rem; cursor: pointer; text-align: center; white-space: nowrap;
  transition: border-color .2s, color .2s, background .2s;
}
.radio-btn.active, .toggle-btn.active {
  border-color: var(--primary); background: var(--primary); color: #fff;
}

/* ── Notes area (avec micro) ─────────────────────────────── */
.notes-area { position: relative; }

.mic-btn {
  position: absolute; right: 10px; bottom: 10px;
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(30,58,95,.25);
  transition: background .2s, transform .1s;
}
.mic-btn svg { width: 16px; height: 16px; }
.mic-btn:hover  { background: var(--primary-d); }
.mic-btn:active { transform: scale(.93); }
.mic-btn.listening { background: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,.4); }
  50%       { box-shadow: 0 0 0 8px rgba(192,57,43,0); }
}

/* ── Save button ─────────────────────────────────────────── */
.save-btn {
  width: 100%; padding: 13px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm); font-family: var(--font);
  font-size: .97rem; font-weight: 800; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .2s, transform .1s;
}
.save-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.save-btn:hover  { background: var(--accent-d); }
.save-btn:active { transform: scale(.98); }

/* ── Feedback ────────────────────────────────────────────── */
.feedback { margin-top: 10px; min-height: 20px; font-size: .85rem; font-weight: 600; text-align: center; }
.feedback.ok    { color: var(--success); }
.feedback.error { color: var(--danger); }

/* ── Number picker (nb tireurs poule) ────────────────────── */
.number-picker {
  display: flex; align-items: center; justify-content: center;
  gap: 20px; margin: 18px 0 8px;
}
.num-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--primary); background: transparent;
  color: var(--primary); font-size: 1.4rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s;
}
.num-btn:hover { background: var(--primary); color: #fff; }
.num-val { font-size: 2.4rem; font-weight: 800; color: var(--primary); min-width: 60px; text-align: center; }
.num-hint { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 18px; }

/* ── Progress bar (poule) ────────────────────────────────── */
.progress-bar {
  height: 4px; background: var(--border); border-radius: 2px;
  margin: -10px 0 14px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width .4s ease;
}

/* ── Step info / done ────────────────────────────────────── */
.step-info {
  display: flex; align-items: center; gap: 8px;
  background: #e8f0fe; color: var(--primary);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: .9rem; font-weight: 600; margin-bottom: 16px;
}
.step-done {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 20px 0; color: var(--success);
  font-size: 1rem; font-weight: 700;
}

/* ── Score row ───────────────────────────────────────────── */
.score-row {
  display: flex; align-items: flex-end; gap: 8px; margin-bottom: 14px;
}
.score-field { flex: 1; }
.score-input { text-align: center; font-size: 1.2rem; font-weight: 800; padding: 10px 6px; }
.score-sep { font-size: 1.4rem; font-weight: 800; color: var(--muted); padding-bottom: 8px; }

/* ── Tour badge ──────────────────────────────────────────── */
.tour-badge {
  display: inline-block; padding: 5px 14px; border-radius: 20px;
  background: var(--primary); color: #fff;
  font-size: .82rem; font-weight: 800; letter-spacing: .04em;
  margin-bottom: 16px;
}

/* ── Btn row (victoire / défaite / passer) ───────────────── */
.btn-row { display: flex; gap: 10px; margin-bottom: 10px; }

.btn-secondary {
  padding: 11px 18px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font-family: var(--font);
  font-weight: 700; font-size: .9rem; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-secondary:hover { border-color: var(--muted); color: var(--text); }

.btn-victory {
  flex: 1; padding: 13px; background: var(--victory); color: #fff;
  border: none; border-radius: var(--radius-sm); font-family: var(--font);
  font-size: .97rem; font-weight: 800; cursor: pointer;
  transition: opacity .2s;
}
.btn-victory:hover { opacity: .88; }

.btn-defeat {
  flex: 1; padding: 13px; background: var(--defeat); color: #fff;
  border: none; border-radius: var(--radius-sm); font-family: var(--font);
  font-size: .97rem; font-weight: 800; cursor: pointer;
  transition: opacity .2s;
}
.btn-defeat:hover { opacity: .88; }

.btn-correct {
  width: 100%; padding: 8px; border: none; background: transparent;
  color: var(--muted); font-family: var(--font); font-size: .78rem;
  font-weight: 600; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 5px; transition: color .2s;
}
.btn-correct:hover { color: var(--primary); }

/* ── Photo upload ────────────────────────────────────────── */
.photo-upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 20px; text-align: center; color: var(--muted);
  margin-bottom: 14px;
}
.photo-upload-zone svg { color: var(--muted); margin-bottom: 8px; }
.photo-upload-zone p { font-size: .88rem; margin-bottom: 10px; }

.btn-photo {
  padding: 8px 16px; border: 2px solid var(--primary); border-radius: 20px;
  background: transparent; color: var(--primary); font-family: var(--font);
  font-weight: 700; font-size: .82rem; cursor: pointer;
  transition: background .2s, color .2s;
}
.btn-photo:hover { background: var(--primary); color: #fff; }

.photo-status { font-size: .78rem; margin-top: 8px; font-weight: 600; }
.photo-status.ok    { color: var(--success); }
.photo-status.error { color: var(--danger); }

/* ── Detail section title ────────────────────────────────── */
.detail-section-title {
  font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
  margin-bottom: 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Assault rows (collapsibles dans la vue détail) ──────── */
.assault-row {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px; overflow: hidden;
}
.assault-row-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; cursor: pointer; background: var(--bg);
  transition: background .15s;
}
.assault-row-head:hover { background: #e4ebf5; }

.row-num {
  font-size: .72rem; font-weight: 800; color: var(--primary);
  text-transform: uppercase; min-width: 52px; flex-shrink: 0;
}
.row-adv { flex: 1; font-size: .9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-score { font-size: .82rem; font-weight: 700; color: var(--muted); white-space: nowrap; }

.result-badge {
  padding: 2px 7px; border-radius: 20px; font-size: .72rem; font-weight: 800; flex-shrink: 0;
}
.result-badge.victory { background: #d4edda; color: var(--victory); }
.result-badge.defeat  { background: #f8d7da; color: var(--defeat); }
.result-badge.unknown { background: #e2e8f0; color: var(--muted); }

.row-chevron {
  width: 16px; height: 16px; color: var(--muted); flex-shrink: 0;
  transition: transform .25s;
}
.row-chevron.rotated { transform: rotate(180deg); }

.assault-row-body {
  padding: 12px; background: var(--card);
  border-top: 1px solid var(--border);
}
.row-comment {
  font-size: .88rem; color: var(--muted); margin-bottom: 10px;
  font-style: italic; white-space: pre-wrap;
}

/* ── Photo gallery ───────────────────────────────────────── */
.photo-gallery { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-thumb {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-decoration: none;
}
.photo-thumb img {
  width: 90px; height: 90px; object-fit: cover;
  border-radius: var(--radius-sm); border: 2px solid var(--border);
}
.photo-thumb span { font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
