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

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --danger: #ff3b30;
  --success: #34c759;
  --warning: #ff9500;
  --border: #d2d2d7;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

/* === Header === */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 24px 32px;
  text-align: center;
}
header h1 { font-size: 1.5rem; font-weight: 700; }
header .subtitle { color: var(--text-secondary); font-size: 0.875rem; margin-top: 4px; }

/* === Main === */
main { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

/* === Tabs === */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { background: var(--primary); color: white; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* === Cards === */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header h2 { margin-bottom: 0; }

/* === Config grid === */
.config-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) {
  .config-grid { grid-template-columns: 1fr 1fr; }
  .config-grid > .card:first-child { grid-column: 1 / -1; }
}

/* === Forms === */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.form-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 120px;
}
input[type="text"],
input[type="number"],
select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

.form-actions { display: flex; gap: 8px; margin-top: 8px; }

/* === Buttons === */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  color: var(--text);
}
.btn:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fff0f0; }
.btn-icon {
  padding: 4px 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  border-radius: 4px;
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg); }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e8f0fe;
  color: var(--primary);
}
.badge-alt { background: #fef3e8; color: var(--warning); }
.badge-combo { background: #e8f8ee; color: var(--success); }

/* === Tags === */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
}
.tag-remove {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: none;
  padding: 0;
}
.tag-remove:hover { background: var(--danger); color: white; }

.hint { font-size: 0.82rem; color: var(--text-secondary); margin-top: 8px; }

/* === Table === */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid #f0f0f2; }
tbody tr:hover { background: #fafafa; }

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

/* === Stats bar === */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

/* === Alertes === */
.alertes {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
  font-size: 0.88rem;
}
.alertes p { margin-bottom: 4px; }
.alertes strong { color: var(--warning); }

/* === Planches === */
.planche-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}
.planche-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.planche-header h3 { font-size: 1rem; font-weight: 600; }
.planche-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.planche-meta .badge { font-size: 0.72rem; }

.planche-canvas-wrapper {
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: inline-block;
  max-width: 100%;
}
.planche-canvas-wrapper canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.planche-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 8px;
}

.fill-bar {
  width: 200px;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}
.fill-bar-inner {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

/* === Panier layout === */
.panier-layout { display: flex; flex-direction: column; gap: 16px; }

/* === Responsive === */
@media (max-width: 600px) {
  header { padding: 16px; }
  main { padding: 12px 8px; }
  .card { padding: 16px; }
  .form-row { flex-direction: column; }
  .form-row label { min-width: 100%; }
}

/* Color palette for visuals on canvas */
.color-0  { fill: #a8d8ea; }
.color-1  { fill: #aa96da; }
.color-2  { fill: #fcbad3; }
.color-3  { fill: #ffffd2; }
.color-4  { fill: #b5ead7; }
.color-5  { fill: #c7ceea; }
.color-6  { fill: #ffd3b6; }
.color-7  { fill: #dcedc1; }
.color-8  { fill: #f6d186; }
.color-9  { fill: #e2b4bd; }
.color-10 { fill: #bcd4e6; }
.color-11 { fill: #d4a5a5; }
