/* =====================================================
   amane2figures Mini App — LIGHT / DARK THEME
   Font: Nunito (bubble-style rounded)
   Palette inspired by the sakura/anime aesthetic
   ===================================================== */

/* ---------- LIGHT THEME (default — Photo 1 palette) ---------- */
:root,
[data-theme="light"] {
  --bg-primary: #f8f4fc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-header: rgba(248, 244, 252, 0.94);
  --bg-input: #ffffff;
  --bg-meta: #f3ecfa;
  --bg-desc: #faf7fd;
  --bg-modal-card: #ffffff;
  --bg-overlay: rgba(20, 14, 30, 0.5);

  --text-main: #2b2238;
  --text-muted: #8a7d96;
  --text-on-accent: #ffffff;

  --accent: #b07ed8;
  --accent-dark: #9162b8;
  --accent-pink: #e882a8;
  --accent-gradient: linear-gradient(135deg, #c78fe6, #e882a8);

  --border-subtle: #eedff7;
  --border-input-focus: #b07ed8;

  --shadow-soft: 0 6px 20px rgba(155, 114, 207, 0.10);
  --shadow-hover: 0 10px 30px rgba(155, 114, 207, 0.18);
  --shadow-btn: 0 4px 16px rgba(176, 126, 216, 0.35);
  --shadow-float: 0 6px 24px rgba(176, 126, 216, 0.4);

  --sakura-from: #ffe3ec;
  --sakura-to: #f8a1bd;

  --cart-badge: #e04d7a;
  --success-bg: #eaf7ec;
  --success-text: #2e7d32;

  --radius-card: 18px;
  --radius-pill: 999px;
}

/* ---------- DARK THEME (Photo 2 palette — deeper purple/charcoal) ---------- */
[data-theme="dark"] {
  --bg-primary: #1a1424;
  --bg-secondary: #241d32;
  --bg-card: #2a2240;
  --bg-header: rgba(26, 20, 36, 0.94);
  --bg-input: #2a2240;
  --bg-meta: #322952;
  --bg-desc: #2a2240;
  --bg-modal-card: #241d32;
  --bg-overlay: rgba(8, 4, 16, 0.7);

  --text-main: #ede6f5;
  --text-muted: #9e93ad;
  --text-on-accent: #ffffff;

  --accent: #c48ef0;
  --accent-dark: #a86cd8;
  --accent-pink: #f06b98;
  --accent-gradient: linear-gradient(135deg, #c48ef0, #f06b98);

  --border-subtle: #3d3458;
  --border-input-focus: #c48ef0;

  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-btn: 0 4px 16px rgba(196, 142, 240, 0.3);
  --shadow-float: 0 6px 24px rgba(196, 142, 240, 0.35);

  --sakura-from: #5a3060;
  --sakura-to: #a0507a;

  --cart-badge: #f06b98;
  --success-bg: #1e3a28;
  --success-text: #6fcf7c;
}

/* ---------- RESET ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

*, body, button, input, textarea, select {
  font-family: 'Comfortaa', 'Balsamiq Sans', cursive, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 80px;
  overflow-x: hidden;
  user-select: none;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ---------- HEADER ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 16px 10px;
  transition: background 0.3s ease;
}

/* ---------- SAKURA PETALS ---------- */
.sakura-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.petal {
  position: absolute;
  background: radial-gradient(circle, var(--sakura-from), var(--sakura-to));
  border-radius: 12px 2px 12px 2px;
  opacity: 0.55;
  filter: drop-shadow(0 2px 6px rgba(248, 161, 189, 0.2));
  animation: fall linear infinite;
  will-change: transform, opacity;
}

@keyframes fall {
  0% {
    transform: translateY(-20px) rotate(0deg) scale(0.7);
    opacity: 0;
  }
  15% { opacity: 0.55; }
  100% {
    transform: translateY(105vh) rotate(360deg) scale(1);
    opacity: 0;
  }
}

/* ---------- BRAND ---------- */
.brand-row {
  text-align: center;
  margin-bottom: 8px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent-gradient);
  color: var(--text-on-accent);
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-btn);
}

/* Telegram Custom Emojis / Stickers */
.custom-tg-emoji {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  display: inline-block;
  object-fit: contain;
  pointer-events: none;
}

.custom-tg-sticker-big {
  width: 68px;
  height: 68px;
  vertical-align: middle;
  display: inline-block;
  object-fit: contain;
  margin-bottom: 8px;
  animation: floatSticker 3s ease-in-out infinite;
}

@keyframes floatSticker {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 600;
}

/* ---------- THEME TOGGLE ---------- */
.theme-toggle {
  position: absolute;
  top: 10px;
  right: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, background 0.3s ease;
  z-index: 55;
}

.theme-toggle:active {
  transform: scale(0.9);
}

