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

:root {
  --primary:   #2c6e49;
  --primary-d: #1b4332;
  --accent:    #f4a261;
  --bg:        #f8f6f2;
  --card:      #ffffff;
  --text:      #1a1a1a;
  --muted:     #6b7280;
  --border:    #e5e7eb;
  --danger:    #dc2626;
  --gold:      #f59e0b;
  --radius:    12px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── Layout ────────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.page { flex: 1; display: flex; flex-direction: column; }

header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: .5px; }
header .subtitle { font-size: .75rem; opacity: .8; }

.nav-tabs {
  display: flex;
  background: var(--primary-d);
  padding: 0 8px;
}
.nav-tab {
  padding: 10px 16px;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  font-size: .85rem;
  border-bottom: 3px solid transparent;
  transition: all .15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.nav-tab.active { color: #fff; border-bottom-color: var(--accent); }
.nav-tab:hover { color: #fff; }

main { flex: 1; padding: 16px; max-width: 900px; margin: 0 auto; width: 100%; }

/* ── Login ─────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-d) 100%);
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-card h2 { font-size: 1.5rem; color: var(--primary); margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: .9rem; margin-bottom: 28px; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color .15s;
  background: var(--bg);
}
.form-group input:focus { outline: none; border-color: var(--primary); background: #fff; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.9); }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Score banner ──────────────────────────────────────────── */
.score-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.score-banner .score-val { font-size: 2rem; font-weight: 800; }
.score-banner .score-label { font-size: .8rem; opacity: .8; }
.score-banner .progress-wrap { flex: 1; }
.progress-bar { height: 8px; background: rgba(255,255,255,.2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }

/* ── Oeuvres table ─────────────────────────────────────────── */
.oeuvres-list { display: flex; flex-direction: column; gap: 12px; }

.oeuvre-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 2px solid var(--border);
  transition: border-color .15s;
}
.oeuvre-card.done { border-color: var(--primary); }

.oeuvre-card-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.oeuvre-col {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.oeuvre-col + .oeuvre-col {
  border-left: 1px solid var(--border);
}

.col-header {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 700;
}

.oeuvre-ref-img, .oeuvre-user-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  border-radius: 8px;
  background: #1a1a1a;
}

.oeuvre-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 8px;
  background: var(--bg);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: .8rem;
}
.oeuvre-placeholder .icon { font-size: 1.8rem; }

.oeuvre-footer {
  padding: 10px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.oeuvre-name { font-weight: 700; font-size: .95rem; }
.oeuvre-desc { font-size: .8rem; color: var(--muted); }
.oeuvre-points {
  background: var(--accent);
  color: #fff;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 700;
}
.oeuvre-points.earned { background: var(--primary); }

.btn-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Classement ────────────────────────────────────────────── */
.classement-list { display: flex; flex-direction: column; gap: 10px; }

.classement-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  border: 2px solid transparent;
}
.classement-card:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,.12); border-color: var(--primary); }
.classement-card.me { border-color: var(--primary); background: #f0faf4; }

.rank {
  font-size: 1.4rem;
  font-weight: 800;
  min-width: 36px;
  text-align: center;
  color: var(--muted);
}
.rank.gold { color: var(--gold); }
.rank.silver { color: #9ca3af; }
.rank.bronze { color: #b45309; }

.classement-info { flex: 1; }
.classement-pseudo { font-weight: 700; font-size: 1rem; }
.classement-meta { font-size: .8rem; color: var(--muted); }

.classement-score {
  text-align: right;
}
.classement-score .pts { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.classement-score .pts-label { font-size: .7rem; color: var(--muted); }

/* ── Profil ────────────────────────────────────────────────── */
.profil-header {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}
.profil-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
}
.profil-name { font-size: 1.3rem; font-weight: 700; }
.profil-score { color: var(--primary); font-weight: 700; font-size: 1rem; }

.profil-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }

.profil-photo-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}
.profil-photo-card.done { border-color: var(--primary); }
.profil-photo-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #1a1a1a;
}
.profil-photo-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--border);
}
.profil-photo-info { padding: 10px 12px; }
.profil-photo-info .name { font-weight: 600; font-size: .9rem; }
.profil-photo-info .pts { font-size: .8rem; color: var(--muted); }

/* ── Toast ─────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1a;
  color: #fff;
  padding: 12px 22px;
  border-radius: 24px;
  font-size: .9rem;
  opacity: 0;
  transition: all .25s;
  z-index: 999;
  max-width: 90vw;
  text-align: center;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--primary); }
#toast.error { background: var(--danger); }

/* ── Camera input (hidden) ─────────────────────────────────── */
#cameraInput { display: none; }

/* ── Loading ───────────────────────────────────────────────── */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px;
  color: var(--muted);
  font-size: .9rem;
  gap: 10px;
}
.spinner {
  width: 20px; height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ─────────────────────────────────────────────────── */
.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .88rem;
  margin-bottom: 12px;
  display: none;
}
.error-msg.show { display: block; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .oeuvre-card-inner { grid-template-columns: 1fr; }
  .oeuvre-col + .oeuvre-col { border-left: none; border-top: 1px solid var(--border); }
  .profil-grid { grid-template-columns: repeat(2, 1fr); }
  main { padding: 10px; }
}
