/**
 * İşBul Mobile / PWA CSS
 * Mobil deneyim iyileştirmeleri, bottom nav, touch-friendly UI
 * Yalnızca mobil cihazlarda ve PWA standalone modunda etkinleşir
 */

/* ─── CSS VARIABLES ─────────────────────────────────────────── */
:root {
  --bottom-nav-height: 64px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);
}

/* ─── GLOBAL MOBILE TOUCH FIXES ─────────────────────────────── */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
  }

  /* Daha iyi scroll performansı */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* Butonları daha büyük yap (minimum 44px touch target) */
  button, .btn, a.btn,
  [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Form elemanları */
  input, select, textarea {
    font-size: 16px !important; /* iOS zoom'u engeller */
    border-radius: 10px;
  }

  /* Navbar'ı mobil için optimize et */
  .navbar {
    padding: 10px 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  /* Bottom nav için sayfa alt padding */
  body {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  }

  /* PWA standalone modunda status bar */
  @media (display-mode: standalone) {
    .navbar {
      padding-top: calc(10px + var(--safe-area-top));
    }
  }
}

/* ─── BOTTOM NAVIGATION BAR ─────────────────────────────────── */
#mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  #mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 9990;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.3);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    height: var(--bottom-nav-height);
    text-decoration: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: color 0.2s, transform 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item:active {
    transform: scale(0.9);
  }

  .bottom-nav-item.active {
    color: #6C63FF;
  }

  .bottom-nav-item svg,
  .bottom-nav-item .nav-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2;
    transition: transform 0.2s;
  }

  .bottom-nav-item.active svg,
  .bottom-nav-item.active .nav-icon {
    transform: scale(1.15);
  }

  /* Aktif item için üst çizgi efekti */
  .bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: #6C63FF;
    border-radius: 0 0 4px 4px;
  }

  /* Orta buton (CTA - Uzman Bul) */
  .bottom-nav-item.center-btn {
    color: white;
  }

  .bottom-nav-item.center-btn .nav-icon-wrap {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #6C63FF, #a855f7);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 2px;
  }

  .bottom-nav-item.center-btn:active .nav-icon-wrap {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.4);
  }

  .bottom-nav-item.center-btn svg {
    color: white;
    stroke: white;
  }

  /* Badge */
  .bottom-nav-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 18px);
    background: #ef4444;
    color: white;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid rgba(15, 23, 42, 0.97);
  }
}

/* ─── MOBİL NAVBAR DÜZELTMELERI ─────────────────────────────── */
@media (max-width: 768px) {
  /* Desktop nav linkleri gizle */
  .navbar__links {
    display: none !important;
  }

  /* Desktop CTA butonları gizle - bottom nav'da olacak */
  .navbar__cta {
    display: none !important;
  }

  /* Sadece logo ve hamburger kalsın */
  .navbar__inner {
    justify-content: space-between;
  }

  /* Hamburger menü butonu */
  .navbar__hamburger {
    display: flex !important;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    cursor: pointer;
    color: white;
  }
}

/* ─── MOBİL DRAWER MENU ──────────────────────────────────────── */
#mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99995;
  display: none;
}

#mobile-drawer.open {
  display: block;
}

#mobile-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

#mobile-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(320px, 85vw);
  height: 100%;
  background: #0f172a;
  border-left: 1px solid rgba(255,255,255,0.08);
  padding: 0;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

#mobile-drawer.open #mobile-drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.drawer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
  font-weight: 800;
  font-size: 18px;
  text-decoration: none;
}

