/* ==========================================================================
   XClinic — Production Header & Mobile Navigation Layer (Matching xclinicsys.com)
   ========================================================================== */

/* 1. Brand & Logo */
.public-header .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
  flex-shrink: 0;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  transition: transform 0.22s ease, opacity 0.18s ease;
}

.public-header .logo:hover {
  transform: translateY(-1px);
  opacity: 1;
}

.public-header .logo-copy {
  display: grid;
  gap: 0;
  min-width: 0;
}

.public-header .logo-title,
.public-header .public-clinic-name {
  color: var(--dark, #1e293b);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
  white-space: nowrap;
}

.public-header .logo-kicker {
  color: var(--gray, #64748b);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.3;
}

.public-header .logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: transparent;
  flex-shrink: 0;
  transition: transform 0.22s ease, filter 0.22s ease;
  overflow: visible;
}

.public-header .logo-icon .logo-img {
  width: 100%;
  height: 100%;
  max-width: 44px;
  max-height: 44px;
  object-fit: contain;
  display: block;
}

.public-header .logo:hover .logo-icon {
  transform: translateY(-2px) scale(1.06);
  filter: drop-shadow(0 4px 12px rgba(0, 102, 255, 0.4));
}

/* 2. Theme Toggle Switch (Exact xclinicsys.com Blue Gradient Pill) */
.theme-toggle-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}

.public-header .switch {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 30px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  transition: transform 0.22s ease, filter 0.22s ease;
}

.public-header .switch:hover {
  transform: translateY(-1px) scale(1.03);
  filter: saturate(1.12);
}

.public-header .switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

/* الخلفية المتدرجة */
.public-header .slider {
  position: absolute;
  inset: 0;
  border-radius: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  transition: .4s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
  border: none !important;
}

