/* ==========================================================================
   Telegram Mini App - Modern Orange Theme Stylesheet
   Designed for Hamtar Ads Mini App
   ========================================================================== */

:root {
  /* Neon Orange & Dark Luxury Palette */
  --primary: #ff6a00;
  --primary-hover: #ff8522;
  --primary-dark: #e05300;
  --primary-glow: rgba(255, 106, 0, 0.45);
  --primary-glow-strong: rgba(255, 106, 0, 0.7);
  --primary-subtle: rgba(255, 106, 0, 0.14);
  --primary-gradient: linear-gradient(135deg, #ff5500 0%, #ff7700 50%, #ffa100 100%);
  --primary-gradient-active: linear-gradient(135deg, #e64a00 0%, #ff6a00 100%);
  
  --accent: #ffa629;
  --success: #10b981;
  --danger: #ef4444;
  
  /* Backgrounds & Glassmorphism */
  --bg-main: #0c0f17;
  --bg-surface: #141824;
  --bg-surface-elevated: #1a2030;
  --bg-card: rgba(20, 24, 36, 0.85);
  --bg-card-hover: rgba(28, 34, 52, 0.95);
  --bg-glass: rgba(18, 22, 33, 0.75);
  
  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-card: rgba(255, 255, 255, 0.1);
  --border-active: rgba(255, 106, 0, 0.5);
  
  /* Typography */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.5);
  --shadow-orange: 0 8px 25px rgba(255, 106, 0, 0.38);
  --shadow-orange-lg: 0 12px 35px rgba(255, 106, 0, 0.55);
  
  /* Layout */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Telegram Dynamic Theme Overrides if available */
body.telegram-theme {
  --bg-main: var(--tg-theme-bg-color, #0c0f17);
  --text-main: var(--tg-theme-text-color, #f8fafc);
  --text-muted: var(--tg-theme-hint-color, #94a3b8);
}

/* Reset & Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  position: relative;
  background-image: 
    radial-gradient(circle at 10% 0%, rgba(255, 106, 0, 0.12) 0%, transparent 35%),
    radial-gradient(circle at 90% 80%, rgba(255, 106, 0, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

/* App Container */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 90px;
  position: relative;
}

/* Header & Top Bar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 16px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  padding: 2px;
  background: var(--primary-gradient);
  box-shadow: 0 0 14px var(--primary-glow);
}

.user-avatar {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
  background-color: var(--bg-surface-elevated);
  display: block;
}

.user-status-dot {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 12px;
  height: 12px;
  background: var(--success);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-greeting {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.user-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-badge {
  font-size: 0.65rem;
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-glow);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
}

.btn-icon:hover, .btn-icon:active {
  background: var(--bg-surface-elevated);
  border-color: var(--primary);
  transform: scale(0.96);
}

.cart-counter-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 8px var(--primary-glow-strong);
  border: 2px solid var(--bg-surface);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0); }
  70% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Banner / Hero Section */
.hero-banner {
  margin: 16px 16px 8px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 106, 0, 0.22) 0%, rgba(20, 24, 36, 0.95) 80%);
  border: 1px solid var(--border-active);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -30px;
  left: -30px;
  width: 110px;
  height: 110px;
  background: var(--primary-glow);
  filter: blur(40px);
  border-radius: 50%;
  pointer-events: none;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
  border: 1px solid rgba(255, 106, 0, 0.3);
}

.hero-title {
  font-size: 1.2rem;
  font-weight: 900;
  margin-bottom: 4px;
  color: #fff;
}

.hero-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Search Bar */
.search-container {
  padding: 12px 16px 6px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  gap: 10px;
  transition: var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  width: 100%;
  direction: rtl;
}

.search-input::placeholder {
  color: var(--text-dim);
}

.search-clear {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: none;
}

.search-clear.visible {
  display: block;
}

/* Categories Filter Pills */
.categories-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.categories-nav::-webkit-scrollbar {
  display: none;
}

.category-chip {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.category-chip:hover {
  border-color: var(--primary-glow);
  color: var(--text-main);
}

.category-chip.active {
  background: var(--primary-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--primary-gradient);
  border-radius: 4px;
  display: inline-block;
}

.section-count {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Products Grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 0 16px 20px;
}

/* Product Card */
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  cursor: pointer;
}

.product-card:active {
  transform: scale(0.98);
}

.product-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-md), 0 0 20px rgba(255, 106, 0, 0.15);
}