.drawer-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-user {
  padding: 16px 20px;
  background: rgba(108,99,255,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 12px;
}

.drawer-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6C63FF, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.drawer-user-info strong {
  display: block;
  color: white;
  font-size: 14px;
}

.drawer-user-info span {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
}

.drawer-nav {
  flex: 1;
  padding: 12px 0;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.drawer-nav-item:hover,
.drawer-nav-item.active {
  background: rgba(108,99,255,0.12);
  color: white;
}

.drawer-nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.drawer-nav-item.active svg,
.drawer-nav-item:hover svg {
  opacity: 1;
}

.drawer-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 8px 20px;
}

.drawer-footer {
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #6C63FF, #a855f7);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
}

.drawer-btn-primary:active {
  opacity: 0.9;
  transform: scale(0.98);
}

.drawer-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  background: rgba(255,255,255,0.07);
  color: white;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.drawer-btn-secondary:hover {
  background: rgba(255,255,255,0.12);
}

/* ─── PULL TO REFRESH INDICATOR ────────────────────────────── */
#pull-refresh-indicator {
  position: fixed;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: #6C63FF;
  color: white;
  padding: 8px 16px;
  border-radius: 0 0 20px 20px;
  font-size: 12px;
  font-weight: 600;
  z-index: 9999;
  transition: top 0.3s;
  display: none;
}

/* ─── MOBILE CARD SWIPE ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* Kartları yatay kaydırılabilir yap */
  .experts-grid,
  .services-grid {
    display: flex !important;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    padding: 4px 16px 16px;
    margin: 0 -16px;
    scrollbar-width: none;
  }

  .experts-grid::-webkit-scrollbar,
  .services-grid::-webkit-scrollbar {
    display: none;
  }

  .experts-grid > *,
  .services-grid > * {
    scroll-snap-align: start;
    flex-shrink: 0;
    width: 280px;
  }

  /* Section padding düzelt */
  .section {
    padding: 32px 16px;
  }

  .container {
    padding: 0 16px;
  }

  /* Hero section mobil */
  .hero {
    padding: 80px 16px 40px;
    min-height: auto;
  }

  .hero__title {
    font-size: clamp(28px, 8vw, 42px) !important;
    line-height: 1.2 !important;
  }

  .hero__subtitle {
    font-size: 15px !important;
  }

  /* Search bar mobil */
  .search-bar {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px !important;
  }

  .search-bar input,
  .search-bar select {
    width: 100% !important;
  }

  /* Stat cards mobil - 2 sütun */
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px;
  }

  /* Modal tam ekran yap */
  .modal-content {
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90vh !important;
    overflow-y: auto;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }

  /* FAB (Floating Action Button) */
  .fab-btn {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 16px);
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6C63FF, #a855f7);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(108,99,255,0.5);
    z-index: 100;
    transition: transform 0.2s;
  }

  .fab-btn:active {
    transform: scale(0.92);
  }
}

/* ─── PWA SPLASH / LOADING ──────────────────────────────────── */
@media (display-mode: standalone) {
  /* PWA'da ek padding */
  .navbar {
    padding-top: calc(var(--safe-area-top) + 10px) !important;
  }

  /* Loading skeleton */
  .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
  }

  @keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }
}

/* ─── TOUCH FEEDBACK ────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Sadece dokunmatik ekranlarda */
  .btn:active,
  .card:active,
  .expert-card:active {
    transform: scale(0.97) !important;
    transition: transform 0.1s !important;
  }

  /* Hover efektlerini kaldır, onun yerine active kullan */
  .expert-card:hover {
    transform: none;
    box-shadow: inherit;
  }
}

/* ─── MOBILE TYPOGRAPHY ─────────────────────────────────────── */
@media (max-width: 480px) {
  h1 { font-size: clamp(24px, 7vw, 36px) !important; }
  h2 { font-size: clamp(20px, 6vw, 28px) !important; }
  h3 { font-size: clamp(16px, 5vw, 22px) !important; }

  .section-title {
    font-size: clamp(20px, 6vw, 28px) !important;
  }
}

/* ─── TABLET ────────────────────────────────────────────────── */
@media (min-width: 769px) {
  #mobile-bottom-nav {
    display: none !important;
  }

  #mobile-drawer {
    display: none !important;
  }
}