/* الحالة العادية (Light Mode) */
.public-header input:not(:checked) + .slider {
  background: linear-gradient(135deg, #1a5cff, #0044ff, #002bbd) !important;
}

/* الحالة التانية (Dark Mode) */
.public-header input:checked + .slider {
  background: linear-gradient(135deg, #0f172a, #1e293b) !important;
}

/* الدائرة المتحركة */
.public-header .slider:before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  border-radius: 50%;
  background: #90aeff !important;
  transition: .4s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* حركة الزر */
.public-header input:checked + .slider:before {
  transform: translateX(28px) !important;
}

/* الأيقونات الشمس والقمر */
.public-header .sun-icon,
.public-header .moon-icon {
  font-size: 12px;
  color: #fff !important;
  position: relative;
  z-index: 2;
  transition: opacity .3s ease;
}

/* شفافية الأيقونات */
.public-header input:not(:checked) + .slider .sun-icon {
  opacity: 1 !important;
}

.public-header input:not(:checked) + .slider .moon-icon {
  opacity: .4 !important;
}

.public-header input:checked + .slider .sun-icon {
  opacity: .4 !important;
}

.public-header input:checked + .slider .moon-icon {
  opacity: 1 !important;
}

/* 3. Header Action & Auth Buttons */
.public-header .header-actions-shell,
.public-header .public-theme-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.public-header .header-auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--primary, #004fff) 18%, var(--border-light, #e2e8f0));
  background: color-mix(in srgb, var(--primary, #004fff) 5%, transparent);
  color: var(--primary, #004fff);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.public-header .header-auth-btn:hover {
  background: color-mix(in srgb, var(--primary, #004fff) 12%, transparent);
  border-color: var(--primary, #004fff);
  transform: translateY(-1px);
}

html[data-theme="dark"] .public-header .header-auth-btn {
  border-color: rgba(56, 189, 248, 0.25);
  background: rgba(56, 189, 248, 0.08);
  color: #38bdf8;
}

/* 4. Desktop Header (>= 821px) */
@media screen and (min-width: 821px) {
  #smart-page-root > .public-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    min-height: 64px !important;
    padding-block: 10px !important;
    padding-inline: 18px !important;
    border: 1px solid color-mix(in srgb, var(--primary, #004fff) 8%, var(--border-light, #e9ecef)) !important;
    border-radius: 18px !important;
    background: color-mix(in srgb, var(--header-bg, #ffffff) 96%, transparent) !important;
    backdrop-filter: blur(18px) !important;
    -webkit-backdrop-filter: blur(18px) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04) !important;
    position: sticky !important;
    top: 10px !important;
    z-index: 1000 !important;
  }

  html[data-theme="dark"] #smart-page-root > .public-header {
    border-color: rgba(255, 255, 255, 0.08) !important;
    background: color-mix(in srgb, #18181b 96%, transparent) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
  }

  #smart-page-root > .public-header .public-nav-shell {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 1 auto !important;
  }

  #smart-page-root > .public-header .public-nav-shell > .nav-menu {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: clamp(4px, 0.75vw, 10px) !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link {
    min-width: 78px;
    min-height: 56px;
    padding: 5px 14px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 13px;
    color: var(--gray, #6c757d);
    text-decoration: none;
    line-height: 1.15;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    text-align: center;
    transition: color 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease !important;
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link:hover,
  #smart-page-root > .public-header .public-nav-shell .nav-link.active {
    color: var(--primary, #004fff);
    background: color-mix(in srgb, var(--primary, #004fff) 9%, var(--header-bg, #ffffff));
  }

  html[data-theme="dark"] #smart-page-root > .public-header .public-nav-shell .nav-link {
    color: #94a3b8;
  }

  html[data-theme="dark"] #smart-page-root > .public-header .public-nav-shell .nav-link:hover,
  html[data-theme="dark"] #smart-page-root > .public-header .public-nav-shell .nav-link.active {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link > :is(.mobile-icon, .nav-icon) {
    order: 1;
    display: grid !important;
    width: 28px;
    height: 28px;
    place-items: center;
    color: inherit;
    background: transparent;
    font-size: 15px;
    margin: 0 !important;
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link > :is(.links, .nav-label) {
    order: 2;
    color: inherit;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
  }

  #smart-page-root > .public-header .public-mobile-menu-btn,
  #smart-page-root > .public-header .public-mobile-drawer {
    display: none !important;
  }
}

/* 5. Mobile & Tablet Header (<= 820px) — Exact Glass Floating Bar */
@media screen and (max-width: 820px) {
  body {
    padding-bottom: 0 !important;
  }

  body > .container,
  #smart-page-root.container {
    padding-top: calc(86px + env(safe-area-inset-top)) !important;
    padding-bottom: 18px !important;
  }

  #smart-page-root > .public-header {
    position: fixed !important;
    top: max(7px, env(safe-area-inset-top)) !important;
    right: max(9px, env(safe-area-inset-right)) !important;
    left: max(9px, env(safe-area-inset-left)) !important;
    z-index: 1300 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    grid-template-rows: 58px !important;
    align-items: center !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 8px !important;
    gap: 5px !important;
    overflow: hidden !important;
    border: 1px solid color-mix(in srgb, var(--primary, #004fff) 14%, var(--border-light, #e9ecef)) !important;
    border-radius: 18px !important;
    background: color-mix(in srgb, var(--header-bg, #ffffff) 97%, transparent) !important;
    box-shadow: 0 12px 34px rgba(15, 35, 63, 0.14) !important;
    backdrop-filter: blur(18px) !important;
    -webkit-backdrop-filter: blur(18px) !important;
  }

  html[data-theme="dark"] #smart-page-root > .public-header {
    border-color: rgba(255, 255, 255, 0.08) !important;
    background: color-mix(in srgb, #18181b 97%, transparent) !important;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5) !important;
  }

  #smart-page-root > .public-header > .logo {
    position: static !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    display: flex !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    gap: 0 !important;
    overflow: hidden !important;
  }

  #smart-page-root > .public-header > .logo .logo-icon {
    width: 36px !important;
    height: 36px !important;
    flex: 0 0 36px !important;
    border-radius: 11px !important;
    background: transparent !important;
  }

  #smart-page-root > .public-header > .logo .logo-icon .logo-img {
    width: 100% !important;
    height: 100% !important;
    max-width: 36px !important;
    max-height: 36px !important;
    object-fit: contain !important;
    display: block !important;
  }

  #smart-page-root > .public-header > .logo .logo-copy {
    display: none !important;
  }

  #smart-page-root > .public-header > .public-theme-shell {
    position: static !important;
    grid-column: 3 !important;
    grid-row: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    margin: 0 !important;
  }

  #smart-page-root > .public-header .switch {
    width: 52px !important;
    height: 28px !important;
    min-width: 52px !important;
  }

  #smart-page-root > .public-header .switch .slider {
    padding: 0 7px !important;
    border-radius: 20px !important;
  }

  #smart-page-root > .public-header .switch .slider:before {
    width: 22px !important;
    height: 22px !important;
    left: 3px !important;
    bottom: 3px !important;
    background: #90aeff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
  }

  #smart-page-root > .public-header .switch input:checked + .slider:before {
    transform: translateX(24px) !important;
  }

  #smart-page-root > .public-header .switch .sun-icon,
  #smart-page-root > .public-header .switch .moon-icon {
    font-size: 11px !important;
    color: #fff !important;
  }

  #smart-page-root > .public-header > .public-nav-shell {
    position: static !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
  }

  #smart-page-root > .public-header .public-nav-shell > .nav-menu {
    position: static !important;
    inset: auto !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 220px !important;
    margin: 0 auto !important;
    padding: 2px !important;
    gap: 3px !important;
    overflow: hidden !important;
    border: 0 !important;
    border-radius: 14px !important;
    background: color-mix(in srgb, var(--bg, #f8f9fa) 76%, var(--header-bg, #ffffff)) !important;
    box-shadow: none !important;
    transform: none !important;
  }

  #smart-page-root > .public-header .public-nav-shell > .nav-menu::-webkit-scrollbar {
    display: none !important;
  }

  html[data-theme="dark"] #smart-page-root > .public-header .public-nav-shell > .nav-menu {
    background: rgba(255, 255, 255, 0.05) !important;
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 52px !important;
    padding: 3px 1px !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    border-radius: 11px !important;
    color: var(--gray, #6c757d) !important;
    background: transparent !important;
    line-height: 1.15 !important;
    text-decoration: none !important;
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link.active {
    color: var(--primary, #004fff) !important;
    background: color-mix(in srgb, var(--primary, #004fff) 11%, var(--header-bg, #ffffff)) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary, #004fff) 10%, transparent) !important;
  }

  html[data-theme="dark"] #smart-page-root > .public-header .public-nav-shell .nav-link.active {
    color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.12) !important;
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.2) !important;
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link > :is(.mobile-icon, .nav-icon) {
    order: 1 !important;
    display: grid !important;
    width: 25px !important;
    height: 25px !important;
    flex: 0 0 25px !important;
    place-items: center !important;
    color: inherit !important;
    background: transparent !important;
    font-size: 14px !important;
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link > :is(.links, .nav-label) {
    position: static !important;
    order: 2 !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    overflow: hidden !important;
    clip: auto !important;
    color: inherit !important;
    font-size: clamp(7px, 2.2vw, 9px) !important;
    font-weight: 800 !important;
    text-align: center !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .public-menu-toggle {
    display: none !important;
  }

  .whatsapp-float {
    bottom: max(14px, env(safe-area-inset-bottom)) !important;
  }
}

/* 6. Extra Small Screens (<= 360px) */
@media screen and (max-width: 360px) {
  body > .container,
  #smart-page-root.container {
    padding-top: calc(80px + env(safe-area-inset-top)) !important;
  }

  #smart-page-root > .public-header {
    grid-template-rows: 54px !important;
    padding: 6px !important;
    gap: 3px !important;
  }

  #smart-page-root > .public-header .public-nav-shell > .nav-menu {
    padding: 2px !important;
    gap: 1px !important;
  }

  #smart-page-root > .public-header .public-nav-shell .nav-link {
    min-height: 48px !important;
  }
}