/* Card Image Area */
.card-img-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #11151f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.product-card:hover .card-img {
  transform: scale(1.05);
}

.card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  box-shadow: 0 3px 10px var(--primary-glow);
  z-index: 2;
}

.card-rating {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(12, 15, 23, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  color: #ffc107;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 3px;
  z-index: 2;
}

/* Card Content */
.card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-category {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 4px;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.8em;
}

.card-price-row {
  margin-top: auto;
  margin-bottom: 10px;
}

.card-original-price {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-decoration: line-through;
  display: block;
}

.card-price {
  font-size: 1rem;
  font-weight: 900;
  color: var(--primary);
}

.card-price span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 2px;
}

/* Orange Punchy Buttons */
.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-orange);
  transition: all var(--transition-fast);
  width: 100%;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  box-shadow: var(--shadow-orange-lg);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--primary-gradient-active);
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Quantity Control Buttons on Card */
.card-qty-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 4px 6px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px var(--primary-glow);
  transition: var(--transition-fast);
}

.qty-btn:active {
  transform: scale(0.9);
}

.qty-display {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--text-main);
}

/* Floating Bottom Cart Bar */
.cart-floating-bar {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 448px;
  margin: 0 auto;
  background: linear-gradient(135deg, rgba(20, 24, 36, 0.95), rgba(28, 34, 52, 0.95));
  border: 1px solid var(--border-active);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg), 0 0 30px rgba(255, 106, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  transform: translateY(120%);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cart-floating-bar.active {
  transform: translateY(0);
}

.cart-info {
  display: flex;
  flex-direction: column;
}

.cart-count-txt {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cart-total-txt {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--primary);
}

.btn-checkout {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  padding: 11px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-orange);
  transition: var(--transition-fast);
}

.btn-checkout:active {
  transform: scale(0.97);
}

/* Modals & Bottom Sheets */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 1, 0.23, 1);
}

.modal-overlay.open .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle-bar {
  width: 100%;
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
  cursor: grab;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  background: var(--border-subtle);
  border-radius: 10px;
}

.sheet-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
}

.btn-close {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-close:active {
  transform: scale(0.9);
}

.sheet-body {
  padding: 20px;
  overflow-y: auto;
}

/* Detail Modal Styles */
.detail-img-wrap {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #10141f;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-title {
  font-size: 1.25rem;
  font-weight: 900;
  margin-bottom: 8px;
  color: #fff;
}

.detail-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 16px;
}

.detail-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.detail-feat-item {
  background: var(--bg-surface-elevated);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-feat-item svg {
  color: var(--primary);
  flex-shrink: 0;
}

/* Cart Sheet Styles */
.cart-items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.cart-item-row {
  display: flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  gap: 12px;
}

.cart-item-thumb {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #0f131c;
  flex-shrink: 0;
}

.cart-item-info {
  flex-grow: 1;
}

.cart-item-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #fff;
}

.cart-item-price {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--primary);
}

.cart-form-group {
  margin-bottom: 14px;
}

.cart-form-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.cart-input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  direction: rtl;
  transition: var(--transition-fast);
}

.cart-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.cart-summary-box {
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.summary-row.total {
  font-size: 1.1rem;
  font-weight: 900;
  color: #fff;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  margin-bottom: 0;
}

.summary-row.total .price {
  color: var(--primary);
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 14px;
  display: inline-block;
}

.empty-text {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Success Celebration Modal */
.success-card {
  text-align: center;
  padding: 30px 20px 20px;
}

.success-icon-wrap {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  background: var(--primary-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px var(--primary-glow-strong);
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 30px var(--primary-glow-strong); }
  50% { transform: scale(1.05); box-shadow: 0 0 45px var(--primary-glow-strong); }
}

.success-order-num {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--primary);
  background: var(--primary-subtle);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--primary);
  display: inline-block;
  margin: 12px 0 18px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.toast {
  background: rgba(22, 27, 40, 0.96);
  border: 1px solid var(--border-active);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg), 0 4px 15px rgba(255, 106, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  animation: toastSlideDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes toastSlideDown {
  0% { opacity: 0; transform: translateY(-20px); }
  100% { opacity: 1; transform: translateY(0); }
}
