@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --bg-primary: var(--tg-theme-bg-color, #0a0f1d);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #111a2e);
  --card-bg: rgba(21, 30, 50, 0.85);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-hover: rgba(16, 185, 129, 0.35);
  --text-main: var(--tg-theme-text-color, #f8fafc);
  --text-muted: var(--tg-theme-hint-color, #94a3b8);
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-gold: #fbbf24;
  --accent-indigo: #6366f1;
  --accent-rose: #f43f5e;
  --accent-cyan: #06b6d4;
  --badge-bg: rgba(255, 255, 255, 0.05);
  --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "ss01" 1;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: calc(var(--safe-bottom) + 32px);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Glass Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  max-width: 100%;
  background: rgba(10, 15, 29, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  padding: calc(var(--safe-top) + 12px) 14px 10px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
  flex-shrink: 0;
}

.brand-info {
  min-width: 0;
  flex: 1;
}

.brand-info h1 {
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-info p {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  padding: 4px 8px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 600;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.refresh-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.refresh-btn:active {
  transform: scale(0.92) rotate(45deg);
}

/* Search Box */
.search-container {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  height: 42px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0 38px 0 36px;
  color: #ffffff;
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--accent-emerald);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.search-input::placeholder {
  color: #64748b;
  font-size: 0.78rem;
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-clear {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  display: none;
  font-size: 1.1rem;
  padding: 4px;
}

/* Category Slider */
.category-nav-wrapper {
  margin-top: 8px;
  width: 100%;
  overflow: hidden;
}

.category-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 2px 6px;
  scroll-behavior: smooth;
  width: 100%;
}

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

.category-pill {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-pill:active {
  transform: scale(0.95);
}

.category-pill.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: #10b981;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.pill-count {
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 6px;
  border-radius: 8px;
}

/* Sub-filters bar */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px 4px;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.speed-filters {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.speed-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.speed-chip.active {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
  font-weight: 600;
}

.sort-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  max-width: 130px;
}

.sort-select option {
  background: #111a2e;
  color: #ffffff;
}

/* Products Count Banner */
.results-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 14px 8px;
  font-size: 0.74rem;
  color: var(--text-muted);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.results-info span strong {
  color: var(--accent-emerald-light);
  font-weight: 700;
}

/* Products Grid */
.products-container {
  padding: 4px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Product Card */
.product-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.category-tag {
  font-size: 0.7rem;
  color: var(--accent-emerald-light);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  max-width: 65%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turnaround-tag {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.turnaround-tag.express {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.turnaround-tag.standard {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.product-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.45;
  word-break: break-word;
}

/* Specs Grid */
.specs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 8px 10px;
  border-radius: 10px;
  width: 100%;
  box-sizing: border-box;
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  min-width: 0;
}

.spec-icon {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.spec-label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.spec-value {
  color: #e2e8f0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
}

/* Card Footer */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  gap: 12px;
}

.price-box {
  display: flex;
  flex-direction: column;
}

.price-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.price-amount {
  font-size: 1.15rem;
  font-weight: 900;
  color: #34d399;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.price-currency {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.order-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: all 0.2s;
}

.order-btn:active {
  transform: scale(0.94);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
}

/* Loading & Infinite Scroll */
.loading-sentinel {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  display: none;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.7;
}

.empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 0.82rem;
}

/* Order Bottom Sheet Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  display: flex;
  align-items: flex-end;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  width: 100%;
  background: #111a2e;
  border-radius: 24px 24px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 16px 20px calc(var(--safe-bottom) + 20px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 85vh;
  overflow-y: auto;
}

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

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.sheet-header {
  margin-bottom: 16px;
}

.sheet-category {
  font-size: 0.72rem;
  color: var(--accent-emerald-light);
  font-weight: 600;
  margin-bottom: 4px;
}

.sheet-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.4;
}

.sheet-specs-table {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-spec-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sheet-spec-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sheet-spec-label {
  color: var(--text-muted);
}

.sheet-spec-value {
  color: #ffffff;
  font-weight: 600;
}

/* Design Service Options */
.design-option-group {
  margin-bottom: 16px;
}

.design-option-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.design-radio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.design-radio-card.selected {
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--accent-emerald);
}

.radio-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.design-radio-card.selected .radio-circle {
  border-color: var(--accent-emerald);
}

.radio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  display: none;
}

.design-radio-card.selected .radio-dot {
  display: block;
}

.radio-label-text {
  font-size: 0.82rem;
  color: #ffffff;
  font-weight: 500;
}

.radio-subtext {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Order Summary & Submit */
.sheet-summary {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.05) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-title {
  font-size: 0.78rem;
  color: #e2e8f0;
}

.summary-price {
  font-size: 1.3rem;
  font-weight: 900;
  color: #34d399;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.telegram-submit-btn {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
  transition: all 0.2s;
}

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

.sheet-close-btn {
  width: 100%;
  height: 42px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.sheet-close-btn:active {
  background: rgba(255, 255, 255, 0.08);
}

/* Customer Contact Form */
.order-contact-group {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.contact-group-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 10px;
}

.order-form-row {
  margin-bottom: 10px;
}

.order-form-row:last-child {
  margin-bottom: 0;
}

.order-input-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.order-input, .order-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 9px 12px;
  color: #ffffff;
  font-family: var(--font-family);
  font-size: 0.82rem;
  transition: all 0.2s;
  outline: none;
}

.order-input:focus, .order-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.order-textarea {
  resize: none;
  line-height: 1.5;
}

/* Success Confirmation Screen */
.order-success-screen {
  padding: 36px 16px 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.success-icon-wrapper {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.12);
  border: 2px solid rgba(34, 197, 94, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  animation: pulseSuccess 2s infinite;
}

@keyframes pulseSuccess {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  70% { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.success-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
}

.success-code-badge {
  background: rgba(30, 41, 59, 0.8);
  border: 1px dashed rgba(59, 130, 246, 0.5);
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 0.9rem;
  color: #93c5fd;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-family: monospace, var(--font-family);
  direction: ltr;
}

.success-desc {
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.6;
  max-width: 320px;
  margin: 4px 0 16px 0;
}

.success-done-btn {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
  transition: all 0.2s;
}

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