*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #FFFFFF;
  --primary: #1A1A1A;
  --card: #F5F5F5;
  --secondary: #6B6B6B;
  --border: #E5E5E5;
  --radius: 16px;
  --sidebar-w: 220px;
  --header-h: 57px;
  --bnav-h: 64px;
  --bg-blur: rgba(255,255,255,0.95);
  --bnav-blur: rgba(255,255,255,0.96);
  --input-focus-bg: #fff;
  --active-bg: #1A1A1A;
  --active-color: #ffffff;
}

[data-theme="dark"] {
  --bg: #121212;
  --primary: #FFFFFF;
  --card: #1E1E1E;
  --secondary: #AAAAAA;
  --border: #2D2D2D;
  --bg-blur: rgba(18,18,18,0.95);
  --bnav-blur: rgba(18,18,18,0.96);
  --input-focus-bg: #1A1A1A;
  --active-bg: rgba(255,255,255,0.12);
  --active-color: #ffffff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--primary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

/* ── APP LAYOUT (sidebar + main, horizontal) ── */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── FOCUS STYLES (accessibility) ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
/* suppress focus ring on mouse click, keep for keyboard */
:focus:not(:focus-visible) { outline: none; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 16px;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 1.5px;
  font-family: system-ui, -apple-system, sans-serif;
  padding: 4px 12px 28px;
  color: var(--primary);
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--secondary);
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.menu-item:hover { background: var(--card); color: var(--primary); }
.menu-item.active { background: var(--active-bg); color: var(--active-color); }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ── MAIN WRAPPER ── */
.main-wrapper {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── PAGE ── */
.page {
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.page.active { display: flex; flex: 1; min-height: 0; }

/* ── STICKY HEADER ── */
.sticky-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--bg-blur);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.page-brand {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
}

.page-title {
  font-size: 18px;
  font-weight: 800;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--card);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--border); }
.icon-btn svg { width: 17px; height: 17px; }

/* ── SCROLLABLE AREA ── */
.page-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.page-scroll::-webkit-scrollbar { width: 4px; }
.page-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── CATEGORY TABS ── */
.category-scroll {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.category-scroll::-webkit-scrollbar { display: none; }

.cat-btn {
  border: none;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--card);
  color: var(--secondary);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.cat-btn.active { background: var(--active-bg); color: var(--active-color); }
.cat-btn:hover:not(.active) { background: var(--border); color: var(--primary); }

/* ── DEALS GRID (masonry) ── */
.deals-grid {
  columns: 2;
  column-gap: 12px;
  padding: 14px 14px 24px;
}

.deal-card {
  break-inside: avoid;
  margin-bottom: 12px;
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  display: block;
}
.deal-card:hover { transform: scale(0.97); box-shadow: 0 8px 28px rgba(0,0,0,0.14); }
.deal-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 18px; }

.deal-inner {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
}
.deal-card:nth-child(odd)  .deal-inner { min-height: 170px; }
.deal-card:nth-child(even) .deal-inner { min-height: 138px; }

.deal-badge {
  align-self: flex-start;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.badge-live { background: rgba(255,255,255,0.93); color: #D32F2F; }
.badge-last { background: rgba(255,255,255,0.93); color: #E65100; }

.deal-discount {
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.12);
  letter-spacing: -0.5px;
}

.deal-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.deal-brand {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  background: rgba(0,0,0,0.2);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deal-save {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: none;
  background: rgba(255,255,255,0.22);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}
.deal-save:hover { background: rgba(255,255,255,0.4); }
.deal-save svg { width: 14px; height: 14px; color: #fff; }

/* ── VITRIN ── */
.vitrin-feed {
  flex: 1;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.vitrin-feed::-webkit-scrollbar { display: none; }

.vitrin-card {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--header-h));
  scroll-snap-align: start;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vitrin-card:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

.vitrin-bg {
  position: absolute;
  inset: 0;
  transition: transform 0.3s;
}
.vitrin-card:hover .vitrin-bg { transform: scale(1.03); }

.vitrin-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.1) 50%, transparent 100%);
}

.play-btn {
  position: relative;
  z-index: 2;
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.18);
  border: 2px solid rgba(255,255,255,0.45);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.2s;
  pointer-events: none;
}
.vitrin-card:hover .play-btn { background: rgba(255,255,255,0.3); transform: scale(1.08); }
.play-btn svg { width: 26px; height: 26px; color: #fff; margin-left: 4px; }

.vitrin-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 24px 32px;
  z-index: 3;
  color: #fff;
  pointer-events: none;
}
.vitrin-brand { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.vitrin-desc  { font-size: 14px; opacity: 0.88; line-height: 1.4; }

/* ── SEARCH ── */
.search-outer { padding: 16px 20px 32px; }

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 14px;
  padding: 0 14px;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 28px;
}
.search-input-wrap:focus-within { border-color: var(--primary); background: var(--input-focus-bg); }

