/* =========================================================
   STUDY — Composants UI Réutilisables (Style Apple / Encore)
   ========================================================= */

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-compact {
  background: var(--surface-card);
  border: 1px solid var(--border-faint);
  border-radius: 20px;
  padding: 15px 14px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

/* Boutons & Pilules */
.btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 120ms ease;
}

.btn:hover {
  background: #3A3A3D;
  border-color: #48484A;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--orange);
  border-color: var(--orange);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--orange-light);
  border-color: var(--orange-light);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--surface-secondary);
}

.btn-danger {
  background: var(--red-soft);
  border-color: rgba(255, 69, 58, 0.25);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(255, 69, 58, 0.22);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
}

.circle-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-primary);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 150ms ease, transform 120ms ease;
  flex-shrink: 0;
}

.circle-icon-btn:hover {
  background: var(--surface-secondary);
}

.circle-icon-btn:active {
  transform: scale(0.94);
}

.circle-icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Segmented Control (iOS) */
.segmented-control {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.segment-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.segment-btn.active {
  background: var(--surface-secondary);
  color: var(--orange);
}

/* Barres de progression */
.progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-secondary);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--orange);
  transition: width 350ms cubic-bezier(0.22, 1, 0.36, 1), background-color 250ms ease;
}

.progress-fill.complete {
  background: var(--green);
}

/* Formulaires */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input,
.select {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-secondary);
  color: var(--text-primary);
  font-size: 14.5px;
  outline: none;
  transition: border-color 150ms ease;
}

.input:focus,
.select:focus {
  border-color: var(--orange);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 480px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Switch iOS */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-faint);
}

.switch-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.switch-label {
  font-size: 14.5px;
  font-weight: 500;
}

.switch-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.ios-switch {
  position: relative;
  width: 50px;
  height: 30px;
  flex-shrink: 0;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-slider {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease;
}

.ios-slider::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #FFFFFF;
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.ios-switch input:checked + .ios-slider {
  background: var(--orange);
  border-color: var(--orange);
}

.ios-switch input:checked + .ios-slider::before {
  transform: translateX(20px);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-secondary);
  color: var(--text-secondary);
}

.badge-orange {
  background: var(--orange-soft);
  color: var(--orange);
}

.badge-green {
  background: var(--green-soft);
  color: var(--green);
}

/* Modales & Bottom Sheets iOS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 14px calc(16px + var(--safe-bottom));
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-sheet {
  width: min(520px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-float);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Toast Notification */
.toast {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translate(-50%, -18px);
  z-index: 200;
  max-width: min(440px, calc(100% - 28px));
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
