/* ============================================================
   SMART KITCHEN – App Layout (Sidebar + Content)
   ============================================================ */

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

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

:root {
  --sidebar-bg:      #0f1a14;
  --sidebar-hover:   rgba(26,158,92,0.12);
  --sidebar-active:  rgba(26,158,92,0.2);
  --sidebar-border:  rgba(255,255,255,0.06);
  --sidebar-text:    #9db8a8;
  --sidebar-text-active: #ffffff;
  --sidebar-width:   220px;

  --green:           #1a9e5c;
  --green-dark:      #14784a;
  --green-light:     #e8f5ee;
  --green-mid:       #c8edda;
  --green-accent:    #2dc870;
  --red:             #ef4444;
  --red-light:       #fef2f2;
  --orange:          #f59e0b;
  --orange-light:    #fffbeb;
  --blue:            #3b82f6;
  --blue-light:      #eff6ff;

  --bg:              #f2f8f5;
  --bg-white:        #ffffff;
  --border:          #e2ede8;
  --text-dark:       #1a1f1e;
  --text-mid:        #374240;
  --text-muted:      #6b7c78;

  --radius-sm:       8px;
  --radius-md:       14px;
  --radius-lg:       20px;
  --shadow-sm:       0 2px 10px rgba(0,0,0,0.05);
  --shadow-md:       0 6px 24px rgba(0,0,0,0.08);
  --shadow-lg:       0 12px 40px rgba(0,0,0,0.1);
  --trans:           all 0.25s cubic-bezier(0.4,0,0.2,1);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  overflow-x: hidden;
  line-height: 1.6;
}

/* ============================================================
   APP WRAPPER
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  border-right: 1px solid var(--sidebar-border);
  transition: transform 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.4rem 1.25rem 1.2rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
}

.sidebar-logo-icon { font-size: 1.4rem; }
.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.6rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.58rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--trans);
  margin-bottom: 0.1rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--green-accent);
  font-weight: 600;
}

.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 0.6rem;
  border-top: 1px solid var(--sidebar-border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
}

.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: #d1e8db;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: var(--trans);
}

.logout-btn:hover { color: var(--red); background: rgba(239,68,68,0.08); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* App Header */
.app-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.back-btn {
  width: 30px; height: 30px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: var(--trans);
}

.back-btn:hover { background: var(--green-light); color: var(--green); }

.app-header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-mid);
  font-size: 1.1rem;
  transition: var(--trans);
}

.notif-btn:hover { background: var(--green-light); }

.notif-badge {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Content body */
.content-body {
  padding: 2rem;
  flex: 1;
}

/* ============================================================
   PAGE TITLE
   ============================================================ */
.page-title { font-size: 1.7rem; font-weight: 800; color: var(--text-dark); letter-spacing:-0.5px; }
.page-subtitle { font-size: 0.9rem; color: var(--green); font-weight: 500; margin-top: 0.2rem; }
.page-desc { font-size: 0.88rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--trans);
}

.card:hover { box-shadow: var(--shadow-sm); }

/* Stat cards */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--trans);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-label-sm { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.3rem; }
.stat-val { font-size: 2rem; font-weight: 800; color: var(--text-dark); line-height: 1; letter-spacing:-1px; }
.stat-icon-circle {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon-green { background: var(--green-light); }
.stat-icon-orange { background: var(--orange-light); }
.stat-icon-red { background: var(--red-light); }
.stat-icon-blue { background: var(--blue-light); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-urgent   { background: var(--red-light);    color: var(--red); }
.badge-critical { background: var(--red-light);    color: var(--red); }
.badge-warning  { background: var(--orange-light); color: var(--orange); }
.badge-green    { background: var(--green-light);  color: var(--green); }
.badge-blue     { background: var(--blue-light);   color: var(--blue); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--trans);
  text-decoration: none;
}

.btn-green {
  background: var(--green);
  color: #fff;
  box-shadow: 0 3px 12px rgba(26,158,92,0.3);
}
.btn-green:hover { background: var(--green-dark); transform: translateY(-1px); box-shadow: 0 5px 18px rgba(26,158,92,0.4); }

.btn-outline-green {
  background: transparent;
  color: var(--green);
  border: 1.5px solid var(--green);
}
.btn-outline-green:hover { background: var(--green-light); }

.btn-red {
  background: var(--red);
  color: #fff;
  width: 100%;
  justify-content: center;
}
.btn-red:hover { background: #dc2626; transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--text-mid);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

/* ============================================================
   INPUTS / FORMS
   ============================================================ */
.form-group { margin-bottom: 1.1rem; }
.form-label { font-size: 0.83rem; font-weight: 600; color: var(--text-mid); margin-bottom: 0.4rem; display: block; }

.input, .select {
  width: 100%;
  padding: 0.62rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text-dark);
  background: var(--bg-white);
  transition: var(--trans);
  outline: none;
}

.input:focus, .select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,158,92,0.1);
}

.search-bar {
  position: relative;
}

.search-bar .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar .input { padding-left: 2.4rem; }

/* ============================================================
   LIST ITEMS (Run-out / Expiry etc)
   ============================================================ */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-bottom: 0.5rem;
  transition: var(--trans);
  gap: 1rem;
}

.list-item:hover { background: var(--green-light); }

