/* Oasis Pharma — App Web Pharmacie (Express + EJS) */
/* Custom styles — Tailwind is loaded via CDN */

@layer base {
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: #f8fafc; color: #0f172a; line-height: 1.5; min-height: 100vh; }
  a { color: inherit; text-decoration: none; }
  button { font: inherit; cursor: pointer; border: none; background: none; }
  input, select, textarea { font: inherit; }
}

/* ─── Auth ─── */
.auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 50%, #ecfeff 100%); }
.auth-card { background: white; border-radius: 20px; padding: 40px; max-width: 480px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.1); }
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo { font-size: 56px; margin-bottom: 12px; }
.auth-header h1 { font-size: 24px; color: #0f766e; margin-bottom: 8px; }
.auth-header p { font-size: 14px; color: #64748b; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #475569; font-weight: 600; }
.auth-form input { padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 15px; }
.auth-form input:focus { outline: none; border-color: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }

/* ─── Auth switch (login ↔ register) ─── */
.auth-card-wide { max-width: 560px; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 14px; color: #64748b; }
.auth-switch-link { background: none; border: none; color: #0d9488; font-weight: 600; cursor: pointer; font-size: 14px; text-decoration: underline; }
.auth-switch-link:hover { color: #0f766e; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row label { gap: 6px; }

/* ─── Consent (Loi 22/030) ─── */
.consent-section { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; }
.consent-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.consent-icon { font-size: 24px; }
.consent-header strong { display: block; font-size: 13px; color: #0f172a; }
.consent-header small { font-size: 11px; color: #64748b; font-style: italic; }
.consent-checkbox { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: #475569; cursor: pointer; margin-top: 10px; line-height: 1.5; }
.consent-checkbox input[type="checkbox"] { margin-top: 3px; width: 18px; height: 18px; accent-color: #10b981; flex-shrink: 0; }
.policy-preview { max-height: 260px; overflow-y: auto; background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin: 10px 0; }
.policy-law { font-size: 11px; color: #64748b; font-style: italic; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #f1f5f9; }
.policy-section { margin-bottom: 8px; }
.policy-section strong { display: block; font-size: 12px; color: #0f766e; margin-bottom: 2px; }
.policy-section p { font-size: 12px; color: #475569; line-height: 1.5; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ─── Stats cards ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; padding: 20px; border-radius: 14px; border: 2px solid; box-shadow: 0 2px 4px rgba(0,0,0,.04); }
.stat-emerald { border-color: #a7f3d0; background: linear-gradient(135deg, #fff 0%, #ecfdf5 100%); }
.stat-amber { border-color: #fde68a; background: linear-gradient(135deg, #fff 0%, #fffbeb 100%); }
.stat-red { border-color: #fecaca; background: linear-gradient(135deg, #fff 0%, #fef2f2 100%); }
.stat-cyan { border-color: #a5f3fc; background: linear-gradient(135deg, #fff 0%, #ecfeff 100%); }
.stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; color: #0f172a; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 4px; }
.stat-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* ─── Card ─── */
.card { background: white; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,.04); }
.card-header { padding: 20px; border-bottom: 1px solid #e2e8f0; }
.card-header h2 { font-size: 18px; color: #0f172a; margin-bottom: 4px; }
.card-header p { font-size: 13px; color: #64748b; }
.card-actions { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.card-body { padding: 20px; }
.input { padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; }
.input:focus { outline: none; border-color: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #475569; cursor: pointer; }

/* ─── Buttons ─── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; transition: all .15s; border: 1px solid transparent; }
.btn-primary { background: #10b981; color: white; }
.btn-primary:hover { background: #059669; }
.btn-primary:disabled { background: #d1fae5; cursor: not-allowed; }
.btn-outline { background: white; color: #0f766e; border-color: #a7f3d0; }
.btn-outline:hover { background: #ecfdf5; }
.btn-ghost { background: transparent; color: #64748b; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; background: white; border: 1px solid #e2e8f0; color: #0f766e; font-weight: bold; font-size: 18px; border-radius: 6px; }
.btn-icon:hover { background: #f1f5f9; }
.btn-danger { background: #dc2626; color: white; padding: 10px 16px; border-radius: 8px; font-weight: 600; border: none; cursor: pointer; font-size: 14px; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: #fca5a5; cursor: not-allowed; }

/* ─── Stock table ─── */
.stock-table { width: 100%; border-collapse: collapse; }
.stock-table th, .stock-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f1f5f9; }
.stock-table th { font-size: 12px; text-transform: uppercase; color: #64748b; font-weight: 700; background: #f8fafc; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.stock-table tbody tr:hover { background: #f8fafc; }
.med-name { font-weight: 600; color: #0f172a; }
.med-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.barcode { color: #94a3b8; font-family: monospace; margin-left: 6px; }
.stock-num { font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.price-cell { font-weight: 600; color: #0d9488; font-size: 15px; }
.stock-actions { display: flex; gap: 6px; align-items: center; justify-content: center; }

.chip { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid transparent; }
.chip-default { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.chip-red { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.chip-amber { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.chip-green { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.chip-emerald { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }

/* ─── Search cards ─── */
.search-list { display: flex; flex-direction: column; gap: 12px; }
.search-card { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); border: 2px solid #fde68a; border-radius: 12px; padding: 16px; }
.search-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.badge-amber { background: #f59e0b; color: white; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.search-time { font-size: 11px; color: #92400e; }
.search-med { font-size: 18px; font-weight: 700; color: #78350f; margin-bottom: 4px; }
.search-patient { font-size: 13px; color: #92400e; margin-bottom: 8px; }
.search-msg { font-style: italic; font-size: 12px; color: #92400e; background: rgba(255,255,255,.5); padding: 8px; border-radius: 6px; margin-bottom: 8px; }
.search-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Empty state ─── */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 48px; opacity: .4; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; color: #0f172a; margin-bottom: 4px; }
.empty-text { font-size: 13px; color: #64748b; }
.loading { text-align: center; padding: 40px; color: #64748b; }

/* ─── Stats detail ─── */
.stats-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.bar-row { margin-bottom: 14px; }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.bar-track { background: #f1f5f9; border-radius: 999px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.bar-emerald { background: #10b981; }
.bar-green { background: #22c55e; }
.bar-amber { background: #f59e0b; }
.bar-red { background: #ef4444; }
.rt-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.rt-row strong { color: #0d9488; }
.rt-tip { margin-top: 12px; padding: 12px; background: #ecfdf5; border-radius: 8px; font-size: 12px; color: #064e3b; }

/* ─── Modal ─── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay.show { display: flex; }
.modal { background: white; border-radius: 16px; padding: 28px; max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal h2 { margin-bottom: 16px; }
.modal label { display: block; margin-bottom: 12px; font-size: 13px; color: #475569; font-weight: 600; }
.modal input { width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; margin-top: 4px; font-size: 15px; }
.modal input:focus { outline: none; border-color: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.med-list { max-height: 240px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 8px; margin: 12px 0; }
.med-list-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.med-list-item:hover { background: #f8fafc; }
.med-list-item.selected { background: #ecfdf5; border-left: 4px solid #10b981; }
.med-list-item strong { display: block; font-size: 14px; color: #0f172a; }
.med-list-item small { font-size: 11px; color: #94a3b8; }

/* ─── Map controls ─── */
.map-controls { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.map-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #475569; font-weight: 600; }
.map-controls input[type="range"] { width: 100%; }
.map-controls textarea { padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; resize: vertical; font-family: inherit; }

/* ─── Toast ─── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: white; padding: 14px 20px; border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.2); max-width: 360px; font-size: 14px; font-weight: 500; animation: slide-up .3s ease; }
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }

/* ─── Conflict dialog ─── */
.conflict-info { background: #fef3c7; border: 1px solid #fde68a; border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.conflict-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.conflict-row span { color: #475569; }
.conflict-divider { font-size: 12px; color: #92400e; margin-top: 12px; margin-bottom: 6px; font-weight: 600; }

/* ─── Aliases ─── */
.aliases { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.alias-chip { background: #e0f2fe; color: #0369a1; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 500; }
.alias-more { font-size: 10px; color: #64748b; padding: 1px 4px; }

/* ─── Version badge ─── */
.version-badge { display: inline-block; background: #f1f5f9; color: #475569; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; font-family: monospace; }

/* ─── Accessibilité WCAG 2.1 AA ─── */
*:focus-visible { outline: 3px solid #0d9488 !important; outline-offset: 2px !important; border-radius: 4px; }
.skip-link { position: absolute; top: -40px; left: 0; background: #0d9488; color: white; padding: 8px 16px; z-index: 1000; text-decoration: none; border-radius: 0 0 8px 0; }
.skip-link:focus { top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (prefers-contrast: high) {
  * { border-color: currentColor !important; }
}

/* ─── Privacy settings ─── */
.account-active { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 14px; margin-bottom: 20px; }
.privacy-policy-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #e2e8f0; }
.privacy-policy-section h3 { font-size: 16px; margin-bottom: 4px; color: #0f172a; }
.privacy-law { font-size: 12px; color: #64748b; margin-bottom: 16px; font-style: italic; }
.privacy-sections { display: grid; gap: 12px; }
.privacy-section-item { background: #f8fafc; padding: 12px; border-radius: 8px; border-left: 3px solid #10b981; }
.privacy-section-item strong { display: block; font-size: 13px; color: #0f766e; margin-bottom: 4px; }
.privacy-section-item p { font-size: 12px; color: #475569; line-height: 1.5; }
.danger-zone { margin-top: 24px; padding: 20px; background: #fef2f2; border: 2px solid #fecaca; border-radius: 12px; }
.danger-zone h3 { color: #991b1b; margin-bottom: 8px; font-size: 16px; }
.danger-zone p { font-size: 13px; color: #7f1d1d; margin-bottom: 12px; }
.delete-confirm { background: white; padding: 16px; border-radius: 8px; border: 1px solid #fecaca; }
.delete-confirm p { margin-bottom: 8px; }
.deletion-banner { display: flex; gap: 16px; background: #fffbeb; border: 2px solid #fde68a; border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.deletion-banner .deletion-icon { font-size: 32px; }
.deletion-banner h3 { color: #92400e; margin-bottom: 4px; }
.deletion-banner p { color: #78350f; font-size: 13px; margin-bottom: 4px; }

/* ─── Page Header ─── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 24px; color: #0f172a; margin-bottom: 4px; }
.page-header p { font-size: 14px; color: #64748b; }

/* ─── Quick Actions ─── */
.quick-actions { margin-top: 24px; }
.quick-actions h2 { font-size: 16px; color: #0f172a; margin-bottom: 12px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.quick-card { display: flex; align-items: center; gap: 12px; padding: 16px; background: white; border-radius: 12px; border: 1px solid #e2e8f0; text-decoration: none; color: #0f172a; transition: all .15s; }
.quick-card:hover { border-color: #10b981; box-shadow: 0 4px 12px rgba(16,185,129,.1); transform: translateY(-1px); }
.quick-icon { font-size: 24px; }
.quick-text strong { display: block; font-size: 14px; }
.quick-text small { font-size: 11px; color: #64748b; }
.quick-badge { background: #ef4444; color: white; font-size: 11px; padding: 2px 8px; border-radius: 999px; min-width: 20px; text-center: center; margin-left: auto; }

/* ─── Dashboard Sections ─── */
.dashboard-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; margin-top: 24px; }
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item { display: flex; align-items: center; gap: 10px; padding: 10px; background: #f8fafc; border-radius: 8px; }
.recent-item .recent-icon { font-size: 20px; }
.recent-item div { flex: 1; }
.recent-item strong { display: block; font-size: 13px; color: #0f172a; }
.recent-item small { font-size: 11px; color: #94a3b8; }

/* ─── Real-time cards ─── */
.rt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; }
.rt-card { text-align: center; padding: 16px; background: #f8fafc; border-radius: 10px; }
.rt-value { font-size: 28px; font-weight: 800; color: #0f172a; }
.rt-label { font-size: 12px; color: #64748b; margin-top: 4px; }
.rt-indicator { width: 12px; height: 12px; border-radius: 50%; margin: 8px auto 0; }
.rt-indicator.connected { background: #10b981; box-shadow: 0 0 8px #10b981; }
.rt-indicator.disconnected { background: #dc2626; }

/* ─── Not Found page ─── */
.not-found { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f8fafc; }
.not-found-content { text-align: center; padding: 40px; }
.not-found-icon { font-size: 64px; margin-bottom: 16px; }
.not-found h1 { font-size: 72px; font-weight: 800; color: #10b981; margin-bottom: 8px; }
.not-found h2 { font-size: 20px; color: #0f172a; margin-bottom: 8px; }
.not-found p { font-size: 14px; color: #64748b; margin-bottom: 24px; }
.not-found-actions { display: flex; gap: 12px; justify-content: center; }

/* ─── Animations ─── */
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fade-in .3s ease; }
.animate-slide-up { animation: slide-up .3s ease; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .auth-card { padding: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 24px; }
  .stock-table { font-size: 12px; }
  .stock-table th, .stock-table td { padding: 8px; }
  .med-sub { display: none; }
  .card-actions { flex-direction: column; align-items: stretch; }
  .input { min-width: 0; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-sections { grid-template-columns: 1fr; }
}
