/**
 * آی سیرجان - قالب مدرن و سبک
 * Mobile-first, fast, RTL-ready
 */
:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-elevated: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;
  --color-primary: #ea580c;
  --color-primary-hover: #c2410c;
  --color-primary-soft: rgba(234, 88, 12, 0.08);
  --color-accent: #4f46e5;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
  --nav-height: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --header-height: 56px;
}

/* Base - سبک و خوانا، حس اپ در موبایل */
body {
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}
@media (max-width: 767px) {
  body {
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-app {
    touch-action: pan-y;
  }
}

.mobile-app {
  background: var(--color-surface);
  box-shadow: none;
  min-height: 100vh;
  max-width: 100%;
}

@media (min-width: 768px) {
  body {
    background: linear-gradient(160deg, #f1f5f9 0%, #e2e8f0 100%);
  }
  .mobile-app {
    max-width: 96%;
    margin: 16px auto;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
  }
}

@media (min-width: 1024px) {
  .mobile-app {
    max-width: 480px;
  }
}

@media (min-width: 1280px) {
  .mobile-app {
    max-width: 1320px;
    border-radius: 28px;
  }
}

/* Status bar - مینیمال، شبیه اپ */
.status-bar {
  height: 36px;
  min-height: 36px;
  background: var(--color-surface);
  padding: 0 12px;
  font-size: 11px;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
@media (min-width: 768px) {
  .status-bar { height: 40px; min-height: 40px; padding: 0 14px; font-size: 12px; }
}

/* Hero - فشرده در موبایل */
.hero-modern {
  background: linear-gradient(145deg, #ea580c 0%, #c2410c 100%);
  padding: 16px 14px 20px;
  position: relative;
}
@media (min-width: 768px) {
  .hero-modern { padding: 20px 16px 24px; }
}

.hero-modern::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 80%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero-modern .avatar-wrap {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  border: 2px solid rgba(255,255,255,0.4);
}

.hero-modern .greeting {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
}

.hero-modern .user-name {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Stories strip - فشرده در موبایل */
.stories-strip {
  background: var(--color-surface);
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--color-border);
}
@media (min-width: 768px) {
  .stories-strip { padding: 12px 12px 14px; }
}

.stories-strip .story-item {
  flex-shrink: 0;
  width: 64px;
  text-align: center;
}

.story-ring-modern {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  padding: 2px;
  background: linear-gradient(135deg, #f59e0b, #ec4899, #8b5cf6);
  margin: 0 auto 6px;
}

.story-ring-modern .inner {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--color-surface);
  padding: 2px;
  overflow: hidden;
}

.story-ring-modern img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Quick access / Chips - یکدست و سریع */
.quick-access {
  background: var(--color-surface);
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--color-border);
}

.quick-access .chip {
  flex-shrink: 0;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.quick-access .chip:active {
  transform: scale(0.97);
}

/* Cards - کارت‌های مدرن */
.card-modern {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-modern:active {
  box-shadow: var(--shadow-md);
}

/* Widgets (weather, market, etc.) */
.widget-modern {
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease;
}

.widget-modern:active {
  transform: scale(0.99);
}

/* Bottom navigation - شیک و پایدار */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-border);
  border-radius: 20px 20px 0 0;
  z-index: 1000;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.06);
}

.bottom-nav .nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--nav-height);
  padding: 0 8px;
}

