/* =========================================================
   TomodachiAI — style.css
   Mobile-first. Same file drives phone, tablet, desktop.
   Breakpoints:  768px = tablet   |   1024px = desktop
   ========================================================= */

:root{
  --bg:            #0a0b14;
  --surface:       #14151f;
  --surface-2:     #1a1c29;
  --border:        #262838;
  --text:          #f2f1f7;
  --muted:         #8b8996;
  --accent-1:      #7b5cfa;   /* violet */
  --accent-2:      #4c8dff;   /* blue */
  --accent-grad:   linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --good:          #34d399;
  --bad:           #f87171;

  --radius-sm:     10px;
  --radius-md:     16px;
  --radius-lg:     22px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --header-h: 56px;
  --bottomnav-h: 64px;
}

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

html{ -webkit-text-size-adjust: 100%; }

body{
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
}

a{ color: inherit; text-decoration: none; }
button{ font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
ul{ list-style: none; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Buttons ---------- */
.btn{
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 48px; /* comfortable tap target */
}
.btn-primary{
  background: var(--accent-grad);
  color: #fff;
}
.btn-primary:active{ transform: scale(0.97); }
.btn-block{ width: 100%; }

/* ---------- Header ---------- */
.site-header{
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  padding-top: env(safe-area-inset-top);
  background: rgba(10,11,20,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.header-inner{
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}
.icon-btn{
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  position: relative;
  font-size: 1.1rem;
}
.icon-btn:active{ background: var(--surface-2); }
.icon-btn .dot{
  position: absolute; top: 6px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-1);
}
.hamburger, .hamburger::before, .hamburger::after{
  content:""; display:block;
  width: 20px; height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.hamburger{ position: relative; }
.hamburger::before{ position:absolute; top:-6px; }
.hamburger::after{ position:absolute; top:6px; }

.logo{ display: flex; align-items: center; gap: var(--space-2); }
.logo-mark{
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem;
}
.logo-text{ font-weight: 700; font-size: 1rem; }
.logo-text em{ font-style: normal; color: var(--accent-2); }

.header-actions{ display: flex; align-items: center; gap: var(--space-2); }
.avatar{
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* ---------- Side nav (mobile: slide-in drawer) ---------- */
.side-nav{
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 78%;
  max-width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: calc(var(--header-h) + var(--space-5)) var(--space-4) var(--space-5);
  transform: translateX(-100%);
  transition: transform 0.28s ease;
  z-index: 200;
  overflow-y: auto;
}
.side-nav.open{ transform: translateX(0); }
.nav-overlay{
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s ease;
  z-index: 150;
}
.nav-overlay.show{ opacity: 1; pointer-events: auto; }

.nav-list li + li{ margin-top: var(--space-1); }
.nav-link{
  display: flex; align-items: center; gap: var(--space-3);
  padding: 12px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--muted);
}
.nav-link.active{
  background: var(--surface-2);
  color: var(--text);
}
.badge{
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--accent-grad);
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: auto;
}

.premium-card{
  margin-top: var(--space-6);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.premium-title{ font-weight: 700; margin-bottom: var(--space-1); }
.premium-sub{ font-size: 0.8rem; color: var(--muted); margin-bottom: var(--space-3); }

/* ---------- Main / Greeting ---------- */
.main{ padding: var(--space-4); }

.greeting{ display: none; } /* shown on desktop only */

/* ---------- Hero ---------- */
.hero{
  position: relative;
  padding: var(--space-6) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  text-align: center;
  margin-bottom: var(--space-5);
}
.hero-glow{
  position: absolute;
  top: -40%; right: -20%;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(123,92,250,0.35), transparent 70%);
  filter: blur(10px);
}
.hero-title{
  position: relative;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: var(--space-3);
}
.accent{
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub{
  position: relative;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-5);
}
.search-bar{
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 4px 4px 14px;
  margin-bottom: var(--space-3);
}
.search-icon{ margin-right: var(--space-2); color: var(--muted); }
.search-bar input{
  flex: 1;
  background: none; border: none; outline: none;
  color: var(--text);
  font-size: 0.95rem;
  padding: 12px 0;
}
.search-submit{ padding: 10px 18px; min-height: 40px; }
.ai-suggest-btn{ width: 100%; }

/* ---------- Quick actions ---------- */
.quick-actions{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.quick-card{
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
}
.quick-card:active{ background: var(--surface-2); }
.quick-icon{ font-size: 1.3rem; }
.badge-inline{ position: absolute; top: var(--space-3); right: var(--space-3); margin-left: 0; }

/* ---------- Sections ---------- */
.section{ margin-bottom: var(--space-6); }
.section-head{
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-3);
}
.section-head h2{ font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: var(--space-2); }
.view-all{ font-size: 0.8rem; color: var(--accent-2); font-weight: 600; }

/* ---------- Product cards ---------- */
.card-row{
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-2);
  margin: 0 calc(var(--space-4) * -1);
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}
.card-row::-webkit-scrollbar{ display: none; }

.product-card{
  position: relative;
  flex: 0 0 62%;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.fav-btn{
  position: absolute;
  top: var(--space-3); right: var(--space-3);
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(20,21,31,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.product-img{
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
}
/* placeholder gradients standing in for product photography */
.ph-phone{ background: linear-gradient(160deg, #3a2f66, #17182a); }
.ph-laptop{ background: linear-gradient(160deg, #1f3a63, #17182a); }
.ph-headphones{ background: linear-gradient(160deg, #2a2a2a, #17182a); }

.product-name{ font-size: 0.9rem; font-weight: 600; margin-bottom: var(--space-1); }
.product-rating{ font-size: 0.78rem; color: #f5c451; margin-bottom: var(--space-1); }
.product-rating span{ color: var(--muted); }
.product-price{ font-size: 0.9rem; font-weight: 700; }
.old-price{ font-weight: 400; color: var(--muted); text-decoration: line-through; margin-left: 4px; font-size: 0.78rem; }
.off{ color: var(--good); font-size: 0.72rem; font-weight: 600; margin-left: 4px; }

/* ---------- Panels (AI summary, tracker, compare) ---------- */
.panel{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.panel-note{ color: var(--muted); font-size: 0.82rem; margin-bottom: var(--space-4); }

.review-row{
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}
.review-row:first-of-type{ border-top: none; }
.review-emoji{ font-size: 1.2rem; }
.review-title{ font-weight: 600; font-size: 0.88rem; margin-bottom: 2px; }
.review-sub{ color: var(--muted); font-size: 0.78rem; }
.review-pct{ margin-left: auto; font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.good-pct{ color: var(--good); }
.bad-pct{ color: var(--bad); }

.price-chart{
  position: relative;
  height: 90px;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(123,92,250,0.15), transparent),
    var(--surface-2);
  margin-bottom: var(--space-4);
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding: var(--space-2);
}
.price-tag{
  background: var(--accent-grad);
  font-size: 0.72rem; font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
}

.compare-panel{ text-align: center; }
.compare-panel h2{ font-size: 1.05rem; margin-bottom: var(--space-1); text-align: left; }
.compare-panel .panel-note{ text-align: left; }
.compare-visual{
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.compare-box{
  flex: 1; height: 90px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.vs-badge{
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800;
  flex-shrink: 0;
}

/* ---------- Chips ---------- */
.chip-row{
  display: flex; gap: var(--space-2);
  overflow-x: auto;
  margin: 0 calc(var(--space-4) * -1);
  padding: 0 var(--space-4) var(--space-2);
}
.chip-row::-webkit-scrollbar{ display: none; }
.chip{
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Bottom nav (mobile only) ---------- */
.bottom-nav{
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(10,11,20,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
.bn-link{
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--muted);
}
.bn-link span{ font-size: 1.1rem; }
.bn-link.active{ color: var(--accent-2); }

/* =========================================================
   TABLET — 768px and up
   ========================================================= */
@media (min-width: 768px){
  .main{ padding: var(--space-6); }
  .hero-title{ font-size: 2.1rem; }
  .quick-actions{ grid-template-columns: repeat(4, 1fr); }
  .product-card{ flex: 0 0 40%; }
  .search-bar{ max-width: 520px; margin-left: auto; margin-right: auto; }
  .ai-suggest-btn{ max-width: 280px; margin: 0 auto; }
}

/* =========================================================
   DESKTOP — 1024px and up
   Sidebar becomes permanent, bottom nav disappears,
   header/hamburger adapt, content becomes a 3-column grid.
   ========================================================= */
@media (min-width: 1024px){
  body{
    padding-left: 260px;
    padding-bottom: 0;
  }
  .menu-toggle{ display: none; }
  .bottom-nav{ display: none; }

  .site-header{ left: 260px; }
  .header-inner{ padding: 0 var(--space-6); }

  .side-nav{
    transform: none;
    position: fixed;
    width: 260px;
    border-right: 1px solid var(--border);
  }
  .nav-overlay{ display: none; }

  .greeting{
    display: block;
    font-weight: 700;
    margin-bottom: var(--space-5);
  }
  .greeting span{ display: block; font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

  .main{
    padding: var(--space-6) var(--space-6) var(--space-6) var(--space-6);
    max-width: 1400px;
  }

  .hero{ text-align: left; padding: var(--space-6); }
  .hero-title{ font-size: 2.6rem; }
  .hero-sub{ max-width: 480px; }
  .search-bar{ max-width: 560px; margin: 0 0 var(--space-3); }
  .ai-suggest-btn{ width: auto; margin: 0; }

  .quick-actions{ grid-template-columns: repeat(4, 1fr); max-width: 800px; }

  .card-row{
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    overflow: visible;
    margin: 0; padding: 0;
  }
  .product-card{ flex: none; }

  /* two-column layout: main content + right rail */
  .content-grid{
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: var(--space-5);
  }
}
