/* hbe-cr-visite — feuille de style mobile-first.
 * Pas de framework. Variables CSS pour la charte HBE. */

:root {
  --hbe-orange: #eb6b10;
  --hbe-orange-dark: #c25809;
  --hbe-green: #0B3D2E;
  --hbe-green-dark: #062318;
  --hbe-cream: #F5F3F0;
  --bg: #ffffff;
  --bg-soft: var(--hbe-cream);
  --fg: #1a1a1a;
  --fg-muted: #666;
  --border: #e3ddd5;
  --danger: #c0392b;
  --success: #1f8a4c;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);
  --tap-target: 56px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-soft);
  color: var(--fg);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 1rem;
  color: var(--hbe-green);
}

p { margin: 0 0 0.75rem; }

.muted { color: var(--fg-muted); }
.center { text-align: center; }

/* Header */
.app-header {
  background: var(--hbe-green);
  color: white;
  padding: calc(env(safe-area-inset-top) + 0.75rem) 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.brand-mark {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: var(--hbe-orange);
  border-radius: 3px;
}
.brand-name {
  font-size: 1.1rem;
}
.app-subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  font-weight: 500;
}

/* Layout */
main#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.screen {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* Champs */
.field {
  display: block;
  margin-bottom: 1rem;
}
.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--hbe-green);
  margin-bottom: 0.35rem;
}
input[type="text"],
input[type="search"] {
  width: 100%;
  min-height: var(--tap-target);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]:focus,
input[type="search"]:focus {
  border-color: var(--hbe-orange);
  box-shadow: 0 0 0 3px rgba(235, 107, 16, 0.18);
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap-target);
  padding: 0.75rem 1.25rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  background: transparent;
  color: var(--fg);
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--hbe-orange);
  color: white;
  box-shadow: 0 2px 6px rgba(235, 107, 16, 0.35);
}
.btn-primary:hover { background: var(--hbe-orange-dark); }

.btn-secondary {
  background: white;
  color: var(--hbe-green);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-soft); }

.btn-link {
  background: transparent;
  color: var(--hbe-orange);
  padding: 0.4rem 0.6rem;
  min-height: auto;
  font-weight: 600;
  text-decoration: underline;
}

.btn-block { width: 100%; }
.btn-large { font-size: 1.1rem; min-height: 64px; }

.actions-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.actions-row .btn { flex: 1; }

/* Recherche : liste de résultats */
.hint {
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 1rem;
}

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.result-item {
  padding: 0.85rem 1rem;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.result-item:hover { border-color: var(--hbe-orange); }
.result-item:active { background: #ece8e2; }
.result-name {
  font-weight: 600;
  color: var(--hbe-green);
}
.result-meta {
  font-size: 0.88rem;
  color: var(--fg-muted);
  margin-top: 0.15rem;
}

/* Client sélectionné */
.selected-client {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-soft);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}
.client-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.client-info strong {
  color: var(--hbe-green);
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-meta {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

/* Centre + gros bouton REC */
.center-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0 1rem;
}

.btn-record {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--hbe-orange);
  color: white;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.05em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  box-shadow:
    0 8px 24px rgba(235, 107, 16, 0.35),
    inset 0 -4px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.08s ease, box-shadow 0.2s ease;
}
.btn-record:active {
  transform: scale(0.97);
}
.btn-record .rec-icon { font-size: 3rem; line-height: 1; }
.btn-record .rec-label {
  font-size: 1rem;
  font-weight: 700;
}

.btn-record.is-recording {
  background: var(--danger);
  animation: pulse 1.4s ease-in-out infinite;
  box-shadow:
    0 8px 24px rgba(192, 57, 43, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.1);
}

@keyframes pulse {
  0%, 100% {
    box-shadow:
      0 8px 24px rgba(192, 57, 43, 0.45),
      0 0 0 0 rgba(192, 57, 43, 0.5),
      inset 0 -4px 0 rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow:
      0 8px 24px rgba(192, 57, 43, 0.45),
      0 0 0 22px rgba(192, 57, 43, 0),
      inset 0 -4px 0 rgba(0, 0, 0, 0.1);
  }
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--hbe-green);
  letter-spacing: 0.05em;
}

/* Récap enregistrement */
.recorded-summary {
  background: var(--bg-soft);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.summary-line { font-size: 1rem; }
.summary-line strong {
  color: var(--hbe-green);
  font-variant-numeric: tabular-nums;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 0;
}
.spinner {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 6px solid rgba(11, 61, 46, 0.15);
  border-top-color: var(--hbe-orange);
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-text {
  font-weight: 600;
  color: var(--hbe-green);
  font-size: 1.05rem;
  margin: 0;
}

/* Résultat (succès / erreur) */
.result-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}
.result-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: white;
  margin-bottom: 1rem;
}
.result-success .result-icon { background: var(--success); }
.result-error .result-icon { background: var(--danger); }

.result-state h2 { margin-bottom: 0.5rem; }
.result-state .actions-row { width: 100%; margin-top: 1rem; }

.error-text {
  color: var(--danger);
  font-size: 0.95rem;
  margin: 0.5rem 0;
}

/* Tablette / desktop */
@media (min-width: 720px) {
  main#app { padding: 2rem 1.5rem; }
  .screen { padding: 2rem; }
  .btn-record { width: 240px; height: 240px; }
  .btn-record .rec-icon { font-size: 3.5rem; }
}

/* Préférences de l'utilisateur */
@media (prefers-reduced-motion: reduce) {
  .btn-record.is-recording { animation: none; }
  .spinner { animation-duration: 2s; }
}
