/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --primary:      #4a6fa5;
  --primary-dark: #3a5a8a;
  --primary-light:#e8f0fb;
  --success:      #2e7d32;
  --success-bg:   #e8f5e9;
  --warning:      #e65100;
  --warning-bg:   #fff3e0;
  --danger:       #c62828;
  --danger-bg:    #ffebee;
  --info:         #1565c0;
  --info-bg:      #e3f2fd;
  --text:         #1a1a2e;
  --text-muted:   #666;
  --border:       #dde1e9;
  --bg:           #f7f8fc;
  --card-bg:      #ffffff;
  --radius:       8px;
  --shadow:       0 1px 4px rgba(0,0,0,.08);
  --shadow-md:    0 3px 12px rgba(0,0,0,.12);
  --nav-h:        54px;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--primary);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.nav-brand { color: #fff; font-size: 1.1rem; font-weight: 700; }
.nav-links { display: flex; align-items: center; gap: .25rem; }
.nav-links a {
  color: rgba(255,255,255,.85); padding: .35rem .75rem;
  border-radius: var(--radius); font-size: .9rem; transition: background .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,.18); color: #fff; text-decoration: none;
}
.nav-user {
  display: flex; align-items: center; gap: .25rem;
  border-left: 1px solid rgba(255,255,255,.3); margin-left: .5rem; padding-left: .75rem;
}
.nav-user span { color: rgba(255,255,255,.7); font-size: .85rem; margin-right: .25rem; }

