/* ==========================================================================
   ScanORDO Direct Hors HDS - Styles Web App Mobile Patient (Inspiration Doctolib)
   Lumineux, Épuré, Bouton Géant Central, Zéro Friction
   ========================================================================== */

:root {
  --doctolib-blue: #0596de;
  --doctolib-blue-hover: #0277bd;
  --doctolib-blue-light: #e8f4fd;
  --doctolib-dark: #1b2733;
  --doctolib-muted: #677788;
  --doctolib-border: #e2e8f0;
  --doctolib-bg: #f4f8fb;
  --doctolib-success: #10b981;
}

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

body.patient-body {
  background-color: var(--doctolib-bg);
  color: var(--doctolib-dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: auto;
}

.patient-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom, 24px)) 20px;
  background-color: #ffffff;
  box-shadow: 0 4px 25px rgba(5, 150, 222, 0.06);
  box-sizing: border-box;
}

#actionCards {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* En-tête Lumineux Style Doctolib */
.patient-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edf2f7;
}

.pharmacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--doctolib-blue-light);
  color: var(--doctolib-blue);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.patient-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--doctolib-dark);
  margin: 0 0 4px 0;
  letter-spacing: -0.02em;
}

.counter-sub {
  font-size: 0.92rem;
  color: var(--doctolib-muted);
  font-weight: 600;
}

.p2p-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.8rem;
  color: #b45309;
  margin-top: 10px;
  font-weight: 600;
  transition: all 0.25s ease;
}

.p2p-badge.is-connected {
  background: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.2);
}

.p2p-check-icon {
  display: none;
  width: 16px;
  height: 16px;
  stroke: #10b981;
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.p2p-badge.is-connected .p2p-check-icon {
  display: inline-block;
}

.p2p-badge.is-connected .p2p-dot {
  display: none;
}

.p2p-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.p2p-dot.connected {
  background: var(--doctolib-success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* Bandeau d'assistance si VPN ou Bloqueur AdGuard détecté */
.vpn-hint-box {
  display: none;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 12px auto 6px;
  max-width: 480px;
  text-align: left;
  font-size: 0.82rem;
  color: #78350f;
  line-height: 1.45;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.08);
}

.vpn-hint-title {
  font-weight: 700;
  color: #92400e;
  margin-bottom: 4px;
}

.btn-force-turn {
  display: inline-block;
  background: #ffffff;
  border: 1px solid #f59e0b;
  color: #b45309;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s ease;
}

.btn-force-turn:hover {
  background: #fef3c7;
}

/* État désactivé avant connexion P2P */
.btn-disabled {
  opacity: 0.45 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  filter: grayscale(0.8) !important;
  box-shadow: none !important;
}

.connect-hint {
  font-size: 0.8rem;
  font-weight: 600;
  color: #f59e0b;
  margin-top: 10px;
  text-align: center;
  transition: color 0.2s ease;
}

.connect-hint.is-connected {
  color: #059669;
}

/* Zone Principale d'Action Centrée */
#mainActionArea {
  width: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.hero-camera-area, .hero-action-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 20px 0 24px 0;
  width: 100%;
}

/* Bouton Géant Central (Inspiration Doctolib) */
.btn-giant-camera, .btn-giant-action {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0596de, #0284c7);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(5, 150, 222, 0.35);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  position: relative;
  border: 5px solid #ffffff;
  outline: 4px solid var(--doctolib-blue-light);
}

.btn-giant-camera:hover, .btn-giant-camera:active,
.btn-giant-action:hover, .btn-giant-action:active {
  transform: scale(1.05);
  box-shadow: 0 14px 35px rgba(5, 150, 222, 0.45);
}

.camera-icon-svg, .giant-action-svg {
  width: 60px;
  height: 60px;
  fill: #ffffff;
}

.giant-camera-title, .giant-action-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--doctolib-dark);
  margin-top: 18px;
  margin-bottom: 4px;
}

.giant-camera-desc, .giant-action-desc {
  font-size: 0.85rem;
  color: var(--doctolib-muted);
  max-width: 290px;
}

/* Bouton Secondaire Sobre */
.btn-secondary-upload, .btn-secondary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.btn-secondary-upload:hover, .btn-secondary-upload:active,
.btn-secondary-action:hover, .btn-secondary-action:active {
  border-color: var(--doctolib-blue);
  background: var(--doctolib-blue-light);
  color: var(--doctolib-blue);
}

.upload-icon-svg, .secondary-icon-svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Aperçu du document sélectionné avant/pendant transfert */
.preview-card {
  display: none;
  align-items: center;
  gap: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
}

.preview-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #475569;
}

.preview-details {
  flex: 1;
  min-width: 0;
}

.preview-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--doctolib-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-size {
  font-size: 0.78rem;
  color: var(--doctolib-muted);
  margin-top: 2px;
}

/* Barre de Progression Fluide */
.patient-progress-container {
  display: none;
  margin-bottom: 24px;
  text-align: center;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0596de, #10b981);
  border-radius: 9999px;
  transition: width 0.2s ease;
}

.progress-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
}

/* Écran de Confirmation Immédiate (Style Doctolib) */
.success-screen {
  display: none;
  text-align: center;
  padding: 30px 10px 20px;
}

.success-check-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #ecfdf5;
  border: 2px solid #a7f3d0;
  color: var(--doctolib-success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.success-check-circle svg {
  width: 38px;
  height: 38px;
  stroke: var(--doctolib-success);
}

.success-screen h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--doctolib-dark);
  margin-bottom: 8px;
}

