/* Common design tokens, utilities, and shared components */

/* Design tokens */
:root {
  /* Colors - light theme */
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-elevated: #ffffff; /* all surfaces white */
  --color-border: #e5e7eb;
  --color-text: #000000;
  --color-text-muted: #6b7280;
  --color-primary: #3c79ff;
  --color-primary-contrast: #ffffff;
  --color-accent: #16a34a;
  color-scheme: light;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 24px rgba(15, 23, 42, 0.12);
  /* Morpho (soft/glass) elevations */
  --morph-shadow-1: 0 8px 16px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
  --morph-shadow-2: 0 14px 28px rgba(0, 0, 0, 0.08), 0 8px 12px rgba(0, 0, 0, 0.06);
  --morph-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(0, 0, 0, 0.04);

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;
  --space-10: 72px;

  /* Layout */
  --container-max: 1200px;
}

/* Force light theme even if user prefers dark */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #ffffff;
    --color-surface: #ffffff;
    --color-elevated: #ffffff;
    --color-border: #e5e7eb;
    --color-text: #000000;
    --color-text-muted: #6b7280;
    --color-primary: #3c79ff;
    --color-primary-contrast: #ffffff;
    --color-accent: #16a34a;
  }
}

/* Layout helpers */
.container {
  width: min(100% - 32px, 1600px);
  margin-inline: auto;
}

/* Unified Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: linear-gradient(180deg, #ffffff, #fafafa);
  color: var(--color-text);
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  box-shadow: var(--morph-shadow-1), var(--morph-inset);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--morph-shadow-2), var(--morph-inset);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, #2563eb 100%);
  border-color: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(49, 92, 200, 0.28), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #2563eb;
  box-shadow: 0 12px 22px rgba(49, 92, 200, 0.32), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--color-surface) 0%, #f8fafc 100%);
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-color: var(--color-primary);
}

.btn-accent {
  background: linear-gradient(135deg, var(--color-accent) 0%, #15803d 100%);
  border-color: var(--color-accent);
  color: white;
  box-shadow: 0 8px 18px rgba(21, 128, 61, 0.28), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #15803d 0%, #166534 100%);
  border-color: #15803d;
  box-shadow: 0 12px 22px rgba(21, 128, 61, 0.32), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: #ef4444;
  color: white;
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.28), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border-color: #dc2626;
  box-shadow: 0 12px 22px rgba(220, 38, 38, 0.32), inset 0 1px 0 rgba(255,255,255,0.25);
}

/* Cards */
.card {
  background: linear-gradient(180deg, #ffffff, #fafafa);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--morph-shadow-1), var(--morph-inset);
}

/* Shared service listing components (used by home and search) */
.services-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 16px;
}

.service-card {
  background: linear-gradient(180deg, #ffffff, #fafafa);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  display: grid;
  gap: 10px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  cursor: pointer;
  box-shadow: var(--morph-shadow-1), var(--morph-inset);
  padding: 30px;
}

.service-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--morph-shadow-2), var(--morph-inset);
}

.service-card-image img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
}

.service-card-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.service-badge, .category-badge, .featured-badge {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #eef2ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 700;
}

