/* =====================================================
   Ma Pharmacie - Design System
   © 2026 2ADS sarl
   ===================================================== */

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

:root {
  --color-primary: #1a4d2e;
  --color-primary-light: #2d6a4f;
  --color-primary-lighter: #52b788;
  --color-primary-soft: #d8e9df;
  --color-bg: #f0f4f1;
  --color-card: #ffffff;
  --color-border: #e0e7e2;
  --color-border-strong: #c8d5cc;
  --color-text: #1a2e1f;
  --color-text-muted: #5a6d5e;
  --color-text-light: #8a9d8e;
  --color-success: #1a4d2e;
  --color-success-bg: #d1e7dd;
  --color-warning: #d97706;
  --color-warning-bg: #fff3cd;
  --color-danger: #dc2626;
  --color-danger-bg: #f8d7da;
  --color-info: #2563eb;
  --color-info-bg: #cfe2ff;
  --shadow-sm: 0 1px 3px rgba(26,77,46,0.06);
  --shadow-md: 0 4px 12px rgba(26,77,46,0.08);
  --shadow-lg: 0 12px 32px rgba(26,77,46,0.12);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 9999px;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.display-font { font-family: 'Fraunces', Georgia, serif; letter-spacing: -0.02em; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-light); }
button { font-family: inherit; cursor: pointer; }

/* ============== AUTH LAYOUT (LOGIN) ============== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 30%, rgba(82,183,136,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(26,77,46,0.10) 0%, transparent 50%),
    linear-gradient(135deg, #f0f4f1 0%, #e3ede5 100%);
}

.auth-card {
  background: var(--color-card);
  border-radius: 24px;
  padding: 40px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(26,77,46,0.12);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-lighter), var(--color-primary));
}

.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.auth-title {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}
.auth-subtitle { color: var(--color-text-muted); font-size: 14px; }

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--color-text-light);
}
.auth-footer .brand-link {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  color: var(--color-primary);
}

/* ============== LOGO ============== */
.logo-mark {
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 50%, var(--color-primary-lighter) 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow: 0 4px 12px rgba(26,77,46,0.25);
  flex-shrink: 0;
}
.logo-mark::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.3);
}
.logo-mark svg { position: relative; z-index: 1; }

.logo-text-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}
.logo-text-sub {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 3px;
  font-weight: 500;
}

/* ============== APP LAYOUT ============== */
.app-wrapper { min-height: 100vh; display: flex; }

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 260px;
  background: var(--color-card);
  border-right: 1px solid var(--color-border);
  padding: 24px 16px;
  z-index: 30;
  overflow-y: auto;
  transition: left 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 16px 8px;
  margin-top: 32px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.sidebar-link:hover { background: var(--color-primary-soft); color: var(--color-text); }
.sidebar-link.active {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: white;
  box-shadow: var(--shadow-md);
}
.sidebar-link.active:hover { color: white; }
.sidebar-link svg { flex-shrink: 0; }

.sidebar-help-card {
  margin-top: 32px;
  padding: 16px;
  background: var(--color-bg);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--color-text-muted);
}
.sidebar-help-card-title { font-weight: 600; margin-bottom: 4px; color: var(--color-primary); }

.main-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }

.pharmacy-selector { position: relative; }
.pharmacy-selector-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  transition: all 0.2s;
}
.pharmacy-selector-btn:hover { background: var(--color-primary-soft); }

.pharmacy-selector-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  padding: 6px;
  min-width: 260px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
}
.pharmacy-selector-dropdown.open { display: block; }
.pharmacy-option {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pharmacy-option:hover { background: var(--color-bg); }
.pharmacy-option.active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }

.status-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--color-primary-soft);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
}
.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-primary-light);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

.user-menu {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  background: var(--color-bg);
  border-radius: var(--r-full);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-lighter));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.user-info-name { font-size: 13px; font-weight: 600; color: var(--color-text); line-height: 1.2; }
.user-info-role { font-size: 11px; color: var(--color-text-muted); }

.content { padding: 24px; flex: 1; }

.app-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-card);
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted);
}
.app-footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.app-footer .brand {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  color: var(--color-primary);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}
.page-subtitle { font-size: 14px; color: var(--color-text-muted); }

/* ============== CARDS ============== */
.card {
  background: var(--color-card);
  border-radius: var(--r-lg);
  padding: 20px;
  border: 1px solid var(--color-border);
  transition: all 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--color-card);
  border-radius: var(--r-xl);
  padding: 24px;
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}
.stat-card-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.stat-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-card-label { font-size: 13px; color: var(--color-text-muted); }
.stat-card-value {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 4px;
}

/* ============== BUTTONS ============== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1.2;
}
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: white;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(26,77,46,0.25);
  color: white;
}
.btn-secondary {
  background: var(--color-card);
  color: var(--color-primary);
  border: 1px solid var(--color-border-strong);
}
.btn-secondary:hover { background: var(--color-bg); }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 15px; }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-icon-only {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--color-bg);
  color: var(--color-text-muted);
  padding: 0;
}
.btn-icon-only:hover { background: var(--color-border); color: var(--color-primary); }

/* ============== FORMS ============== */
.form-group { margin-bottom: 16px; }
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}
.input, .select, textarea.input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  background: white;
  font-family: inherit;
  color: var(--color-text);
  transition: all 0.2s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}
.input-with-icon { position: relative; }
.input-with-icon .icon-left {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-light);
  pointer-events: none;
}
.input-with-icon .input { padding-left: 42px; }

.form-error { font-size: 12px; color: var(--color-danger); margin-top: 4px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] { accent-color: var(--color-primary); }

/* ============== TABLES ============== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-card);
  border-radius: var(--r-md);
  overflow: hidden;
}
.table th {
  background: var(--color-bg);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
}
.table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--color-border);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfa; }

/* ============== BADGES ============== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-success { background: var(--color-success-bg); color: #0a3622; }
.badge-warning { background: var(--color-warning-bg); color: #664d03; }
.badge-danger { background: var(--color-danger-bg); color: #58151c; }
.badge-info { background: var(--color-info-bg); color: #052c65; }
.badge-neutral { background: #e5e7eb; color: #374151; }

/* ============== ALERTS ============== */
.alert {
  padding: 14px 16px;
  border-radius: var(--r-md);
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 4px solid;
}
.alert-success { background: var(--color-success-bg); color: #0a3622; border-color: var(--color-success); }
.alert-error { background: var(--color-danger-bg); color: #58151c; border-color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: #664d03; border-color: var(--color-warning); }
.alert-info { background: var(--color-info-bg); color: #052c65; border-color: var(--color-info); }

/* ============== GRIDS ============== */
.grid-stats {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.grid-form {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.grid-cols-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* ============== EMPTY STATES ============== */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--color-text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

/* ============== UTILITIES ============== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ============== MOBILE / RESPONSIVE ============== */
.menu-toggle {
  display: none;
  background: var(--color-bg);
  border: none;
  padding: 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--color-text-muted);
}

.sidebar-close {
  display: none;
  background: var(--color-bg);
  border: none;
  padding: 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--color-text-muted);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,46,31,0.5);
  backdrop-filter: blur(4px);
  z-index: 25;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 1024px) {
  .sidebar { left: -280px; box-shadow: 8px 0 30px rgba(0,0,0,0.1); }
  .sidebar.open { left: 0; }
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .page-title { font-size: 24px; }
  .auth-card { padding: 28px 24px; }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .user-info { display: none; }
  .pharmacy-selector-btn span:not(.icon) { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
