/* ============================================================
   Triskell Outils — Composants (cards, formulaires, résultats)
   ============================================================ */

/* ── BOUTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: .9375rem;
  letter-spacing: .01em;
  transition: var(--t);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(99,102,241,.6);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -6px rgba(99,102,241,.7); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-block { width: 100%; padding-top: 16px; padding-bottom: 16px; font-size: 1rem; }

/* ── TUILES (sélecteur métier / liste calculateurs) ── */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
/* Variante : forcer 4 colonnes en ligne (sélecteur de métier) */
.tiles--row { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
  .tiles--row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
  .tiles--row { grid-template-columns: 1fr; }
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: var(--t);
  text-align: left;
  position: relative;
  overflow: hidden;
  min-height: 124px;
}
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0) 0%, rgba(139,92,246,0) 100%);
  opacity: 0;
  transition: var(--t);
  pointer-events: none;
}
.tile:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--sh-card); }
.tile:hover::before { opacity: 1; background: linear-gradient(135deg, rgba(99,102,241,.08) 0%, rgba(236,72,153,.06) 100%); }
.tile__icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(139,92,246,.15));
  color: var(--indigo);
  position: relative;
}
.tile__icon svg { width: 22px; height: 22px; }
.tile__title {
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--text);
  position: relative;
}
.tile__sub {
  font-size: .8125rem;
  color: var(--muted);
  margin-top: -4px;
  position: relative;
}
.tile__badge {
  position: absolute;
  top: 12px; right: 12px;
  font-size: .6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(245,158,11,.12);
  color: var(--amber);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.tile[disabled], .tile.is-soon { cursor: not-allowed; opacity: .65; }
.tile[disabled]:hover, .tile.is-soon:hover { transform: none; box-shadow: none; }
.tile[disabled]:hover::before, .tile.is-soon:hover::before { opacity: 0; }

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 20px;
}
.card + .card { margin-top: 16px; }
.card h3 { margin-bottom: 4px; }
.card .help { color: var(--muted); font-size: .875rem; }

/* ── FORMULAIRES ── */
.field { display: block; }
.field + .field { margin-top: 16px; }
.field__label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 8px;
}
.field__hint {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-top: 6px;
}
.input, .select {
  width: 100%;
  padding: 13px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  transition: var(--t);
  -webkit-appearance: none;
  appearance: none;
}
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394A3B8'><path d='M5 8l5 5 5-5H5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.input::placeholder { color: var(--muted); }

/* unit input (nombre + suffixe) */
.input-unit {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--bg-2);
  transition: var(--t);
}
.input-unit:focus-within {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.input-unit .input {
  border: none;
  background: transparent;
  box-shadow: none;
  padding-right: 6px;
}
.input-unit .input:focus { box-shadow: none; }
.input-unit__suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 14px 0 6px;
  color: var(--muted);
  font-size: .9375rem;
  font-weight: 500;
}