.bottom-nav a {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  color: var(--color-text-subtle);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav a:hover,
.bottom-nav a:focus {
  color: var(--color-primary);
}

.bottom-nav a.text-primary,
.bottom-nav a.active {
  color: var(--color-primary);
}

.bottom-nav a i {
  font-size: 20px;
}

/* Map button در وسط نوار */
.bottom-nav .nav-map-btn {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: linear-gradient(145deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.4);
  margin-top: -18px;
  flex: 0 0 auto;
}

.bottom-nav .nav-map-btn i {
  font-size: 22px;
}

/* Spacer for bottom nav */
.bottom-nav-spacer {
  height: calc(var(--nav-height) + var(--safe-bottom) + 12px);
}

/* Gradient utilities - هماهنگ با تم */
.gradient-bg {
  background: linear-gradient(145deg, #ea580c 0%, #c2410c 100%) !important;
}

/* Container */
.container-modern {
  padding: 0 16px;
  max-width: 100%;
}

@media (min-width: 1280px) {
  .container-modern {
    padding: 0 24px;
  }
}

/* Typography */
.text-balance {
  text-wrap: balance;
}

/* Reduce motion برای عملکرد بهتر */
@media (prefers-reduced-motion: reduce) {
  .hero-modern::before,
  .quick-access .chip,
  .card-modern,
  .widget-modern,
  .bottom-nav a {
    transition: none;
  }
}

/* Safe area برای آیفون با notch */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav-spacer {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Scrollbar پنهان برای نوار افقی */
.scrollbar-hide {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* تصحیح غلط املایی رایج در کلاس‌ها */
.blcok { display: block; }

/* ========== نسخه اپ موبایل ========== */

/* دسترسی سریع - یک ردیف شش تایی + بیشتر */
.quick-access-app {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.quick-access-app .quick-access-inner {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quick-access-app .quick-access-inner::-webkit-scrollbar {
  display: none;
}
.quick-access-app .chip {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
}
.quick-access-app .chip-more {
  background: var(--color-border) !important;
  color: var(--color-text) !important;
}

/* نوار ابزار فشرده موبایل - یک ردیف سبک */
.home-tools-mobile {
  display: none;
}
@media (max-width: 767px) {
  .home-tools-mobile {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
  }
  .home-tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
  }
  .home-tool-item i {
    font-size: 18px;
    color: var(--color-primary);
  }
  .home-tool-item:first-child {
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.1));
    color: #1e40af;
  }
  .home-tool-item:first-child i {
    color: #2563eb;
  }
}

/* ویجت‌های کامل فقط دسکتاپ */
.home-widgets-full {
  display: none;
}
@media (min-width: 768px) {
  .home-widgets-full {
    display: block;
  }
}

/* جستجو و دسته‌بندی - فشرده‌تر در موبایل */
@media (max-width: 767px) {
  .search-bar {
    padding: 10px 12px !important;
    border-radius: var(--radius-lg) !important;
  }
  .mobile-app .px-6 {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* بخش‌های پایین صفحه - بارگذاری تنبل برای عملکرد */
.home-section-lazy {
  content-visibility: auto;
  contain-intrinsic-size: 0 200px;
}

/* تب‌های صفحه اول */
.home-tabs-wrap {
  padding: 0 0 1rem;
}
.home-tabs {
  display: flex;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 12px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 30;
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  scrollbar-width: none;
}
.home-tabs::-webkit-scrollbar {
  display: none;
}
.home-tab-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.home-tab-btn i {
  font-size: 16px;
}
.home-tab-btn:hover,
.home-tab-btn:focus {
  color: var(--color-primary);
}
.home-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.home-tab-panels {
  min-height: 200px;
}
.home-tab-panel {
  display: none;
  padding: 12px 0 24px;
  animation: homeTabFade 0.2s ease;
}
.home-tab-panel.home-tab-panel--active {
  display: block;
}
@keyframes homeTabFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* دکمه شناور چت - بدون انیمیشن سنگین در موبایل */
@media (max-width: 767px) {
  .animate-bounce-slow {
    animation: none;
  }
  a.fixed.right-4.bottom-24 {
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  }
}

/* استایل‌های بخش پیشنهاد نزدیک و کشویی موبایل (جدا از HTML برای سبکی) */
@keyframes bounce-slow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.animate-bounce-slow {
  animation: bounce-slow 3s infinite;
}
.nearby-section {
  background: linear-gradient(180deg, #eef2ff 0%, #fff 100%);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 10px 30px -15px rgba(10, 31, 68, 0.2);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.nearby-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 55%);
  pointer-events: none;
}
.nearby-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 768px) {
  .nearby-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
  }
}
.nearby-title { font-size: 1.1rem; font-weight: 700; color: #1f2937; }
.nearby-description { font-size: 0.8rem; color: #475569; }
.nearby-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 480px) {
  .nearby-actions { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .nearby-actions { grid-template-columns: repeat(4, 1fr); gap: 12px; }
}
.nearby-slider { display: flex; flex-direction: column; gap: 6px; }
.nearby-slider label { font-size: 0.8rem; opacity: 0.8; }
.nearby-slider input[type="range"] { width: 100%; accent-color: #4f46e5; }
.nearby-button {
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.nearby-button.primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(79, 70, 229, 0.5);
}
.nearby-button.secondary {
  background: rgba(79, 70, 229, 0.1);
  color: #4338ca;
}
.nearby-lists { display: grid; gap: 20px; }
.nearby-group {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 15px -8px rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(99, 102, 241, 0.08);
}
.nearby-group-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.nearby-group-title { font-weight: 700; font-size: 1rem; color: #1e293b; display: flex; align-items: center; gap: 8px; }
.nearby-group-title span.icon {
  width: 32px; height: 32px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(79, 70, 229, 0.1); color: #4338ca;
}
.nearby-items { display: grid; gap: 12px; }
.nearby-item {
  padding: 12px;
  border-radius: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  transition: all 0.2s ease;
}
.nearby-item .badge { font-size: 0.7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(59, 130, 246, 0.15); color: #1d4ed8; }
.nearby-item .distance { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; color: #475569; font-weight: 600; }
.nearby-empty { padding: 40px; text-align: center; color: #64748b; }
.nearby-error {
  background: rgba(245, 70, 99, 0.15);
  color: #b91c1c;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
}
.nearby-loader {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px dashed rgba(79, 70, 229, 0.2);
  color: #4338ca;
  background: rgba(79, 70, 229, 0.08);
}
@media (max-width: 768px) {
  .mobile-collapsible { position: relative; padding-bottom: 3rem; }
  .mobile-collapsible[data-expanded="false"] .mobile-collapsible-inner {
    max-height: 220px;
    overflow: hidden;
    position: relative;
  }
  .mobile-collapsible[data-expanded="false"] .mobile-collapsible-inner::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 80px;
    background: linear-gradient(0deg, rgba(255,255,255,0.95) 20%, transparent);
    pointer-events: none;
  }
  .mobile-collapsible-toggle {
    position: absolute;
    left: 50%;
    bottom: 0.6rem;
    transform: translateX(-50%);
    background: rgba(15, 118, 110, 0.15);
    color: #0f766e;
    border: none;
    border-radius: 999px;
    padding: 0.5rem 1.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(8px);
  }
}
