/* ============================================================
   Ohmelec App — Composants (boutons, cartes, champs, modal, etc.)
   ============================================================ */

/* Reset minimal */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--ff-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, picture { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; padding: 0; }
a { color: var(--c-blue-light); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--c-blue); }

/* Typographie */
h1, h2, h3, h4 {
  font-family: var(--ff-heading);
  color: var(--c-blue);
  line-height: var(--lh-tight);
  margin: 0 0 var(--s-4);
  font-weight: 800;
  letter-spacing: -.01em;
}
h1 { font-size: clamp(1.5rem, 2.5vw + 1rem, 2rem); }
h2 { font-size: clamp(1.25rem, 1.5vw + .8rem, 1.5rem); }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 var(--s-3); }

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .75rem;
  font-weight: 700;
  color: var(--c-green);
  margin-bottom: var(--s-2);
}

.muted { color: var(--c-text-soft); }
.small { font-size: .9rem; }
.xs { font-size: .8rem; }

/* Layout */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--s-4);
}

.section { padding: var(--s-5) 0; }

.grid { display: grid; gap: var(--s-4); }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid--2 { grid-template-columns: 1fr 1fr; }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
}

/* Header app */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  min-height: var(--header-h);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  gap: var(--s-3);
}
.brand {
  font-family: var(--ff-heading);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--c-blue);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.brand-omega { color: var(--c-green); font-weight: 700; font-size: 1.35rem; line-height: 1; }
.brand-subtitle { color: var(--c-text-soft); font-weight: 600; font-size: .85rem; margin-left: var(--s-2); }

.header-actions { display: flex; gap: var(--s-2); align-items: center; }

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 12px 20px;
  font-family: var(--ff-heading);
  font-weight: 600;
  font-size: .95rem;
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
  line-height: 1.2;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--c-green); color: var(--c-white); }
.btn--primary:hover, .btn--primary:focus-visible { background: var(--c-green-dark); color: var(--c-white); }

.btn--secondary { background: transparent; color: var(--c-blue); border-color: var(--c-blue); }
.btn--secondary:hover, .btn--secondary:focus-visible { background: var(--c-blue); color: var(--c-white); }

.btn--ghost { background: var(--c-white); color: var(--c-blue); border-color: var(--c-border); }
.btn--ghost:hover { background: var(--c-bg-alt); }

.btn--danger { background: var(--c-error); color: var(--c-white); }
.btn--danger:hover { background: #8E2530; color: var(--c-white); }

.btn--icon { width: 44px; padding: 0; }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; }

.btn .icon { width: 18px; height: 18px; }

/* Cartes */
.card {
  background: var(--c-white);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--c-border);
}
.card--clickable { cursor: pointer; transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease); }
.card--clickable:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.card--accent { border-left: 4px solid var(--c-green); }
.card--warn { border-left: 4px solid var(--c-warn); background: var(--c-warn-bg); }
.card--error { border-left: 4px solid var(--c-error); background: var(--c-error-bg); }

/* Champs */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-bottom: var(--s-3);
}
.field > label {
  font-family: var(--ff-heading);
  font-weight: 600;
  color: var(--c-blue);
  font-size: .9rem;
}
.field .required { color: var(--c-error); margin-left: 2px; }
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="date"],
.field input[type="search"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  color: var(--c-text);
  background: var(--c-white);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  min-height: 44px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--c-green);
  box-shadow: 0 0 0 3px rgba(61, 139, 94, .2);
}
.field__hint { color: var(--c-text-soft); font-size: .8rem; margin-top: var(--s-1); }
.field__error { color: var(--c-error); font-size: .85rem; }

.field-row {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .field-row--2 { grid-template-columns: 1fr 1fr; }
  .field-row--3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* Checkbox & radio */
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  padding: 10px var(--s-3);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-white);
  font-size: .95rem;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  min-height: 44px;
}
.check:hover { border-color: var(--c-blue-light); }
.check input { width: 20px; height: 20px; accent-color: var(--c-green); flex-shrink: 0; }
.check.is-checked { border-color: var(--c-green); background: rgba(61, 139, 94, .08); }

.checks-grid {
  display: grid;
  gap: var(--s-2);
  grid-template-columns: 1fr;
}
@media (min-width: 480px) {
  .checks-grid--2 { grid-template-columns: 1fr 1fr; }
  .checks-grid--3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .checks-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .checks-grid--4 { grid-template-columns: repeat(4, 1fr); }
}

/* Choice (radio-like) */
.choice {
  background: var(--c-white);
  border: 2px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  font-family: var(--ff-heading);
  font-weight: 600;
  font-size: .9rem;
  color: var(--c-text);
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 48px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.choice:hover { border-color: var(--c-blue-light); color: var(--c-blue); }
.choice.is-active { background: var(--c-blue); border-color: var(--c-blue); color: var(--c-white); }

.choices-grid {
  display: grid;
  gap: var(--s-2);
  grid-template-columns: 1fr 1fr;
}
@media (min-width: 640px) { .choices-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .choices-grid { grid-template-columns: repeat(4, 1fr); } }

/* Badges / pastilles */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: .75rem;
  font-weight: 600;
  font-family: var(--ff-heading);
  background: var(--c-bg-alt);
  color: var(--c-text-soft);
}
.badge--demo { background: rgba(91, 138, 184, .15); color: var(--c-blue); }
.badge--green { background: var(--c-success-bg); color: var(--c-success); }
.badge--warn { background: var(--c-warn-bg); color: var(--c-warn); }
.badge--error { background: var(--c-error-bg); color: var(--c-error); }
.badge--blue { background: rgba(91, 138, 184, .15); color: var(--c-blue); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: var(--c-blue);
  color: var(--c-white);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  box-shadow: var(--sh-md);
  font-size: .9rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in .25s var(--ease);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 90vw;
}
.toast--success { background: var(--c-success); }
.toast--error { background: var(--c-error); }
.toast--warn { background: var(--c-warn); }
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 42, 71, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding: var(--s-3);
  animation: fadein .2s var(--ease);
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: var(--s-5); }
}
.modal {
  background: var(--c-white);
  border-radius: var(--r-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--s-5);
  box-shadow: var(--sh-lg);
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--s-4); }
@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Auto-save indicator */
.autosave-indicator {
  position: fixed;
  bottom: 12px;
  left: 12px;
  background: var(--c-success-bg);
  color: var(--c-success);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: .75rem;
  font-weight: 600;
  font-family: var(--ff-heading);
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
  z-index: 100;
  pointer-events: none;
}
.autosave-indicator.is-visible { opacity: 1; }

/* Stats / numbers */
.stat {
  background: var(--c-white);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--c-border);
}
.stat__label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-text-soft);
  font-weight: 600;
  margin-bottom: 4px;
}
.stat__value {
  font-family: var(--ff-heading);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--c-blue);
  line-height: 1.1;
}
.stat__value--green { color: var(--c-green); }
.stat__sub { font-size: .85rem; color: var(--c-text-soft); margin-top: 4px; }

/* Accessibilité */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
:focus-visible {
  outline: 3px solid var(--c-blue-light);
  outline-offset: 2px;
  border-radius: 2px;
}
.btn:focus-visible { outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