/* ── Container ─────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius);
  margin-bottom: 1rem; font-size: .9rem;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a5d6a7; }
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #ef9a9a; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #90caf9; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #ffb74d; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .45rem .9rem; border-radius: var(--radius);
  border: none; cursor: pointer; font-size: .875rem; font-weight: 500;
  font-family: var(--font); transition: filter .15s, opacity .15s;
  white-space: nowrap; text-decoration: none !important;
}
.btn:hover { filter: brightness(.92); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-secondary{ background: #e2e8f0; color: var(--text); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline  { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-full     { width: 100%; justify-content: center; }
.btn-sm       { padding: .3rem .65rem; font-size: .8rem; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.form-group label { font-size: .85rem; font-weight: 600; color: #444; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 160px; }
.flex-2 { flex: 2; min-width: 200px; }
.form-group-bottom { justify-content: flex-end; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }
.required { color: var(--danger); }
.help-text { font-size: .78rem; color: var(--text-muted); font-weight: 400; }
.current-file { font-size: .8rem; margin-left: .5rem; }

input[type="text"], input[type="password"], input[type="file"],
select, textarea {
  width: 100%; padding: .5rem .7rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font); font-size: .9rem; color: var(--text);
  background: #fff; transition: border-color .15s;
}
input[type="text"]:focus, input[type="password"]:focus,
select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74,111,165,.12);
}
input[type="file"] { padding: .4rem; }
textarea { resize: vertical; }

.narrow-form { max-width: 460px; }

/* ── Checkbox grid ─────────────────────────────────────────────────────────── */
.checkbox-grid {
  display: flex; flex-wrap: wrap; gap: .5rem;
}
.checkbox-label {
  display: flex; align-items: center; gap: .35rem;
  padding: .35rem .7rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: .85rem; user-select: none;
  transition: border-color .15s, background .15s;
}
.checkbox-label:hover { border-color: var(--primary); background: var(--primary-light); }
.checkbox-label input { accent-color: var(--primary); }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-page { background: linear-gradient(135deg, #3a5a8a 0%, #5b7ec9 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; border-radius: 14px; padding: 2.5rem; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-header { text-align: center; margin-bottom: 1.75rem; }
.login-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.login-header h1 { font-size: 1.5rem; color: var(--text); }
.login-header p { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; }

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 { font-size: 1.4rem; }
.count { font-size: .85rem; font-weight: 400; color: var(--text-muted); margin-left: .4rem; }
.breadcrumb { margin-bottom: .75rem; font-size: .85rem; color: var(--text-muted); }

/* ── Search bar ────────────────────────────────────────────────────────────── */
.search-bar { margin-bottom: 1.25rem; }
.search-input-wrap { display: flex; gap: .6rem; margin-bottom: .6rem; }
.search-input { flex: 1; }
.filter-cats { display: flex; flex-wrap: wrap; gap: .4rem; }
.cat-checkbox {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .6rem; border-radius: 99px;
  border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: .8rem; user-select: none;
  transition: all .15s;
}
.cat-checkbox:hover, .cat-checkbox.checked {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.cat-checkbox input { display: none; }

/* ── Song grid ─────────────────────────────────────────────────────────────── */
.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: .85rem;
}
.song-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1rem;
  display: flex; flex-direction: column; gap: .35rem;
  transition: box-shadow .15s, border-color .15s;
  color: var(--text); text-decoration: none !important;
}
.song-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); }
.song-card-title { font-weight: 600; font-size: .95rem; }
.song-card-author { font-size: .82rem; color: var(--text-muted); }
.song-card-cats { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.song-card-icons { font-size: .9rem; margin-top: auto; padding-top: .3rem; }

/* ── Category tags ─────────────────────────────────────────────────────────── */
.cat-tag {
  font-size: .75rem; padding: .15rem .5rem;
  border-radius: 99px; background: var(--primary-light); color: var(--primary);
  border: 1px solid #c5d8f5; font-weight: 500;
}

/* ── Song detail ───────────────────────────────────────────────────────────── */
.song-detail-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.song-detail-header h1 { font-size: 1.6rem; }
.song-author { color: var(--text-muted); font-size: .95rem; margin-top: .15rem; }
.song-theme { font-size: .88rem; color: var(--text-muted); margin-top: .15rem; }
.song-cats { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.song-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.song-partitions { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.lyrics-display { max-width: 700px; }
.lyrics-section { margin-bottom: 1rem; }
.lyrics-prefix { font-weight: 700; font-size: .85rem; display: block; color: #444; }
.lyrics-line { display: block; line-height: 1.55; }
.lyrics-section.refrain .lyrics-line { font-style: italic; }
.empty-lyrics { color: var(--text-muted); font-style: italic; }

/* ── Song form ─────────────────────────────────────────────────────────────── */
.song-form { max-width: 860px; }
.lyrics-example {
  background: #f9fafb; border: 1px dashed var(--border);
  border-radius: var(--radius); padding: .5rem .75rem;
  margin-bottom: .4rem; font-size: .78rem; color: var(--text-muted);
}
.lyrics-editor { font-family: 'Courier New', monospace; font-size: .88rem; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.card h3 { font-size: .95rem; margin-bottom: .85rem; color: #333; }
.mb-2 { margin-bottom: 1.25rem; }

/* ── Feuille builder ───────────────────────────────────────────────────────── */
.feuille-layout { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.feuille-sidebar { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 1rem; }
.feuille-main { flex: 1; min-width: 300px; }
.feuille-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .6rem; flex-wrap: wrap; gap: .5rem;
}
.feuille-header h2 { font-size: 1.1rem; }
.help-hint { font-size: .82rem; color: var(--text-muted); margin-bottom: .75rem; }

.search-results-list {
  list-style: none; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; max-height: 260px; overflow-y: auto;
  display: none;
}
.search-results-list:not(:empty) { display: block; }
.search-result-item {
  padding: .5rem .75rem; cursor: pointer; font-size: .88rem;
  border-bottom: 1px solid var(--border); transition: background .1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-light); }
.search-result-item.already-added { color: var(--text-muted); cursor: default; font-style: italic; }
.no-results { padding: .5rem .75rem; color: var(--text-muted); font-size: .85rem; }

.selected-songs-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }
.selected-song-card {
  display: flex; align-items: flex-start; gap: .6rem;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem .9rem;
  box-shadow: var(--shadow);
}
.song-card-drag {
  cursor: grab; font-size: 1.2rem; color: #bbb; padding-top: .1rem;
  user-select: none; flex-shrink: 0;
}
.song-card-drag:active { cursor: grabbing; }
.song-card-body { flex: 1; min-width: 0; }
.song-card-title-row {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem;
}
.song-card-num { color: var(--text-muted); font-size: .85rem; flex-shrink: 0; }
.song-card-title-row strong { flex: 1; font-size: .93rem; }
.btn-remove {
  background: none; border: none; cursor: pointer; color: #aaa;
  font-size: .9rem; padding: .1rem .3rem; border-radius: 4px;
  line-height: 1; flex-shrink: 0;
}
.btn-remove:hover { color: var(--danger); background: var(--danger-bg); }
.song-card-parts { display: flex; flex-wrap: wrap; gap: .35rem; }
.part-label {
  display: flex; align-items: center; gap: .25rem;
  font-size: .78rem; padding: .15rem .45rem;
  border-radius: 99px; border: 1px solid var(--border);
  background: #f4f6fa; cursor: pointer; user-select: none;
}
.part-label input { accent-color: var(--primary); }
.no-parts { font-size: .8rem; color: var(--text-muted); font-style: italic; }

/* ── Admin ─────────────────────────────────────────────────────────────────── */
.stats-grid { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-card {
  flex: 1; min-width: 150px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; text-align: center; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .4rem; align-items: center;
}
.stat-warning { border-color: #ffb74d; background: var(--warning-bg); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .82rem; color: var(--text-muted); }

.admin-nav-cards { display: flex; gap: 1rem; flex-wrap: wrap; }
.admin-nav-card {
  flex: 1; min-width: 170px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; display: flex; align-items: center; gap: .6rem;
  font-weight: 500; color: var(--text); transition: box-shadow .15s;
  text-decoration: none !important;
}
.admin-nav-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); }
.admin-nav-card.highlight { border-color: var(--warning); }
.admin-nav-icon { font-size: 1.4rem; }

.proposals-list { display: flex; flex-direction: column; gap: .75rem; }
.proposal-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.proposal-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: .5rem; flex-wrap: wrap;
  margin-bottom: .6rem;
}
.proposal-meta { font-size: .8rem; color: var(--text-muted); display: flex; gap: .75rem; }
.proposal-meta-text { font-size: .85rem; color: var(--text-muted); margin-bottom: 1rem; }
.proposal-current { font-size: .85rem; color: var(--text-muted); }
.proposal-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.reject-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.reject-reason-input { width: 220px; padding: .3rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .82rem; }

.proposal-action-badge {
  display: inline-block; font-size: .75rem; padding: .15rem .5rem;
  border-radius: 99px; font-weight: 600; margin-right: .4rem;
}
.action-create { background: var(--success-bg); color: var(--success); }
.action-edit   { background: var(--info-bg);    color: var(--info); }

.diff-view { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.diff-col { flex: 1; min-width: 260px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.diff-current { border-left: 3px solid #90caf9; }
.diff-proposed { border-left: 3px solid #a5d6a7; }
.diff-col h3 { margin-bottom: .75rem; font-size: .9rem; }
.diff-col dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .75rem; font-size: .85rem; margin-bottom: .75rem; }
.diff-col dt { color: var(--text-muted); font-weight: 600; }

.lyrics-preview { font-size: .85rem; margin-top: .5rem; }
.lyrics-preview > div { margin-bottom: .6rem; }
.lyric-italic .lyric-line { font-style: italic; }
.lyric-line { display: block; margin-left: .5rem; }

.proposal-preview { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; }
.proposal-preview dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .75rem; font-size: .85rem; margin-bottom: .75rem; }
.proposal-preview dt { color: var(--text-muted); font-weight: 600; }

.review-actions { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.review-actions .inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ── Data table ────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: .88rem; }
.data-table th { background: #f0f2f7; padding: .6rem .85rem; text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.data-table td { padding: .6rem .85rem; border-top: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: var(--primary-light); }

.inline-form-row { display: flex; gap: .4rem; align-items: center; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: 99px; font-weight: 600; }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.role-badge { font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; }
.role-admin { background: #fce4ec; color: #c2185b; }
.role-user  { background: #e8f5e9; color: var(--success); }
.muted { color: var(--text-muted); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .feuille-sidebar { width: 100%; }
  .nav-links a span { display: none; }
  .song-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
