/**
 * Boussole v2.0 - Styles harmonisés avec myboussole.fr
 * Palette organique (sage/lavande/rose) + dégradé vitrine
 */

/* === VARIABLES === */
:root {
  /* Couleurs primaires — alignées sur vitrine */
  --color-primary: #6E877D;        /* sage (accent vitrine) */
  --color-primary-dark: #5a7268;   /* sage foncé (hover) */
  --color-primary-light: #d4e0da;  /* sage clair (backgrounds légers) */

  /* Curseurs (inchangés — sémantiques) */
  --color-low: #ef4444;
  --color-mid: #f97316;
  --color-high: #22c55e;

  /* Neutrals — palette vitrine */
  --color-bg: #F8F6F0;             /* paper2 vitrine */
  --color-card: #ffffff;
  --color-border: rgba(6,23,45,.12);  /* border vitrine */
  --color-text: #06172D;           /* ink vitrine (navy) */
  --color-text-muted: rgba(6,23,45,.58); /* muted2 vitrine */

  /* Typographie — alignée vitrine */
  --font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size-base: 16px;
  --font-size-small: 14px;
  --font-size-large: 18px;

  /* Espacements */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Radius — plus généreux, alignés vitrine */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;

  /* Ombres — douces comme vitrine */
  --shadow-card: 0 14px 34px rgba(6,23,45,.11);
  --shadow-soft: 0 4px 12px rgba(6,23,45,.08);
}

/* === RESET === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  /* Dégradé radial identique à la vitrine */
  background:
    radial-gradient(950px 620px at 14% 0%, rgba(201,185,217,.45), transparent 60%),
    radial-gradient(920px 620px at 86% 8%, rgba(232,183,200,.40), transparent 62%),
    radial-gradient(1200px 700px at 55% 115%, rgba(110,135,125,.26), transparent 60%),
    linear-gradient(180deg, #F8F6F0, #F3F0E8);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* === LAYOUT === */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--spacing-md);
}

.header {
  text-align: center;
  padding: var(--spacing-lg) 0;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
  color: var(--color-text);
}

.header h1 a::after {
  content: ' ↗';
  opacity: 0.4;
  font-size: 10px;
  vertical-align: super;
}

.header p {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

/* === NAVIGATION === */
.nav {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.nav-btn {
  flex: 1;
  padding: var(--spacing-md);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover {
  color: var(--color-text);
  background: rgba(110,135,125,.06);
}

.nav-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* === PANELS === */
.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* === CARD === */
.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--spacing-lg);
  border: 1px solid rgba(6,23,45,.06);
}

.card-title {
  font-size: var(--font-size-large);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
}

.card-hint {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-md);
}

/* === FIELD === */
.field {
  margin-bottom: var(--spacing-lg);
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
}

.field-value {
  display: inline-block;
  min-width: 32px;
  text-align: center;
  font-weight: 600;
  color: var(--color-primary);
}

/* === RANGE INPUT (CURSEUR) === */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(
    to right,
    var(--color-low) 0%,
    var(--color-mid) 50%,
    var(--color-high) 100%
  );
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--color-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(6,23,45,.18);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--color-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(6,23,45,.18);
}

input[type="range"]:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--spacing-xs);
  font-size: 12px;
  color: var(--color-text-muted);
}

/* === TEXTAREA === */
textarea {
  width: 100%;
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  resize: vertical;
  min-height: 80px;
  transition: border-color .2s, box-shadow .2s;
}

textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(110,135,125,.15);
}

.textarea-count {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: right;
  margin-top: var(--spacing-xs);
}

