/* ============================================================
   FANCY TREATS INVENTORY SYSTEM — Stylesheet
   Apple-inspired minimalism · Warm pastel palette
   ============================================================ */

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

/* ── Variables ── */
:root {
  --rose:       #c47d8e;
  --rose-light: #e8c9d0;
  --rose-pale:  #f5eaec;
  --gold:       #c9a96e;
  --gold-light: #e8d5b0;
  --cream:      #fdf6f0;
  --ivory:      #faf5ef;
  --charcoal:   #2d1f22;
  --dark:       #3d2b2f;
  --muted:      #8a6a70;
  --border:     rgba(196,125,142,0.14);
  --border-med: rgba(196,125,142,0.25);
  --shadow-sm:  0 1px 4px rgba(61,43,47,0.06);
  --shadow-md:  0 4px 20px rgba(61,43,47,0.08);
  --shadow-lg:  0 12px 40px rgba(61,43,47,0.1);
  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  18px;
  --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  --nav-h:      60px;
  --font:       'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--cream); color: var(--charcoal); line-height: 1.6; -webkit-font-smoothing: antialiased; }
img  { max-width: 100%; display: block; }
a    { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── Typography ── */
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 2vw, 1.5rem); font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 500; }
p  { color: var(--muted); font-size: 0.9rem; line-height: 1.7; }