.success-screen p {
  font-size: 0.92rem;
  color: var(--doctolib-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.btn-send-another {
  background: #ffffff;
  color: var(--doctolib-blue);
  border: 2px solid var(--doctolib-blue);
  padding: 12px 22px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
  margin-bottom: 15px;
}

.btn-send-another:hover {
  background: var(--doctolib-blue);
  color: #ffffff;
}

/* Encart Information Santé Publique / Annonce B2C */
.btoc-ad-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--doctolib-blue);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 15px;
  margin-bottom: 20px;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}

.btoc-ad-box.health-notice {
  border-left-color: #059669;
  background: #f0fdf4;
}

.btoc-ad-tag {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #0369a1;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

.btoc-ad-box.health-notice .btoc-ad-tag {
  color: #047857;
}

.btoc-ad-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}

.btoc-ad-desc {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.35;
}

.btoc-ad-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--doctolib-blue);
  text-decoration: underline;
}

/* Mentions de Confidentialité & Sécurité Hors HDS */
.security-notice {
  margin-top: auto;
  padding-top: 20px;
  text-align: center;
  border-top: 1px solid #edf2f7;
}

.security-badge {
  font-size: 0.78rem;
  color: #475569;
  font-weight: 700;
  margin-bottom: 4px;
}

.security-desc {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.4;
  margin: 0;
}

/* ==========================================================================
   Modale de Consentement & Décharge Juridique Préalable
   ========================================================================== */
.legal-consent-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
  box-sizing: border-box;
}

.legal-consent-card {
  background: #ffffff;
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  max-height: 82vh;
  max-height: calc(100dvh - 36px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: modalFadeIn 0.25s ease-out;
  margin: auto;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.legal-header {
  padding: 16px 20px 12px 20px;
  text-align: center;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}

.legal-shield-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e0f2fe;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.legal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 4px 0;
  line-height: 1.3;
}

.legal-subtitle {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0;
  line-height: 1.35;
}

.legal-body {
  padding: 14px 18px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legal-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
}

.legal-section-title {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
  font-size: 0.84rem;
}

.legal-section p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #475569;
}

.legal-section.legal-warning {
  background: #fff1f2;
  border-color: #fecdd3;
}

.legal-section.legal-warning .legal-section-title {
  color: #9f1239;
}

.legal-section.legal-warning p {
  color: #881337;
}

.legal-footer {
  padding: 14px 18px max(16px, env(safe-area-inset-bottom, 16px)) 18px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04);
}

.btn-accept-consent {
  width: 100%;
  min-height: 52px;
  background: #0596de;
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 4px 14px rgba(5, 150, 222, 0.35);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-accept-consent:hover, .btn-accept-consent:active {
  background: #0284c7;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(5, 150, 222, 0.45);
}

/* ==========================================================================
   Écran de Session Clôturée / Fin de Délivrance (Style Doctolib / Drop2Desk)
   ========================================================================== */
.session-closed-screen {
  display: none;
  width: 100%;
  padding: 10px 0 24px 0;
  box-sizing: border-box;
}

.session-closed-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 32px 20px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
  max-width: 400px;
  margin: 16px auto;
  box-sizing: border-box;
}

.session-closed-icon-wrap {
  width: 72px;
  height: 72px;
  background: #ecfdf5;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  border: 2px solid #10b981;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.2);
}

.session-closed-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--doctolib-dark);
  margin: 0 0 10px 0;
  letter-spacing: -0.02em;
}

.session-closed-desc {
  font-size: 0.92rem;
  color: var(--doctolib-muted);
  line-height: 1.5;
  max-width: 320px;
  margin: 0 auto 20px auto;
}

.session-closed-pill {
  display: inline-block;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 22px;
}

.session-lock-banner {
  margin: 0 auto 20px auto;
  padding: 12px 16px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  font-size: 0.84rem;
  color: #9f1239;
  max-width: 320px;
}

.session-lock-banner strong {
  font-family: monospace;
  font-size: 1.05rem;
  color: #be123c;
}

.session-lock-sub {
  font-size: 0.74rem;
  color: #b91c1c;
  margin-top: 4px;
}

.session-closed-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  margin: 0 auto;
}

.btn-rescan-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: var(--doctolib-blue);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 15px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(5, 150, 222, 0.32);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.btn-rescan-primary:hover, .btn-rescan-primary:active {
  background: var(--doctolib-blue-hover);
  transform: translateY(-1px);
}

.btn-exit-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: #f8fafc;
  color: #475569;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  padding: 13px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.btn-exit-secondary:hover, .btn-exit-secondary:active {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

/* Modale Scanner QR Code Vidéo */
.qr-scanner-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0f172a;
  display: flex;
  flex-direction: column;
}

.qr-scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  z-index: 10;
}

.qr-scanner-title {
  font-size: 1rem;
  font-weight: 700;
}

.qr-scanner-close {
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-scanner-viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qrScannerVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-scanner-frame {
  position: absolute;
  width: 250px;
  height: 250px;
  border: 2px solid #38bdf8;
  border-radius: 16px;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  overflow: hidden;
}

.qr-laser {
  width: 100%;
  height: 2px;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  animation: qrLaserScan 2s ease-in-out infinite alternate;
}

@keyframes qrLaserScan {
  0% { transform: translateY(0); }
  100% { transform: translateY(248px); }
}

.qr-scanner-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: #ffffff;
  font-size: 0.85rem;
  background: rgba(15, 23, 42, 0.75);
  padding: 6px 16px;
  border-radius: 20px;
  white-space: nowrap;
}

@keyframes d2dSpin {
  to { transform: rotate(360deg); }
}

.spin-icon {
  animation: d2dSpin 1s linear infinite;
}