/* === RMSSD === */
.rmssd-block {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.rmssd-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.rmssd-optional {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
  background: rgba(6,23,45,.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
}

.rmssd-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

.rmssd-block input[type="number"] {
  width: 100%;
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  transition: border-color .2s, box-shadow .2s;
}

.rmssd-block input[type="number"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(110,135,125,.15);
}

/* === BUTTONS === */
.btn {
  display: inline-block;
  padding: 12px 24px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: white;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.btn-row {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
}

.btn-row .btn {
  flex: 1;
}

/* === STATUS === */
.status {
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
  font-size: var(--font-size-small);
}

.status-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.status-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #3b82f6;
}

.status-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

.status-muted {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  margin-top: var(--spacing-md);
}

/* === SUMMARY SECTIONS === */
.summary-section {
  margin-bottom: var(--spacing-xl);
}

.summary-section h2 {
  font-size: var(--font-size-large);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  color: var(--color-text);
}

.summary-item {
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-md);
  background: rgba(6,23,45,.03);
  border-radius: var(--radius-md);
}

.summary-item strong {
  color: var(--color-primary);
  font-weight: 600;
}

.summary-trend {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  margin-top: var(--spacing-xs);
}

.summary-list {
  list-style: none;
  padding: 0;
}

.summary-list li {
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.summary-list li:last-child {
  border-bottom: none;
}

/* === MODAL === */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(6, 23, 45, 0.4);
  z-index: 1000;
  padding: var(--spacing-md);
  overflow-y: auto;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 22px 60px rgba(6,23,45,.22);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.modal-title {
  font-size: var(--font-size-large);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--color-text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .15s;
}

.modal-close:hover {
  background: rgba(6,23,45,.06);
}

.modal-body {
  margin-bottom: var(--spacing-md);
}

.modal-footer {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
}

/* === PREVIEW === */
.preview {
  background: rgba(6,23,45,.03);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  font-family: monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 500px;
  overflow-y: auto;
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .container {
    padding: var(--spacing-sm);
  }

  .card {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
  }

  .btn-row {
    flex-direction: column;
  }

  .btn-row .btn {
    width: 100%;
  }
}

/* === ACCESSIBILITY === */
:focus-visible {
  outline: 3px solid rgba(110,135,125,.40);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* === Questions journalières sous curseurs === */
.range-question {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: 4px;
}

.range-hint {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: right;
  margin-top: 2px;
}

/* === Footer version === */
.app-footer {
  text-align: center;
  padding: 20px 16px 8px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.app-footer a {
  color: var(--color-primary);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* === INDICATOR CARDS === */
.indicator-card {
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(6,23,45,.07);
}

.indicator-card .field {
  margin-bottom: 0;
}

.indicator-card--energie  { background: #e8f5f0; --indicator-color: #2e9e6e; }
.indicator-card--sommeil  { background: #fdf0eb; --indicator-color: #c0714a; }
.indicator-card--confort  { background: #f3eef8; --indicator-color: #8b5cb5; }
.indicator-card--mental   { background: #eaf2f8; --indicator-color: #3b82b6; }

.indicator-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 600;
}

.indicator-score {
  font-size: 2rem;
  font-weight: 700;
  color: var(--indicator-color);
  line-height: 1;
  min-width: auto;
}

/* === Section Mes mesures (ADR-2026-021) === */
.mesures-section {
  margin-top: 24px;
  border-top: 1px solid #e0e0e0;
  padding-top: 16px;
}

.mesures-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 0;
  user-select: none;
}

.mesures-chevron {
  font-size: 12px;
  transition: transform 0.2s ease;
  color: #6E877D;
}

.mesures-chevron.open {
  transform: rotate(90deg);
}

.mesures-title {
  font-size: 15px;
  font-weight: 600;
  color: #06172D;
}

.mesures-subtitle {
  font-size: 13px;
  color: #888;
  margin: 0 0 12px 0;
  padding-left: 20px;
}

.mesures-body {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
}

.mesures-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mesures-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #444;
  margin-bottom: 4px;
}

.mesures-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  box-sizing: border-box;
  -moz-appearance: textfield;
}

.mesures-field input::-webkit-outer-spin-button,
.mesures-field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.mesures-field-ta {
  grid-column: 1 / -1;
}

.ta-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ta-inputs input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  box-sizing: border-box;
  -moz-appearance: textfield;
}

.ta-inputs input::-webkit-outer-spin-button,
.ta-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ta-separator {
  font-size: 18px;
  font-weight: 600;
  color: #666;
}

.btn-save-mesures {
  margin-top: 14px;
  width: 100%;
  padding: 10px;
  background: #6E877D;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-save-mesures:active {
  opacity: 0.85;
}

.mesures-status {
  text-align: center;
  font-size: 13px;
  color: #6E877D;
  margin-top: 8px;
}

/* === PEM Detector — Episodes de crash === */

.pem-section {
  margin-top: 16px;
}

.pem-header {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 6px;
}

.pem-count {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0 0 12px;
}

.pem-card {
  border-left: 4px solid #D32F2F;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(6,23,45,.08);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.pem-dates {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.pem-scores {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.pem-crash-score {
  color: #D32F2F;
  font-weight: 600;
}

.pem-delta {
  color: #D32F2F;
  font-weight: 700;
}

.pem-level {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.pem-fc {
  font-size: 12px;
  color: var(--color-text-muted);
}

.pem-message {
  font-size: 13px;
  color: var(--color-text-muted);
  font-style: italic;
  margin: 10px 0 0;
  line-height: 1.5;
}

/* === Bouton outline sage (lien Articles accueil) === */
.btn-outline-sage {
  border: 2px solid #6E877D;
  background: transparent;
  color: #6E877D;
  padding: 14px;
  border-radius: 12px;
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: block;
  text-align: center;
  transition: background 0.2s, color 0.2s;
  box-sizing: border-box;
}

.btn-outline-sage:hover {
  background: #6E877D;
  color: white;
}

/* === Alerte pacing === */

.pacing-alert {
  position: relative;
  background: #e8f5f0;
  color: #6E877D;
  border-radius: 12px;
  padding: 12px 40px 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  margin-top: 12px;
}

.pacing-icon {
  font-weight: 700;
}

.pacing-dismiss {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #6E877D;
  line-height: 1;
  padding: 0 4px;
}
