/* ==========================================================================
   RADAR SANTÉ — Minimal Modern Design System (Pure Vanilla CSS)
   Optimized for Cloudflare Pages, Mobile-First Responsiveness, Zero Bloat
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', var(--font-sans);

  /* Dark Theme (Default) */
  --bg-app: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #18233c;
  --bg-input: #0f1626;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(56, 189, 248, 0.3);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #38bdf8;
  --accent-cyan-bg: rgba(56, 189, 248, 0.12);
  --accent-emerald: #10b981;
  --accent-emerald-bg: rgba(16, 185, 129, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.12);
  --accent-indigo: #6366f1;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-highlight: rgba(2, 132, 199, 0.4);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --accent-cyan: #0284c7;
  --accent-cyan-bg: #e0f2fe;
  --accent-emerald: #059669;
  --accent-emerald-bg: #d1fae5;
  --accent-amber: #d97706;
  --accent-amber-bg: #fef3c7;
  --accent-indigo: #4f46e5;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-radar-dot {
  width: 12px;
  height: 12px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.brand-meta {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-title span {
  color: var(--accent-cyan);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.icon-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
}

/* App Main Container */
.app-main {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  flex: 1;
}

/* Controls Card */
.controls-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.search-row {
  margin-bottom: 0.75rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-svg {
  position: absolute;
  left: 0.85rem;
  color: var(--text-dim);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 2.6rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--border-highlight);
}

.clear-btn {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-dim);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
}

.clear-btn.visible {
  display: flex;
}

/* Filter Chips (Horizontal Scroll on Mobile) */
.chips-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.chip.active {
  background: var(--accent-cyan);
  color: #041322;
  border-color: var(--accent-cyan);
  font-weight: 700;
}

/* Results Meta Bar */
.results-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meta-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.clear-selection-btn {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.clear-selection-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #ffffff;
  transform: translateY(-1px);
}

.per-page-selector {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.per-page-selector select {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

/* Cards List */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Practitioner Card — Clean & Mobile Focused */
.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.2s, box-shadow 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.doc-card:hover {
  border-color: var(--border-highlight);
  box-shadow: var(--shadow-md);
}

/* Selected Card Highlight */
.doc-card.is-selected {
  border-color: var(--accent-cyan);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.09) 0%, var(--bg-card) 55%);
  box-shadow: 0 0 0 1px var(--accent-cyan), var(--shadow-md);
}

/* Custom Checkbox on Card */
.doc-header-left {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  flex: 1;
}

.doc-select-box {
  display: flex;
  align-items: center;
  padding-top: 3px;
  flex-shrink: 0;
}

.checkbox-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.custom-checkmark {
  height: 22px;
  width: 22px;
  background-color: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.checkbox-container:hover input ~ .custom-checkmark {
  border-color: var(--accent-cyan);
  background-color: var(--accent-cyan-bg);
}

.checkbox-container input:checked ~ .custom-checkmark {
  background-color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}

.custom-checkmark:after {
  content: "";
  display: none;
  width: 5px;
  height: 10px;
  border: solid #041322;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.checkbox-container input:checked ~ .custom-checkmark:after {
  display: block;
}

/* Selected Chip Style */
.chip.chip-selected.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #000;
}

/* Card Header */
.doc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.doc-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.doc-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.doc-tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.tag-specialty {
  background: var(--accent-cyan-bg);
  color: var(--accent-cyan);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-sm);
}

.tag-origin {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

.tag-insurance {
  color: var(--accent-cyan);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sector-pill {
  color: var(--accent-emerald);
  font-weight: 600;
}

/* Score Pill */
.score-badge {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-md);
  font-weight: 800;
  line-height: 1;
}

.score-badge .score-num {
  font-size: 1.15rem;
  font-family: var(--font-heading);
}

.score-badge .score-lbl {
  font-size: 0.62rem;
  text-transform: uppercase;
  margin-top: 0.2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.score-100, .score-high {
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.score-med {
  background: var(--accent-cyan-bg);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.score-low {
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Essentials Grid */
.doc-essentials {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  font-size: 0.88rem;
  background: var(--bg-input);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

@media (min-width: 640px) {
  .doc-essentials {
    grid-template-columns: 1fr 1fr;
  }
}

.essential-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--text-muted);
}

.essential-icon {
  flex-shrink: 0;
  font-size: 1rem;
}

.essential-text {
  word-break: break-word;
}

.essential-text strong {
  color: var(--text-main);
}

.highlight-arabic {
  color: #10b981 !important;
  font-weight: 600;
}

.evidence-quote {
  display: block;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

/* Card Actions */
.doc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.2rem;
}

.btn-book {
  background: #0284c7;
  color: #ffffff;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  min-height: 42px;
}

.btn-book:hover {
  background: #0369a1;
  transform: translateY(-1px);
}

.btn-phone {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 42px;
  transition: background 0.2s;
}

.btn-phone:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-emerald);
}

/* Pagination Bar */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-btn.active {
  background: var(--accent-cyan);
  color: #041322;
  border-color: var(--accent-cyan);
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Loading & Empty States */
.loading-state, .empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.footer-tag {
  margin-top: 0.25rem;
  color: var(--text-dim);
}

/* Mobile Responsiveness Fine-Tuning */
@media (max-width: 600px) {
  .header-inner {
    padding: 0.75rem;
  }
  
  .brand-title {
    font-size: 1.1rem;
  }

  .brand-subtitle {
    display: none;
  }

  .app-main {
    padding: 0.65rem;
  }

  .controls-card {
    padding: 0.75rem;
  }

  .doc-card {
    padding: 0.9rem;
  }

  .doc-actions {
    justify-content: stretch;
  }

  .btn-book, .btn-phone {
    flex: 1;
    justify-content: center;
    text-align: center;
  }
}