/* row 2 colonnes pour dimensions */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* segmented control */
.seg {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 3px;
  width: 100%;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1;
  text-align: center;
  padding: 9px 10px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted-2);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--t);
  user-select: none;
}
.seg input:checked + label {
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px -2px rgba(99,102,241,.5);
}
.seg label:hover { color: var(--text); }
.seg input:checked + label:hover { color: #fff; }

/* ── RÉSULTATS ── */
.results {
  margin-top: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 26px 22px 22px;
  position: relative;
  box-shadow: var(--sh-card);
}
/* Bandeau coloré en haut pour bien repérer la zone */
.results::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 3px;
  background: linear-gradient(90deg, var(--indigo), var(--violet) 50%, var(--pink));
  border-radius: 0 0 3px 3px;
}
.results.is-empty {
  background: var(--bg-3);
  border-style: dashed;
  border-color: var(--border-2);
  box-shadow: none;
}
.results.is-empty::before { opacity: .4; }
.results.has-result {
  animation: t-results-pop .35s cubic-bezier(.4,0,.2,1);
}
@keyframes t-results-pop {
  0%   { transform: scale(.99); }
  60%  { transform: scale(1.005); }
  100% { transform: scale(1); }
}
.results__title {
  font-family: var(--font-h);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: .02em;
  margin-bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.results__title::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--pink));
  box-shadow: 0 0 12px rgba(139,92,246,.6);
}
.results.is-empty .results__title { color: var(--muted-2); }
.results.is-empty .results__title::before {
  background: var(--muted);
  box-shadow: none;
  opacity: .5;
}
.result-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.result-line:last-child { border-bottom: none; }
.result-line__label {
  font-size: .9375rem;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.result-line__label small { color: var(--muted); font-size: .75rem; }
.result-line__value {
  font-family: var(--font-h);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.result-line__value em {
  font-style: normal;
  font-family: var(--font-b);
  font-weight: 500;
  color: var(--muted-2);
  font-size: .8125rem;
  margin-left: 4px;
}
.result-highlight .result-line__value {
  background: linear-gradient(135deg, var(--indigo), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.375rem;
}

.results__actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.results__actions .btn { flex: 1 1 auto; }

.results__notice {
  margin-top: 14px;
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.results__notice svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }

/* état vide / placeholder */
.placeholder-block {
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-lg);
  color: var(--muted);
}
.placeholder-block h3 { color: var(--text-2); margin-bottom: 8px; }
.placeholder-block .icon { font-size: 2rem; margin-bottom: 12px; opacity: .6; }

/* ── LIGNES D'OUVERTURES (calc surface) ── */
.openings { display: flex; flex-direction: column; gap: 10px; }
.opening-row {
  display: grid;
  grid-template-columns: 1fr 84px 84px 60px 36px;
  gap: 8px;
  align-items: center;
}
.opening-row .input { padding: 10px 10px; font-size: .9375rem; }
.opening-row .input-unit { background: var(--bg-2); }
.opening-row .input-unit .input { padding-right: 4px; }
.opening-row .input-unit__suffix { padding: 0 8px 0 0; font-size: .8125rem; }
.opening-row__count {
  text-align: center;
}
.opening-row__remove {
  width: 36px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  transition: var(--t);
}
.opening-row__remove:hover { background: rgba(239,68,68,.12); color: var(--red); }
.opening-row__remove svg { width: 16px; height: 16px; }
.opening-add {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-sm);
  color: var(--muted-2);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--t);
}
.opening-add:hover { color: var(--text); border-color: var(--text-2); }
.opening-add svg { width: 16px; height: 16px; }
@media (max-width: 540px) {
  .opening-row {
    grid-template-columns: 1fr 1fr 36px;
    grid-template-areas:
      "label  label   remove"
      "w      h       count";
    gap: 6px 8px;
  }
  .opening-row > :nth-child(1) { grid-area: label; }
  .opening-row > :nth-child(2) { grid-area: w; }
  .opening-row > :nth-child(3) { grid-area: h; }
  .opening-row > :nth-child(4) { grid-area: count; }
  .opening-row > :nth-child(5) { grid-area: remove; align-self: start; }
}

/* ── INSTALL BANNER (PWA) ── */
.t-install {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(99,102,241,.10), rgba(236,72,153,.06));
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
}
.t-install[hidden] { display: none !important; }
.t-install__icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px -6px rgba(99,102,241,.55);
}
.t-install__icon svg { width: 24px; height: 24px; color: #fff; }
.t-install__body { flex: 1; min-width: 0; }
.t-install__title {
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--text);
  margin: 0;
}
.t-install__desc {
  font-size: .875rem;
  color: var(--muted-2);
  margin: 4px 0 0;
  line-height: 1.45;
}
.t-install__desc .ios-share-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  vertical-align: -5px;
  margin: 0 2px;
  color: var(--indigo-dk);
}
.t-install__desc .ios-share-icon svg { width: 12px; height: 12px; }
.t-install__btn { flex-shrink: 0; }
.t-install__close {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: var(--t);
}
.t-install__close:hover { background: var(--bg-3); color: var(--text); }
.t-install__close svg { width: 14px; height: 14px; }
@media (max-width: 540px) {
  .t-install { flex-direction: column; align-items: stretch; text-align: left; gap: 12px; padding-top: 32px; }
  .t-install__btn { width: 100%; }
}

/* toast minimaliste pour copier */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 600;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  z-index: 100;
  pointer-events: none;
}
.toast.is-shown { transform: translateX(-50%) translateY(0); }
