/* ============================================
   TEXTMED — Design System v2
   Style : Dashboard médical minimaliste
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Variables ── */
:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #1a202c;
  --muted:     #718096;
  --accent:    #2563eb;
  --accent-lt: #eff6ff;
  --success:   #16a34a;
  --warning:   #d97706;
  --danger:    #dc2626;
  --sidebar-w: 220px;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ── */
.app-shell {
  display: flex;
  flex: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .2s;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand a { text-decoration: none; }
.sidebar-brand .logo-text {
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: .05em;
}
.sidebar-brand .logo-sub {
  font-size: .7rem;
  color: var(--muted);
  margin-top: .2rem;
  line-height: 1.3;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-section {
  padding: .5rem 1rem .25rem;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: all .15s;
  border-left: 3px solid transparent;
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg);
}
.nav-link.active {
  color: var(--accent);
  background: var(--accent-lt);
  border-left-color: var(--accent);
  font-weight: 500;
}
.nav-link i { font-size: 1rem; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.5;
}
.sidebar-footer a { color: var(--accent); text-decoration: none; }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .875rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-sub {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .1rem;
}
.topbar-actions { display: flex; gap: .5rem; }

.page-body {
  padding: 1.75rem 2rem;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
}
.card-body { padding: 1.25rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-ghost     { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; }
.btn-xs { padding: .2rem .5rem; font-size: .72rem; }

/* ── Tag pills (sous-catégories) ── */
.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: 1rem;
}
.tag {
  padding: .3rem .75rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--muted);
  transition: all .15s;
}
.tag:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }
.tag.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tag.success { background: #dcfce7; color: var(--success); border-color: #bbf7d0; }
.tag.success:hover, .tag.success.active { background: var(--success); color: #fff; border-color: var(--success); }
.tag.warning { background: #fef3c7; color: var(--warning); border-color: #fde68a; }
.tag.warning:hover, .tag.warning.active { background: var(--warning); color: #fff; border-color: var(--warning); }

/* ── Form elements ── */
.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea.form-control {
  font-family: 'DM Mono', monospace;
  font-size: .8rem;
  resize: vertical;
  line-height: 1.6;
}
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.input-sm { padding: .35rem .6rem; font-size: .8rem; }
.input-xs { width: 70px; padding: .3rem .5rem; font-size: .8rem; }

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--muted);
  cursor: pointer;
}
.form-check input[type=checkbox] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Autocomplete suggestions ── */
.suggestions-wrapper { position: relative; }
.suggestions-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}
.suggestions-list li {
  padding: .6rem .9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  list-style: none;
  font-size: .85rem;
}
.suggestions-list li:last-child { border-bottom: none; }
.suggestions-list li:hover, .suggestions-list li.selected { background: var(--accent-lt); color: var(--accent); }
.suggestion-info { font-size: .75rem; color: var(--muted); }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.col-span-2 { grid-column: span 2; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Constantes inline ── */
.constante-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
  font-size: .85rem;
  color: var(--text);
  flex-wrap: wrap;
}
.constante-label { min-width: 160px; color: var(--muted); font-size: .8rem; }

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-box.modal-lg { max-width: 680px; }
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-weight: 600; font-size: .9rem; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1.1rem; padding: .2rem;
}
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
}
.badge-blue { background: var(--accent-lt); color: var(--accent); }
.badge-green { background: #dcfce7; color: var(--success); }

/* ── Hamburger (mobile) ── */
.hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 1.2rem; padding: .2rem;
}

/* ── Dashboard home cards ── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.home-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.home-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.home-card-icon {
  font-size: 1.6rem;
  color: var(--accent);
}
.home-card-title { font-weight: 600; font-size: .9rem; }
.home-card-desc { font-size: .78rem; color: var(--muted); line-height: 1.5; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .page-body { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: .75rem 1rem; }
}