.list-item-name { font-size: 0.9rem; font-weight: 600; color: var(--text-dark); }
.list-item-sub  { font-size: 0.77rem; color: var(--text-muted); margin-top: 0.1rem; }

.list-item-right { text-align: right; flex-shrink: 0; }
.list-item-days { font-size: 0.95rem; font-weight: 800; color: var(--red); line-height: 1; }
.list-item-days.warning { color: var(--orange); }
.list-item-meta { font-size: 0.72rem; color: var(--text-muted); }

/* ============================================================
   SECTION DIVIDER
   ============================================================ */
.section-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   REMINDER BANNER
   ============================================================ */
.reminder-banner {
  background: var(--green-light);
  border: 1px solid var(--green-mid);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.1rem;
  font-size: 0.86rem;
  color: var(--green-dark);
  font-weight: 500;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slide-in 0.4s ease;
}

@keyframes slide-in {
  from { opacity:0; transform: translateY(-8px); }
  to   { opacity:1; transform: translateY(0); }
}

/* ============================================================
   TWO COLUMN GRID
   ============================================================ */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.col-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
}

.col-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* ============================================================
   PANTRY GRID
   ============================================================ */
.pantry-grid {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 1rem;
}

.pantry-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  transition: var(--trans);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.pantry-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.pantry-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.pantry-item-name { font-size: 0.95rem; font-weight: 700; color: var(--text-dark); }
.pantry-item-cat  { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }

.pantry-details { display: flex; flex-direction: column; gap: 0.35rem; }

.pantry-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}
.pantry-detail-label { color: var(--text-muted); }
.pantry-detail-val   { font-weight: 600; color: var(--text-dark); }

/* ============================================================
   AI INSIGHT ROWS
   ============================================================ */
.insight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-bottom: 0.5rem;
  gap: 1rem;
  transition: var(--trans);
  cursor: pointer;
}
.insight-row:hover { background: var(--green-light); }

.insight-left { flex:1; }
.insight-name { font-size: 0.9rem; font-weight: 700; color: var(--text-dark); display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.insight-sub  { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.2rem; }

.insight-right { text-align: right; flex-shrink: 0; }
.insight-days  { font-size: 1.05rem; font-weight: 800; color: var(--red); line-height: 1; }
.insight-days.warn { color: var(--orange); }
.insight-empty { font-size: 0.7rem; color: var(--text-muted); }

.insight-bar {
  width: 4px; height: 30px;
  background: var(--red);
  border-radius: 2px;
  flex-shrink: 0;
  margin-left: 0.75rem;
}
.insight-bar.warn { background: var(--orange); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--trans);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 94%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: var(--trans);
  box-shadow: var(--shadow-lg);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--text-dark); }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--trans);
  color: var(--text-muted);
}
.modal-close:hover { background: var(--red-light); color: var(--red); }

.modal-footer {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--text-dark);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 0.87rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  min-width: 260px;
  max-width: 360px;
}

.toast.toast-success { background: var(--green-dark); }
.toast.toast-error   { background: var(--red); }
.toast.toast-warning { background: var(--orange); }

@keyframes toast-in {
  from { opacity:0; transform: translateX(30px) scale(0.95); }
  to   { opacity:1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
  to { opacity:0; transform: translateX(30px) scale(0.9); }
}

/* ============================================================
   SCROLL ANIMATION
   ============================================================ */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  animation: fade-in 0.45s ease forwards;
}
@keyframes fade-in {
  to { opacity: 1; transform: translateY(0); }
}

/* Stagger */
.fade-in:nth-child(1)  { animation-delay: 0.05s; }
.fade-in:nth-child(2)  { animation-delay: 0.10s; }
.fade-in:nth-child(3)  { animation-delay: 0.15s; }
.fade-in:nth-child(4)  { animation-delay: 0.20s; }
.fade-in:nth-child(5)  { animation-delay: 0.25s; }
.fade-in:nth-child(6)  { animation-delay: 0.30s; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-title { font-size: 1rem; font-weight: 700; color: var(--text-mid); margin-bottom: 0.4rem; }
.empty-desc  { font-size: 0.86rem; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-bar .search-bar { flex: 1; min-width: 200px; }

.filter-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-icon { color: var(--text-muted); font-size: 0.9rem; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar-wrap {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--green);
  transition: width 1s ease;
}
.progress-bar-fill.red    { background: var(--red); }
.progress-bar-fill.orange { background: var(--orange); }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}
.toggle:hover .toggle-slider {
  background: #b9c3d1;
}
.toggle input:checked + .toggle-slider {
  background: var(--green);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.toggle input:checked:hover + .toggle-slider {
  background: var(--green-dark);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}
.toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ============================================================
   CHIP / TAG
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg-white);
  color: var(--text-mid);
  transition: var(--trans);
}
.chip:hover, .chip.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width:1100px){
  .pantry-grid    { grid-template-columns: repeat(3,1fr); }
  .stats-row      { grid-template-columns: repeat(2,1fr); }
}
@media (max-width:860px){
  .two-col-grid   { grid-template-columns: 1fr; }
  .pantry-grid    { grid-template-columns: repeat(2,1fr); }
}
@media (max-width:640px){
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .content-body { padding: 1.25rem; }
  .pantry-grid { grid-template-columns: 1fr; }
  .stats-row   { grid-template-columns: 1fr 1fr; }
}