/* ── Layout ── */
.container  { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.page-wrap  { padding-top: calc(var(--nav-h) + 32px); padding-bottom: 60px; min-height: 100vh; }

/* ── NAV ── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(253,246,240,0.88);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.nav-logo  { display: flex; align-items: center; gap: 10px; }
.nav-logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--rose), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white; letter-spacing: 0.02em;
}
.nav-logo-text { font-size: 0.95rem; font-weight: 600; color: var(--charcoal); letter-spacing: -0.01em; }
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-link {
  padding: 6px 14px; border-radius: 8px; font-size: 0.82rem; font-weight: 500;
  color: var(--muted); transition: var(--transition);
}
.nav-link:hover, .nav-link.active { background: var(--rose-pale); color: var(--rose); }
.nav-right { display: flex; align-items: center; gap: 10px; }
#user-pill {
  display: none; align-items: center; gap: 6px;
  padding: 5px 14px; background: var(--rose-pale);
  border-radius: 50px; font-size: 0.78rem; font-weight: 500; color: var(--rose);
}
#logout-btn {
  display: none; padding: 5px 14px; border-radius: 50px;
  font-size: 0.78rem; font-weight: 500; background: none;
  border: 1px solid var(--border-med); color: var(--muted); transition: var(--transition);
}
#logout-btn:hover { background: var(--rose-pale); color: var(--rose); border-color: var(--rose-light); }
.nav-login-btn {
  padding: 7px 18px; border-radius: 50px; font-size: 0.8rem; font-weight: 500;
  background: var(--charcoal); color: white; border: none; transition: var(--transition);
}
.nav-login-btn:hover { background: var(--dark); }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: white; border-radius: var(--radius); border: 1px solid var(--border);
  padding: 20px 22px; transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label { font-size: 0.72rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 1.9rem; font-weight: 600; color: var(--charcoal); letter-spacing: -0.02em; line-height: 1; }
.stat-sub   { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.stat-trend { font-size: 0.78rem; font-weight: 500; margin-top: 6px; }
.trend-up   { color: #5a8a5a; }
.trend-down { color: #c05050; }

/* ── Chart cards ── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.chart-card {
  background: white; border-radius: var(--radius); border: 1px solid var(--border);
  padding: 22px 24px;
}
.chart-card.full { grid-column: span 2; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.chart-title  { font-size: 0.88rem; font-weight: 600; color: var(--charcoal); }
.chart-sub    { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.chart-canvas { height: 220px; position: relative; }
.chart-canvas.tall { height: 280px; }

/* ── Stock bar indicator ── */
.stock-bar-wrap { margin-bottom: 12px; }
.stock-bar-label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin-bottom: 5px; }
.stock-bar-label strong { color: var(--charcoal); font-weight: 500; }
.stock-bar-track { height: 6px; background: var(--rose-pale); border-radius: 3px; overflow: hidden; }
.stock-bar-fill  { height: 100%; border-radius: 3px; transition: width 0.8s ease; }
.stock-bar-fill.ok      { background: linear-gradient(90deg, var(--gold-light), var(--gold)); }
.stock-bar-fill.warn    { background: linear-gradient(90deg, #f5d090, #e0a040); }
.stock-bar-fill.danger  { background: linear-gradient(90deg, #e8a0a8, var(--rose)); }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 500; letter-spacing: 0.05em; }
.badge-ok      { background: #e8f5e8; color: #3a6a3a; }
.badge-warning { background: #fdf0e0; color: #8a5a10; }
.badge-danger  { background: #fceaea; color: #8a2a2a; }
.badge-info    { background: var(--rose-pale); color: var(--rose); }
.badge-upcoming{ background: var(--gold-light); color: #5a4010; }
.badge-completed{background: #e8f5e8; color: #3a6a3a; }

/* ── Table ── */
.table-card { background: white; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; margin-bottom: 24px; }
.table-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.table-head h3 { font-size: 0.88rem; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 12px 20px; text-align: left; font-size: 0.72rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--ivory); }
tbody td { padding: 13px 20px; font-size: 0.85rem; border-bottom: 1px solid rgba(196,125,142,0.07); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--rose-pale); }

/* ── Forms & Inputs ── */
.form-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 32px; }
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border-med); border-radius: var(--radius-sm);
  font-size: 0.9rem; color: var(--charcoal); background: var(--ivory);
  transition: var(--transition); outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--rose); background: white;
  box-shadow: 0 0 0 3px rgba(196,125,142,0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-error { font-size: 0.78rem; color: #c05050; margin-top: 6px; }
.form-hint  { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 22px; border-radius: 50px;
  font-size: 0.82rem; font-weight: 500; border: none; transition: var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--charcoal); color: white; }
.btn-primary:hover { background: var(--dark); transform: translateY(-1px); }
.btn-rose { background: var(--rose); color: white; }
.btn-rose:hover { background: #b0607a; transform: translateY(-1px); }
.btn-ghost { background: none; border: 1px solid var(--border-med); color: var(--muted); }
.btn-ghost:hover { background: var(--rose-pale); color: var(--rose); border-color: var(--rose-light); }
.btn-sm { padding: 6px 14px; font-size: 0.78rem; }
.btn-danger { background: #fceaea; color: #8a2a2a; border: 1px solid #e8b0b0; }
.btn-danger:hover { background: #f5d0d0; }

/* ── Prediction table ── */
.pred-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.pred-card {
  background: var(--ivory); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}
.pred-item { font-size: 0.82rem; font-weight: 500; color: var(--charcoal); margin-bottom: 4px; }
.pred-val  { font-size: 1.3rem; font-weight: 600; color: var(--charcoal); letter-spacing: -0.01em; }
.pred-last { font-size: 0.75rem; color: var(--muted); margin-top: 3px; }
.pred-growth { font-size: 0.75rem; font-weight: 500; }
.pred-growth.up   { color: #5a8a5a; }
.pred-growth.down { color: #c05050; }

/* ── Chatbot FAB ── */
.chat-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 200;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--charcoal); color: white; border: none;
  font-size: 1.3rem; cursor: pointer; box-shadow: var(--shadow-lg);
  transition: var(--transition); display: flex; align-items: center; justify-content: center;
}
.chat-fab:hover { transform: scale(1.07); background: var(--dark); }

/* ── Chatbot panel ── */
.chat-panel {
  position: fixed; bottom: 92px; right: 28px; z-index: 200;
  width: 340px; max-height: 480px;
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateY(16px) scale(0.97);
  opacity: 0; pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}
.chat-panel.chat-open { transform: translateY(0) scale(1); opacity: 1; pointer-events: all; }
.chat-panel-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-panel-title { font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.chat-status-dot  { width: 7px; height: 7px; border-radius: 50%; background: #5aba6a; }
#chat-close { background: none; border: none; color: var(--muted); font-size: 1rem; padding: 2px; }
#chat-log {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-msg { display: flex; }
.chat-msg-user      { justify-content: flex-end; }
.chat-msg-assistant { justify-content: flex-start; }
.chat-bubble {
  max-width: 82%; padding: 9px 13px; border-radius: 14px;
  font-size: 0.82rem; line-height: 1.55;
}
.chat-msg-user      .chat-bubble { background: var(--charcoal); color: white; border-radius: 14px 14px 3px 14px; }
.chat-msg-assistant .chat-bubble { background: var(--rose-pale); color: var(--charcoal); border-radius: 14px 14px 14px 3px; }
.chat-typing-dots { display: flex; gap: 4px; align-items: center; padding: 10px 14px; }
.chat-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--rose);
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.chat-chip {
  padding: 4px 12px; background: var(--rose-pale); border: 1px solid var(--rose-light);
  border-radius: 50px; font-size: 0.72rem; font-weight: 500; color: var(--rose);
  cursor: pointer; transition: var(--transition);
}
.chat-chip:hover { background: var(--rose-light); }
.chat-input-row {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
}
#chat-input {
  flex: 1; border: 1px solid var(--border-med); border-radius: 50px;
  padding: 8px 14px; font-size: 0.82rem; outline: none;
  background: var(--ivory); transition: var(--transition);
}
#chat-input:focus { border-color: var(--rose); background: white; }
#chat-send {
  width: 34px; height: 34px; border-radius: 50%; background: var(--charcoal);
  color: white; border: none; font-size: 0.9rem; display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
#chat-send:hover { background: var(--rose); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 10px 20px; border-radius: 50px; font-size: 0.82rem; font-weight: 500;
  opacity: 0; transition: all 0.3s ease; z-index: 300; pointer-events: none;
  box-shadow: var(--shadow-md);
}
.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-info    { background: var(--charcoal); color: white; }
.toast-success { background: #2a6a2a; color: white; }
.toast-error   { background: #8a2a2a; color: white; }

/* ── Empty / loading states ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); font-size: 0.88rem; }
.spinner {
  width: 24px; height: 24px; border: 2px solid var(--border-med);
  border-top-color: var(--rose); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login / Auth page ── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--cream); padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 40px 36px;
  box-shadow: var(--shadow-md);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-mark {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--rose), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: white;
}
.auth-title { font-size: 1.3rem; font-weight: 600; text-align: center; margin-bottom: 6px; }
.auth-sub   { font-size: 0.82rem; text-align: center; color: var(--muted); margin-bottom: 28px; }
.auth-switch { text-align: center; font-size: 0.8rem; color: var(--muted); margin-top: 18px; }
.auth-switch a { color: var(--rose); font-weight: 500; }

/* ── Inventory page ── */
.inv-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 180px; padding: 9px 16px;
  border: 1px solid var(--border-med); border-radius: 50px;
  font-size: 0.85rem; outline: none; background: white; transition: var(--transition);
}
.search-input:focus { border-color: var(--rose); }
.filter-select {
  padding: 9px 14px; border: 1px solid var(--border-med); border-radius: 50px;
  font-size: 0.82rem; background: white; outline: none; color: var(--charcoal);
}

/* ── Inline edit ── */
.qty-input {
  width: 64px; padding: 4px 8px; border: 1px solid var(--border-med); border-radius: 6px;
  font-size: 0.85rem; text-align: center; outline: none;
}
.qty-input:focus { border-color: var(--rose); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .stat-grid  { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.full { grid-column: span 1; }
  .pred-grid  { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .nav-links { display: none; }
  .chat-panel { width: calc(100vw - 32px); right: 16px; bottom: 80px; }
  .form-row { grid-template-columns: 1fr; }
  .pred-grid { grid-template-columns: 1fr 1fr; }
}
