/**
 * Feuille de style du widget CliniOutils.
 *
 * Toutes les règles sont préfixées `.cot-` et descendent de `.cot-root`.
 * Les propriétés sont écrites en toutes lettres plutôt qu'héritées, parce que
 * les thèmes WordPress stylent agressivement `input`, `button` et `label` :
 * sans cela, le widget prend l'apparence du thème de façon imprévisible.
 */

.cot-root {
  --cot-brand: #0f4864;
  --cot-text: #1a2330;
  --cot-muted: #5b6878;
  --cot-line: #dde3ea;
  --cot-bg: #ffffff;
  --cot-soft: #f5f7fa;
  --cot-radius: 10px;

  --cot-neutral: #5b6878;
  --cot-success: #1a7f52;
  --cot-info: #1b6ca8;
  --cot-warning: #a8671b;
  --cot-danger: #b3261e;

  box-sizing: border-box;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0;
  color: var(--cot-text);
  background: var(--cot-bg);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  text-align: left;
}

.cot-root *,
.cot-root *::before,
.cot-root *::after {
  box-sizing: border-box;
}

/* ---------------------------------------------------------------- */
/* En-tête                                                           */
/* ---------------------------------------------------------------- */

.cot-header {
  margin: 0 0 1.5rem;
}

.cot-title {
  margin: 0 0 0.5rem;
  color: var(--cot-brand);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
}

.cot-description {
  margin: 0;
  color: var(--cot-muted);
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- */
/* Formulaire                                                        */
/* ---------------------------------------------------------------- */

.cot-form {
  margin: 0 0 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--cot-line);
  border-radius: var(--cot-radius);
  background: var(--cot-soft);
}

.cot-group {
  margin: 0 0 1.25rem;
  padding: 0.75rem 0 0;
  border: 0;
  border-top: 1px solid var(--cot-line);
}

