/* ==========================================================================
   HÔM NAY ĂN GÌ - UI COMPONENTS STYLESHEET
   Bao gồm: Chips, Cards, Badges, Modals, Sliders, Toast và Micro-interactions
   ========================================================================== */

/* ==========================================================================
   1. BUTTONS & INPUTS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  line-height: 1.2;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
}

.btn-secondary:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

.btn-outline {
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  background: transparent;
}

.btn-outline:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.95rem 1.6rem;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.input-control, .select-control {
  width: 100%;
  padding: 0.7rem 1rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-main);
  transition: all var(--transition-fast);
}

.input-control:focus, .select-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* ==========================================================================
   2. PANTRY SIDEBAR & CONTROLS
   ========================================================================== */
.pantry-sidebar-card, .pantry-main-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.input-with-button {
  display: flex;
  gap: 0.5rem;
}

.input-with-button input {
  flex: 1;
}

/* Category Pills */
.category-pills-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  scrollbar-width: thin;
}

.cat-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  background-color: var(--color-border-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.cat-pill:hover {
  background-color: var(--color-surface-hover);
  color: var(--color-text-main);
}

.cat-pill.active {
  background-color: var(--color-primary);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3);
}

/* Quick Actions Bar */
.pantry-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

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

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

.toolbar-buttons {
  display: flex;
  gap: 0.5rem;
}

/* ==========================================================================
   3. INGREDIENT CHIPS (INTERACTIVE GRID)
   ========================================================================== */
.ingredients-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.ingredient-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  background-color: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.ingredient-chip:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.ingredient-chip.selected {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.18);
}

[data-theme="dark"] .ingredient-chip.selected {
  color: #34D399;
}

.chip-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.chip-label {
  font-size: 0.88rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-check {
  display: none;
  width: 18px;
  height: 18px;
  background-color: var(--color-primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ingredient-chip.selected .chip-check {
  display: flex;
}

.chip-delete {
  color: #EF4444;
  font-size: 1.2rem;
  padding: 0 4px;
  line-height: 1;
}

.chip-delete:hover {
  transform: scale(1.2);
}

/* Empty filter */
.empty-filter-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   4. FLOATING MOBILE ACTION BAR
   ========================================================================== */
.mobile-floating-bar {
  display: none;
  position: fixed;
  bottom: 4.8rem;
  left: 1rem;
  right: 1rem;
  z-index: 55;
  background: linear-gradient(135deg, #0F172A, #1E293B);
  color: #FFFFFF;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-full);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  align-items: center;
  justify-content: space-between;
  animation: slideUp 200ms ease;
}

.mobile-floating-bar.visible {
  display: flex;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.floating-count-badge {
  background-color: var(--color-primary);
  color: white;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
}

/* ==========================================================================
   5. MENU OPTIONS (3 AI RECOMMENDATIONS)
   ========================================================================== */
.menu-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
}

.status-badge.level-0 {
  background-color: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.status-badge.level-1 {
  background-color: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

.status-badge.level-2 {
  background-color: #F1F5F9;
  color: #334155;
  border: 1px solid #CBD5E1;
}

[data-theme="dark"] .status-badge.level-0 { background: rgba(16, 185, 129, 0.15); color: #34D399; }
[data-theme="dark"] .status-badge.level-1 { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
[data-theme="dark"] .status-badge.level-2 { background: rgba(148, 163, 184, 0.15); color: #94A3B8; }

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: currentColor;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.menu-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.menu-card {
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
  position: relative;
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-color, var(--color-primary));
}

.card-header {
  padding: 1.25rem 1.25rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
}

.card-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 0.5rem;
}

.card-tagline {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  margin-bottom: 0.65rem;
}

.card-nutrition-pill {
  font-size: 0.78rem;
  font-weight: 600;
  background-color: var(--color-border-subtle);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--color-text-main);
  display: inline-block;
}

.meals-list {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.meal-item {
  background-color: var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  border-left: 3px solid transparent;
}

.meal-item.morning { border-left-color: #F59E0B; }
.meal-item.noon { border-left-color: #10B981; }
.meal-item.night { border-left-color: #3B82F6; }

.meal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.meal-time-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.meal-duration {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.meal-name {
  font-size: 0.96rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.meal-ingredients, .meal-nutrition {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.card-footer {
  padding: 1.1rem 1.25rem;
  border-top: 1px solid var(--color-border);
  background-color: var(--color-surface);
}

/* AI Loading State */
.ai-loading-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.spinner-pulse {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  box-shadow: 0 0 25px var(--color-primary-glow);
  margin-bottom: 1.5rem;
  animation: scalePulse 1.2s infinite ease-in-out;
}

@keyframes scalePulse {
  0%, 100% { transform: scale(0.85); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ==========================================================================
   6. PLANNER & CHECKLIST
   ========================================================================== */
.planner-empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  background-color: var(--color-surface);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

.plan-header-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.08));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.plan-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.plan-main-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
}

.plan-main-sub {
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.plan-date-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
}

.progress-container {
  margin-top: 1.25rem;
}

.progress-track {
  height: 8px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10B981, #059669);
  border-radius: var(--radius-full);
  transition: width 300ms ease;
}

.progress-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Checklist items */
.planner-checklist-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.planner-item {
  background-color: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  transition: all var(--transition-fast);
}

.planner-item.done {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary);
  opacity: 0.85;
}

.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 1rem;
  user-select: none;
}

.custom-checkbox input {
  display: none;
}

.checkmark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.custom-checkbox input:checked ~ .checkmark {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.custom-checkbox input:checked ~ .checkmark::after {
  content: '✓';
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
}

.item-body {
  padding-left: 2.15rem;
  font-size: 0.86rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   7. MODAL (SETTINGS)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScale 200ms ease;
}

@keyframes modalScale {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--color-border);
  background-color: var(--color-border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ==========================================================================
   8. TOAST NOTIFICATION
   ========================================================================== */
.app-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  background-color: #0F172A;
  color: #FFFFFF;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  display: none;
  align-items: center;
  gap: 0.5rem;
  animation: toastFade 200ms ease;
}

.app-toast.show {
  display: flex;
}

@keyframes toastFade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .app-toast {
    bottom: 5.5rem;
    left: 1rem;
    right: 1rem;
    text-align: center;
    justify-content: center;
  }
}