/* ---------- SEARCH ---------- */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  margin-bottom: 10px;
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--border-input-focus);
  box-shadow: 0 0 0 3px rgba(176, 126, 216, 0.2);
}

.search-icon {
  font-size: 14px;
  margin-right: 8px;
  opacity: 0.7;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13.5px;
  color: var(--text-main);
  font-family: inherit;
}

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

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
}

/* ---------- FILTERS ---------- */
.filters-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.filters-row::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.filter-chip.active {
  background: var(--accent-gradient);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: var(--shadow-btn);
}

/* ---------- MAIN ---------- */
.app-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 12px 12px 20px;
}

/* ---------- LOADER ---------- */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
  gap: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---------- EMPTY STATE ---------- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  margin-top: 10px;
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }

.empty-state h3 {
  font-size: 17px;
  color: var(--text-main);
  margin-bottom: 6px;
  font-weight: 800;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 320px;
  margin: 0 auto;
}

/* ---------- PRODUCT GRID ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 600px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
}

.product-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

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

.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.1;
  background: var(--bg-meta);
  overflow: hidden;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.card-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(43, 34, 56, 0.8);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.3px;
}

.card-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
  min-height: 34px;
}

.card-price-row {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-price {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-dark);
}

.card-status {
  font-size: 9.5px;
  color: var(--success-text);
  background: var(--success-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* Add to cart button on card */
.card-cart-btn {
  width: 100%;
  border: none;
  background: var(--accent-gradient);
  color: var(--text-on-accent);
  font-size: 11.5px;
  font-weight: 700;
  padding: 7px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.2s ease;
  font-family: inherit;
}

.card-cart-btn:hover { opacity: 0.93; }

.card-cart-btn.in-cart {
  background: var(--success-bg);
  color: var(--success-text);
}

/* ---------- CART FLOATING BUTTON ---------- */
.cart-float {
  position: fixed;
  bottom: 22px;
  right: 18px;
  z-index: 90;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-float);
  cursor: pointer;
  transition: transform 0.2s ease;
  animation: popIn 0.3s ease;
}

.cart-float:active { transform: scale(0.92); }

.cart-float-icon { font-size: 22px; }

.cart-float-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--cart-badge);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
}

/* ---------- CART SHEET ---------- */
.cart-sheet {
  max-height: 80vh;
}

.cart-header {
  padding: 18px 16px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.cart-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.cart-body {
  padding: 12px 16px;
  overflow-y: auto;
  max-height: 45vh;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.cart-item:last-child { border-bottom: none; }

.cart-item-img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-meta);
  flex-shrink: 0;
}

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

.cart-item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-price {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-dark);
  margin-top: 2px;
}

.cart-item-remove {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s ease;
}

.cart-item-remove:hover { color: var(--accent-pink); }

.cart-empty-msg {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.cart-footer {
  padding: 14px 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.cart-total-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-dark);
}

.btn-cart-clear {
  width: 100%;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  padding: 9px 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.btn-cart-clear:hover {
  border-color: var(--accent-pink);
  color: var(--accent-pink);
}

/* ---------- MODAL (PRODUCT DETAIL) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  position: relative;
  background: var(--bg-modal-card);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-subtle);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .modal-close {
  background: rgba(36, 29, 50, 0.85);
  color: var(--text-main);
}

.modal-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-meta);
}

.modal-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.modal-orig-tag {
  position: absolute;
  bottom: 12px;
  left: 14px;
  background: rgba(43, 34, 56, 0.85);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.modal-body {
  padding: 16px 16px 24px;
}

.modal-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-dark);
}

.modal-avail-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--success-text);
  background: var(--success-bg);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 14px;
  line-height: 1.35;
}

.modal-meta-box {
  background: var(--bg-meta);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-main);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meta-icon { font-size: 14px; }

.modal-desc-wrap { margin-bottom: 18px; }

.desc-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.55;
  white-space: pre-wrap;
  background: var(--bg-desc);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
}

.modal-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg-modal-card);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- BUTTONS ---------- */
.btn-order-main {
  width: 100%;
  border: none;
  background: var(--accent-gradient);
  color: var(--text-on-accent);
  font-size: 14px;
  font-weight: 800;
  padding: 13px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, opacity 0.15s ease;
  font-family: inherit;
}

.btn-order-main:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.btn-add-cart {
  width: 100%;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-add-cart:active {
  transform: scale(0.97);
  background: var(--accent);
  color: var(--text-on-accent);
}

.btn-add-cart.in-cart {
  background: var(--success-bg);
  border-color: var(--success-text);
  color: var(--success-text);
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(43, 34, 56, 0.95);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: popIn 0.25s ease;
  max-width: 90vw;
  text-align: center;
}

[data-theme="dark"] .toast {
  background: rgba(196, 142, 240, 0.95);
  color: #1a1424;
}

@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, 15px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- SCROLLBAR (desktop) ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}
