@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;900&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --teal-900: #0B4A40;
  --teal-700: #0F6B5C;
  --teal-500: #17916F;
  --teal-100: #E3F3EE;

  --amber-500: #C9932F;

  --bg: #F6F7F5;
  --surface: #FFFFFF;
  --surface-2: #F0F2EF;
  --border: #E2E5E1;
  --text: #14201C;
  --text-secondary: #5B6864;
  --text-muted: #8B958F;
  --danger: #B3432B;
  --success: #1E8A5F;

  --accent: var(--teal-700);
  --on-accent: #FFFFFF;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --font-ar: 'Tajawal', 'Segoe UI', sans-serif;
  --font-en: 'Inter', 'Segoe UI', sans-serif;

  --shadow: 0 1px 2px rgba(20, 32, 28, 0.04), 0 4px 16px rgba(20, 32, 28, 0.06);
}

[data-theme="dark"] {
  --bg: #0E1613;
  --surface: #16211D;
  --surface-2: #1C2822;
  --border: #263630;
  --text: #EDF2EF;
  --text-secondary: #A9B6B0;
  --text-muted: #71807A;
  --teal-100: #143A32;
  --accent: var(--teal-500);
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body {
  font-family: var(--font-ar);
  -webkit-font-smoothing: antialiased;
}

html[dir="ltr"] body { font-family: var(--font-en); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -------------------- الهيكل العام -------------------- */

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 900px) {
  .app-shell {
    max-width: 560px;
    margin: 24px auto;
    min-height: calc(100vh - 48px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
  }
}

/* -------------------- الرأس -------------------- */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
}

.brand-pulse {
  width: 22px;
  height: 22px;
  display: block;
}

.top-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* -------------------- البحث والفلاتر -------------------- */

.search-section {
  padding: 14px 18px 6px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
}
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box svg { flex-shrink: 0; color: var(--text-muted); }

.filter-chips {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.15s ease;
}
.chip.active {
  background: var(--teal-100);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 500;
}

/* -------------------- التبويبات -------------------- */

.tabs {
  display: flex;
  padding: 12px 18px 0;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  text-align: center;
  padding: 8px 0 12px;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none; border-left: none; border-right: none;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* -------------------- نتائج البحث -------------------- */

.results-list {
  flex: 1;
  padding: 12px 18px 90px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.provider-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.provider-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--teal-100);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.provider-info { flex: 1; min-width: 0; }

.provider-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.provider-name { font-weight: 600; font-size: 14.5px; }
.verified-badge { color: var(--accent); font-size: 14px; }

.provider-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 3px 0 6px;
}

.provider-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.provider-stats .stat { display: flex; align-items: center; gap: 3px; }
.star { color: var(--amber-500); }

.tier-badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.tier-badge.gold { background: #FBF0DA; color: #92660F; }
.tier-badge.platinum { background: #EDEBFB; color: #5B4FC4; }
.tier-badge.silver { background: #EEF0EF; color: #566159; }

.empty-state, .loading-state, .error-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 13.5px;
}
.error-state { color: var(--danger); }

/* -------------------- شارة النبض (Signature element) -------------------- */

.pulse-divider {
  width: 100%;
  height: 20px;
  overflow: hidden;
  opacity: 0.5;
}
.pulse-divider svg { width: 100%; height: 100%; }
.pulse-path {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  animation: draw-pulse 1.6s ease-out forwards;
}
@keyframes draw-pulse {
  to { stroke-dashoffset: 0; }
}

/* -------------------- شريط التنقل السفلي -------------------- */

.bottom-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 4px 12px;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 21px; height: 21px; }

/* -------------------- عناصر عامة -------------------- */

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* -------------------- اتجاه RTL/LTR -------------------- */

html[dir="rtl"] .provider-card { direction: rtl; }
html[dir="ltr"] .provider-card { direction: ltr; }

/* المحتوى الرئيسي يتمدد دائمًا ليملأ المساحة المتبقية، فيبقى شريط
   التنقل السفلي ثابتًا في أسفل الشاشة فعليًا حتى لو كان المحتوى قصيرًا */
.app-shell > main {
  flex: 1 1 auto;
}

/* سهم "رجوع" يعكس اتجاهه تلقائيًا حسب لغة الواجهة: يشير لليسار في
   الإنجليزية (LTR) ولليمين في العربية (RTL) */
html[dir="rtl"] #back-btn svg {
  transform: scaleX(-1);
}

/* -------------------- نماذج الإدخال (تسجيل الدخول / حساب جديد) -------------------- */

.auth-header {
  padding: 28px 20px 8px;
  text-align: center;
}
.auth-header .brand-pulse-lg {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  display: block;
}
.auth-header h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 4px;
}
.auth-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.auth-tabs {
  display: flex;
  margin: 18px 20px 6px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
}
.auth-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.auth-form {
  padding: 10px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}