.cot-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.cot-group-title {
  padding: 0;
  color: var(--cot-brand);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cot-field {
  margin: 0 0 1.1rem;
}

.cot-field:last-child {
  margin-bottom: 0;
}

.cot-label {
  display: block;
  margin: 0 0 0.4rem;
  color: var(--cot-text);
  font-size: 0.95rem;
  font-weight: 600;
}

.cot-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.cot-input,
.cot-unit {
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--cot-line);
  border-radius: 8px;
  background: var(--cot-bg);
  color: var(--cot-text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
}

.cot-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

.cot-unit {
  flex: 0 0 auto;
  min-width: 5.5rem;
  cursor: pointer;
}

.cot-input:focus-visible,
.cot-unit:focus-visible,
.cot-choice:focus-visible,
.cot-submit:focus-visible,
.cot-reset:focus-visible,
.cot-copy:focus-visible {
  outline: 2px solid var(--cot-brand);
  outline-offset: 2px;
}

.cot-unit-static {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 0 0.6rem;
  color: var(--cot-muted);
  font-size: 0.9rem;
}

.cot-help {
  margin: 0.35rem 0 0;
  color: var(--cot-muted);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------- */
/* Choix                                                             */
/* ---------------------------------------------------------------- */

.cot-choices {
  display: flex;
  gap: 0.5rem;
}

.cot-choices-segmented {
  flex-wrap: wrap;
}

.cot-choices-stack {
  flex-direction: column;
}

.cot-choice {
  flex: 1 1 auto;
  min-height: 2.75rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--cot-line);
  border-radius: 8px;
  background: var(--cot-bg);
  color: var(--cot-text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.cot-choices-segmented .cot-choice {
  text-align: center;
}

.cot-choice:hover {
  border-color: var(--cot-brand);
}

.cot-choice-on {
  border-color: var(--cot-brand);
  background: var(--cot-brand);
  color: #ffffff;
}

.cot-choice-label {
  display: block;
  font-weight: 600;
}

.cot-choice-help {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.8;
}

/* ---------------------------------------------------------------- */
/* Actions                                                           */
/* ---------------------------------------------------------------- */

.cot-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.cot-submit,
.cot-reset,
.cot-copy {
  min-height: 2.75rem;
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--cot-brand);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.cot-submit {
  background: var(--cot-brand);
  color: #ffffff;
}

.cot-reset,
.cot-copy {
  background: transparent;
  color: var(--cot-brand);
}

/* ---------------------------------------------------------------- */
/* Résultat                                                          */
/* ---------------------------------------------------------------- */

.cot-result {
  margin: 0 0 1rem;
  padding: 1.25rem;
  border: 1px solid var(--cot-line);
  border-left: 5px solid var(--cot-neutral);
  border-radius: var(--cot-radius);
  background: var(--cot-bg);
}

.cot-tone-success { border-left-color: var(--cot-success); }
.cot-tone-info    { border-left-color: var(--cot-info); }
.cot-tone-warning { border-left-color: var(--cot-warning); }
.cot-tone-danger  { border-left-color: var(--cot-danger); }

.cot-result-label {
  margin: 0 0 0.2rem;
  color: var(--cot-muted);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.cot-result-value {
  margin: 0 0 0.5rem;
  color: var(--cot-brand);
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.15;
}

.cot-result-unit {
  font-size: 1.1rem;
  font-weight: 600;
}

.cot-band {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.cot-tone-success .cot-band { color: var(--cot-success); }
.cot-tone-info    .cot-band { color: var(--cot-info); }
.cot-tone-warning .cot-band { color: var(--cot-warning); }
.cot-tone-danger  .cot-band { color: var(--cot-danger); }

.cot-meaning {
  margin: 0;
  font-size: 0.95rem;
}

.cot-details {
  margin: 0.9rem 0 0;
  padding: 0.9rem 0 0;
  border-top: 1px solid var(--cot-line);
  list-style: none;
}

.cot-details li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0;
  font-size: 0.9rem;
}

.cot-detail-value {
  font-weight: 700;
  white-space: nowrap;
}

.cot-warnings {
  margin: 0.9rem 0 0;
  padding: 0.75rem 0.9rem 0.75rem 2rem;
  border-radius: 8px;
  background: #fdf6ec;
  color: var(--cot-warning);
  font-size: 0.88rem;
}

.cot-incomplete,
.cot-error,
.cot-failed {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--cot-soft);
  color: var(--cot-muted);
  font-size: 0.9rem;
}

.cot-error,
.cot-failed {
  background: #fdeceb;
  color: var(--cot-danger);
}

.cot-loading {
  padding: 1.5rem;
  color: var(--cot-muted);
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- */
/* Compte rendu                                                      */
/* ---------------------------------------------------------------- */

.cot-report {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px dashed var(--cot-line);
  border-radius: var(--cot-radius);
  background: var(--cot-soft);
}

.cot-report-title {
  margin: 0 0 0.4rem;
  color: var(--cot-muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cot-report-text {
  margin: 0 0 0.75rem;
  font-size: 0.93rem;
}

/* ---------------------------------------------------------------- */
/* Sections éditoriales                                              */
/* ---------------------------------------------------------------- */

.cot-section {
  margin: 0 0 1.5rem;
}

.cot-section-title {
  margin: 0 0 0.4rem;
  color: var(--cot-brand);
  font-size: 1.05rem;
  font-weight: 700;
}

.cot-section-body {
  margin: 0;
  font-size: 0.95rem;
}

.cot-list,
.cot-references {
  margin: 0;
  padding-left: 1.3rem;
  font-size: 0.92rem;
}

.cot-list li,
.cot-references li {
  margin-bottom: 0.4rem;
}

.cot-references {
  color: var(--cot-muted);
  font-size: 0.85rem;
}

.cot-ref-link {
  color: var(--cot-brand);
}

.cot-disclaimer {
  margin: 1.5rem 0 0;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: var(--cot-soft);
  color: var(--cot-muted);
  font-size: 0.85rem;
}

.cot-credit {
  margin: 0.75rem 0 0;
  color: var(--cot-muted);
  font-size: 0.8rem;
  text-align: right;
}

.cot-credit a {
  color: var(--cot-brand);
}

/* ---------------------------------------------------------------- */
/* Écrans étroits                                                    */
/* ---------------------------------------------------------------- */

@media (max-width: 640px) {
  .cot-root { font-size: 15px; }
  .cot-form { padding: 1rem; }
  .cot-result-value { font-size: 1.8rem; }
  .cot-choices-segmented { flex-direction: column; }
  .cot-actions { flex-direction: column; }
}

/* ---------------------------------------------------------------- */
/* Impression                                                        */
/* ---------------------------------------------------------------- */

@media print {
  .cot-actions,
  .cot-copy,
  .cot-credit { display: none; }
  .cot-root { max-width: none; }
  .cot-form { background: transparent; }
}