.service-card-header { display: flex; align-items: center; justify-content: space-between; }
.service-provider { display: inline-flex; align-items: center; gap: 8px; color: #334155; }
.service-description { color: #475569; }
.service-location { display: inline-flex; gap: 6px; align-items: center; color: #334155; }
.service-metrics { display: flex; align-items: center; justify-content: space-between; color: #475569; }
.service-stats { color: #334155; }

@media (max-width: 1100px) {
  .services-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 700px) {
  .services-grid { grid-template-columns: 1fr; }
}

/* Navigation */
.nav-container {
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  .nav-container { background: rgba(255, 255, 255, 0.8); }
}

.nav-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  width: min(100% - 24px, var(--container-max));
  margin-inline: auto;
  position: relative;
}

/* Mobile grid layout */
@media (max-width: 900px) {
  .nav-inner {
    grid-template-columns: 1fr auto;
  }
  
  .nav-logo {
    font-size: 14px;
  }
  
  .nav-logo img {
    height: 32px;
  }
  
  .nav-hamburger {
    display: flex;
  }
  
  .mobile-nav-menu {
    display: flex;
  }
}

.nav-logo {
  color: var(--color-text);
  font-weight: 800;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-logo img {
  display: block;
  height: 40px;
  width: auto;
  border-radius: 8px;
  margin-right: 10px;
}

.nav-main {
  display: flex;
  justify-content: center;
}

/* Ensure desktop elements are visible on desktop */
@media (min-width: 901px) {
  .desktop-nav {
    display: flex !important;
  }
  
  .desktop-actions {
    display: flex !important;
  }
  
  .nav-hamburger {
    display: none !important;
  }
  
  .mobile-nav-menu {
    display: none !important;
  }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--color-text-muted);
  transition: background 160ms ease, color 160ms ease;
}

.nav-links a:hover {
  background: #f3f4f6;
  color: var(--color-text);
}

.nav-links a.active {
  background: #dbeafe;
  color: #1e3a8a;
}

.nav-hamburger {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  flex-direction: column;
  gap: 4px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1001;
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
  transition: all 0.3s ease;
  transform-origin: center;
}

.nav-hamburger.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-hamburger.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.nav-hamburger.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

.header-actions {
  display: flex;
  justify-content: flex-end;
}

.auth-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 14px;
}

.notification-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: linear-gradient(180deg, #ffffff, #fafafa);
  box-shadow: var(--morph-shadow-1), var(--morph-inset);
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ff6b6b;
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(255, 107, 107, 0.35);
}

.user-profile {
  position: relative;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 10px;
  transition: background 160ms ease;
}

.user-info:hover {
  background: #f3f4f6;
}

.profile-image img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--color-border);
}

.profile-initials {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dbeafe;
  color: #1e3a8a;
  font-weight: 800;
  border: 1px solid var(--color-border);
}

.user-name {
  color: var(--color-text);
  font-weight: 700;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 240px;
  background: linear-gradient(180deg, #ffffff, #fafafa);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  box-shadow: var(--morph-shadow-2), var(--morph-inset);
  padding: 8px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.profile-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.profile-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  color: var(--color-text);
}

.profile-dropdown a:hover {
  background: #f3f4f6;
}

/* Admin Panel Link Styling */
.admin-link {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  font-weight: 700 !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.admin-link:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4) !important;
}

/* Footer */
.footer-minimal {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 18px 0;
  margin-top: var(--space-9);
}

.footer-minimal .footer-links {
  display: flex;
  gap: 12px 18px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.footer-minimal .footer-links a {
  color: var(--color-text-muted);
}

.footer-minimal .footer-links a:hover {
  color: var(--color-text);
}

.footer-minimal .footer-copy {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* Scroll To Top - Highest Priority */
.scroll-to-top-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  z-index: 2147483647;
  border: 1px solid rgba(0,0,0,0.06);
  background: linear-gradient(180deg, #ffffff, #fafafa);
  color: var(--color-text);
  box-shadow: var(--morph-shadow-1), var(--morph-inset);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  isolation: isolate;
  will-change: transform;
  /* iOS Safari specific fixes */
  -webkit-transform: translateY(6px);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Force highest stacking context */
  transform-style: preserve-3d;
}

/* Mobile-specific scroll to top button */
@media (max-width: 900px) {
  .scroll-to-top-btn {
    z-index: 2147483647;
    bottom: 80px;
    right: 15px;
    width: 50px;
    height: 50px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
}

.scroll-to-top-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Z-Index Hierarchy:
 * -1: Background elements (overlays, backdrops)
 * 0: Base content
 * 1: Regular content elements
 * 10: Cards and elevated content
 * 100: Dropdowns and overlays
 * 1000: Navigation elements
 * 10000: Mobile menu
 * 2147483647: Scroll to top button (highest priority)
 */

/* Mobile Navigation Menu */
.mobile-nav-menu {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  bottom: 0;
  width: 100%;
  max-width: 320px;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  background: #ffffff;
  border-left: 1px solid var(--color-border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.1);
  z-index: 10000;
  transition: transform 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  pointer-events: none;
  isolation: isolate;
  will-change: transform;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

/* Mobile menu backdrop overlay */
.mobile-nav-menu::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.3);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.mobile-nav-menu.nav-open::before {
  opacity: 1;
  pointer-events: auto;
}

/* Ensure mobile menu is always on top when open */
body.mobile-menu-open {
  overflow: hidden;
}

/* Force mobile menu to be on top */
html, body {
  position: relative;
}

.mobile-nav-menu.nav-open {
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  background: #ffffff;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.2);
}

/* Removed duplicate rule - keeping only the clean version above */

.mobile-nav-content {
  padding: 20px;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  flex: 1;
  background: #ffffff;
  position: relative;
  z-index: 1;
}

.mobile-nav-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.mobile-nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-nav-links li {
  margin: 0;
  padding: 0;
}

.mobile-nav-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid transparent;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}

.mobile-nav-links a:hover {
  background: #f8fafc;
  border-color: var(--color-border);
  transform: translateX(4px);
}

.mobile-nav-links a.active {
  background: #dbeafe;
  color: #1e3a8a;
  border-color: #3b82f6;
}

/* Mobile Admin Link Styling */
.mobile-nav-links .admin-link {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  font-weight: 700 !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.mobile-nav-links .admin-link:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%) !important;
  transform: translateX(4px) !important;
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4) !important;
}

.mobile-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
  margin-bottom: 12px;
}

.mobile-profile-image {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.mobile-profile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-profile-initials {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--color-primary), #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}

.mobile-user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.mobile-user-type {
  font-size: 12px;
  color: var(--color-text-muted);
}

.mobile-notification-badge {
  background: #ef4444;
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.mobile-auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-btn {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

.mobile-logout {
  color: #ef4444 !important;
  background: #fef2f2 !important;
  border-color: #fecaca !important;
}

.mobile-logout:hover {
  background: #fee2e2 !important;
  border-color: #fca5a5 !important;
}

/* Responsive Navigation */
@media (max-width: 900px) {
  .nav-inner {
    grid-template-columns: 1fr auto;
  }

  .desktop-nav,
  .desktop-actions {
    display: none;
  }

  .nav-hamburger {
    display: flex;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .nav-logo {
    font-size: 12px;
  }
  
  .nav-logo img {
    height: 28px;
    margin-right: 6px;
  }
}

/* Hide mobile elements on desktop */
@media (min-width: 901px) {
  .nav-hamburger {
    display: none !important;
  }
  
  .mobile-nav-menu {
    display: none !important;
    transform: translateX(100%) !important;
  }
}



/* Motion reduction */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .service-card,
  .nav-links a,
  .profile-dropdown,
  .scroll-to-top-btn {
    transition: none !important;
  }
}


/* Generic modal overlay (used by login modal and others) */
/* For <dialog> element */
.login-modal {
  border: none;
  padding: 0;
  max-width: none;
  background: transparent;
}

.login-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.login-modal-content {
  width: min(92vw, 520px);
  background: var(--color-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.login-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
}

.login-modal-body { padding: 16px; color: var(--color-text); }
.login-modal-actions { display: flex; gap: 10px; margin-top: 12px; }
.login-modal .modal-close { border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface); height: 36px; padding: 0 10px; }