.search-ico { width: 17px; height: 17px; color: var(--secondary); flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 0;
  font-size: 15px;
  color: var(--primary);
  outline: none;
  /* reset browser search input styling */
  -webkit-appearance: none;
  appearance: none;
}
.search-input::-webkit-search-cancel-button { display: none; }
.search-input::placeholder { color: var(--secondary); }

.search-clear {
  border: none;
  background: none;
  color: var(--secondary);
  font-size: 13px;
  padding: 4px;
  display: none;
  line-height: 1;
  border-radius: 4px;
}
.search-clear:hover { color: var(--primary); }

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.chip {
  padding: 8px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.trend-cats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
}

.trend-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  border-radius: 14px;
  background: var(--card);
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  transition: transform 0.15s, box-shadow 0.15s;
}
.trend-cat:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); }

.trend-cat-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.hidden { display: none !important; }

/* ── SAVED ── */
.saved-tabs-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.saved-tab {
  flex: 1;
  padding: 14px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--secondary);
  position: relative;
  transition: color 0.15s;
}
.saved-tab.active { color: var(--primary); }
.saved-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  text-align: center;
}
.empty-icon  { font-size: 52px; margin-bottom: 18px; }
.empty-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-sub   { font-size: 14px; color: var(--secondary); line-height: 1.6; max-width: 280px; }

/* ── PROFILE ── */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-name  { font-size: 17px; font-weight: 700; }
.profile-email { font-size: 13px; color: var(--secondary); margin-top: 2px; }

.settings-list { overflow-y: auto; flex: 1; }

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.settings-item:hover { background: var(--card); }
.settings-item:focus-visible { outline-offset: -2px; border-radius: 0; }
.settings-item.danger { color: #D32F2F; }

.s-left {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: 500;
}
.s-left svg { width: 20px; height: 20px; flex-shrink: 0; }
.chevron { width: 16px; height: 16px; color: var(--secondary); }

/* ── DISCLAIMER ── */
.page-vitrin-active .disclaimer { display: none; }

/* ── ABOUT MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--bg);
  border-radius: 20px;
  padding: 28px 24px 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--primary);
}

.modal-body {
  font-size: 14px;
  color: var(--secondary);
  line-height: 1.65;
  margin-bottom: 24px;
}

.modal-close {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.modal-close:hover { opacity: 0.85; }

.disclaimer {
  font-size: 11px;
  color: var(--secondary);
  text-align: center;
  padding: 10px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  line-height: 1.5;
}

/* ── BOTTOM NAV (mobile) ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bnav-blur);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  border: none;
  background: transparent;
  color: var(--secondary);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
}
.bnav-item svg { width: 22px; height: 22px; }
.bnav-item.active { color: var(--primary); }

/* ── THEME TOGGLE FLOAT (mobile only) ── */
.theme-toggle-float {
  display: none;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  body { overflow: hidden; }

  .sidebar { display: none; }

  .bottom-nav { display: flex; }

  .theme-toggle-float {
    display: flex;
    position: fixed;
    bottom: calc(var(--bnav-h) + 14px);
    right: 14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card);
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transition: background 0.15s;
  }
  .theme-toggle-float:hover { background: var(--border); }
  .theme-toggle-float svg { width: 18px; height: 18px; color: var(--primary); }

  .main-wrapper { padding-bottom: 0; }
  .disclaimer { padding-bottom: calc(var(--bnav-h) + 10px); }

  .vitrin-card { height: calc(100vh - var(--header-h) - var(--bnav-h)); }

  .deals-grid { columns: 1; padding: 12px 12px 20px; column-gap: 0; }
  .deal-inner { padding: 12px; min-height: 140px; }
  .deal-card:nth-child(odd)  .deal-inner { min-height: 155px; }
  .deal-card:nth-child(even) .deal-inner { min-height: 128px; }
  .deal-discount { font-size: 26px; }

  .search-outer { padding: 12px 14px 24px; }
  .trend-cats { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}

@media (max-width: 480px) {
  .deal-discount { font-size: 22px; }
  .deal-brand { font-size: 10px; }
}