.field input,
.field select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
}
.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}
.field-error {
  font-size: 11.5px;
  color: var(--danger);
  display: none;
}
.field.has-error input {
  border-color: var(--danger);
}
.field.has-error .field-error {
  display: block;
}

.form-alert {
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: none;
}
.form-alert.error {
  background: #FBE9E4;
  color: var(--danger);
  display: block;
}
.form-alert.success {
  background: var(--teal-100);
  color: var(--accent);
  display: block;
}
[data-theme="dark"] .form-alert.error { background: #3A241D; }

.btn-primary.loading { opacity: 0.7; pointer-events: none; }

.auth-footer-link {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.auth-footer-link a, .auth-footer-link button.link-btn {
  color: var(--accent);
  font-weight: 600;
  background: none;
  border: none;
  font-size: inherit;
  padding: 0;
}

.user-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.user-type-option {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--surface);
}
.user-type-option.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--teal-100);
  font-weight: 600;
}

/* -------------------- ملف الطبيب + الحجز -------------------- */

.profile-hero {
  padding: 20px 20px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.avatar-lg {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--teal-100);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  margin: 0 auto 10px;
}
.profile-hero h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.profile-hero .profile-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 4px 0 10px;
}
.profile-stats-row {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 12px;
  color: var(--text-secondary);
}
.profile-stats-row .stat { display: flex; align-items: center; gap: 4px; }

.section-block {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.section-block h2 {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
  margin: 0 0 10px;
}

.booking-type-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.booking-type-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
  text-align: center;
  background: var(--surface);
  color: var(--text-secondary);
}
.booking-type-card.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--teal-100);
}
.booking-type-card.disabled {
  opacity: 0.35;
  pointer-events: none;
}
.booking-type-card svg { width: 18px; height: 18px; margin-bottom: 4px; }
.booking-type-card .bt-label { font-size: 10.5px; display: block; }
.booking-type-card .bt-price { font-size: 10px; color: var(--text-muted); display: block; margin-top: 2px; }

.slots-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.slot-chip {
  flex-shrink: 0;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong, var(--border));
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
.slot-chip.active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-pill {
  font-size: 10.5px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
}

.address-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
}
.address-input:focus { border-color: var(--accent); }

.booking-footer {
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.booking-footer .price-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}
.booking-footer .price-row strong { color: var(--text); font-size: 15px; }

/* -------------------- صفحة حسابي -------------------- */

.account-hero {
  padding: 24px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.account-hero .status-pill {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--teal-100);
  color: var(--accent);
  font-weight: 600;
}
.account-hero .status-pill.pending {
  background: #FBF0DA;
  color: #92660F;
}

.info-list {
  padding: 6px 20px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.info-row .info-label { color: var(--text-secondary); }
.info-row .info-value { font-weight: 500; }

.menu-list {
  padding: 6px 20px;
}
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text);
  background: none;
  border-top: none; border-left: none; border-right: none;
  width: 100%;
  text-align: inherit;
}
.menu-item .menu-left { display: flex; align-items: center; gap: 10px; }
.menu-item svg { width: 19px; height: 19px; color: var(--text-secondary); }
.menu-item .soon-badge {
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
}
.menu-item .chevron { color: var(--text-muted); }

.btn-danger-outline {
  width: calc(100% - 40px);
  margin: 18px 20px;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger);
  color: var(--danger);
  background: none;
  font-size: 14px;
  font-weight: 600;
}
.btn-danger-outline.loading { opacity: 0.6; pointer-events: none; }
