/* =========================================
   COMPONENTS — Recipe to Grocery List v2.0
   ========================================= */

/* ══════════════════════════════════════════
   LUCIDE SVG ICON SYSTEM
   ══════════════════════════════════════════ */

/* Base icon — Lucide replaces <i data-lucide> with <svg> */
.icon,
[data-lucide] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
}

/* All SVGs created by Lucide */
svg[xmlns] {
  display: block;
  flex-shrink: 0;
}

/* Navigation icons */
.app-nav__icon svg {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-spring);
}

.app-nav__link--active .app-nav__icon svg {
  transform: scale(1.1) translateY(-1px);
  stroke: var(--color-brand);
}

/* Header brand icon */
.app-header__logo svg {
  width: 26px;
  height: 26px;
  stroke: url(#brand-gradient);
  filter: drop-shadow(0 2px 4px rgb(16 185 129 / 0.3));
}

/* Button icons — scale with button size */
.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-lg svg {
  width: 18px;
  height: 18px;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* Theme toggle icon */
#theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Recipe card meta icons */
.recipe-card__meta-item svg {
  width: 12px;
  height: 12px;
  opacity: 0.75;
}

/* Recipe card action buttons */
.recipe-card__action-btn svg {
  width: 14px;
  height: 14px;
}

/* Badge icon */
.badge svg {
  width: 10px;
  height: 10px;
}

/* Form section title icons */
.form-section__title svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-brand);
}

/* Grocery category header icons */
.grocery-category__emoji svg,
.grocery-category__emoji i {
  width: 20px;
  height: 20px;
  stroke: var(--color-text-secondary);
}

/* Toast icons */
.toast__icon svg {
  width: 16px;
  height: 16px;
}

/* Empty state icon */
.empty-state__icon svg {
  width: 56px;
  height: 56px;
  stroke: var(--color-brand);
  opacity: 0.7;
  filter: drop-shadow(0 8px 16px rgb(16 185 129 / 0.2));
}

/* Meal plan recipe item dot */
.meal-plan__recipe-item>svg {
  width: 8px;
  height: 8px;
}

/* ══════════════════════════════════════════
   BUTTON
   ══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2-5) var(--space-5);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    color var(--transition-fast);
  min-height: var(--size-touch-comfortable);
  user-select: none;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / 0);
  transition: background var(--transition-fast);
  border-radius: inherit;
}

.btn:hover::after {
  background: rgb(255 255 255 / 0.08);
}

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

.btn:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

/* Primary */
.btn-primary {
  background: var(--gradient-brand);
  background-size: 200% 200%;
  color: #ffffff;
  border-color: transparent;
  box-shadow: var(--shadow-brand);
  font-weight: var(--weight-bold);
}

.btn-primary:hover {
  box-shadow: var(--shadow-brand-hover);
  transform: translateY(-1px) scale(1.01);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

/* Secondary */
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-brand);
  color: var(--color-text-brand);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
  border-color: var(--color-border);
}

/* Danger */
.btn-danger {
  background: transparent;
  color: var(--error-text);
  border-color: var(--error-border);
}

.btn-danger:hover {
  background: var(--error-bg);
  box-shadow: 0 2px 8px rgb(244 63 94 / 0.15);
}

/* Sizes */
.btn-sm {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  min-height: var(--size-touch-min);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-xl);
  letter-spacing: var(--tracking-wide);
}

/* Icon Button */
.btn-icon {
  padding: var(--space-2);
  min-height: var(--size-touch-min);
  min-width: var(--size-touch-min);
  border-radius: var(--radius-md);
}

/* Disabled */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
}

/* ══════════════════════════════════════════
   CARD
   ══════════════════════════════════════════ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition:
    box-shadow var(--transition-base),
    border-color var(--transition-base),
    transform var(--transition-base),
    background-color var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-border-brand);
}

.card--interactive:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.card--selected {
  border-color: var(--color-brand) !important;
  box-shadow:
    var(--shadow-md),
    0 0 0 3px rgb(16 185 129 / 0.15) !important;
  background: var(--gradient-brand-soft) !important;
}

.card__body {
  padding: var(--space-5) var(--space-5);
}

.card__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

/* ── Recipe Card ── */
/* ── Recipe Card ── */
.recipe-card {
  position: relative;
  display: flex;
  flex-direction: column;
  transition:
    box-shadow var(--transition-base),
    border-color var(--transition-base),
    transform var(--transition-base);
}

/* Colored top accent stripe */
.recipe-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-brand);
  opacity: 0;
  transition: opacity var(--transition-base);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.recipe-card:hover::before,
.card--selected.recipe-card::before {
  opacity: 1;
}

/* ── Header Bar: checkbox + badge dalam satu baris ── */
.recipe-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  gap: var(--space-2);
}

.recipe-card__select {
  position: static;
  /* tidak absolute lagi */
  display: flex;
  align-items: center;
}

.recipe-card__checkbox {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--color-brand);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0;
}

/* Badge di header */
.recipe-card__header .badge {
  margin: 0;
}

/* ── Body ── */
.recipe-card__body {
  padding: 0 var(--space-4) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2-5);
}

.recipe-card__title {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  color: var(--color-text);
  letter-spacing: var(--tracking-tight);
}

.recipe-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.recipe-card__meta-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-bg-subtle);
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-full);
  font-weight: var(--weight-medium);
  border: 1px solid var(--color-border);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.recipe-card:hover .recipe-card__meta-item {
  background: var(--color-surface);
  border-color: var(--color-border-brand);
}

.recipe-card__actions {
  display: flex;
  gap: var(--space-1);
  margin-block-start: auto;
  padding-block-start: var(--space-3);
  border-block-start: 1px solid var(--color-border);
}

.recipe-card__action-btn {
  font-size: var(--text-sm);
}

.recipe-card__action-btn--danger:hover {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

/* ══════════════════════════════════════════
   INPUT & FORM
   ══════════════════════════════════════════ */
.input {
  width: 100%;
  padding: var(--space-2-5) var(--space-4);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast);
  min-height: var(--size-touch-comfortable);
}

.input::placeholder {
  color: var(--color-text-muted);
}

.input:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
}

.input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgb(16 185 129 / 0.12);
  background: var(--color-surface);
}

.input:invalid,
.input[aria-invalid="true"] {
  border-color: var(--error-icon);
  box-shadow: 0 0 0 3px rgb(244 63 94 / 0.10);
}

textarea.input {
  min-height: 90px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M5 7L0.5 2.5h9z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-inline-end: var(--space-8);
}

/* ── Label ── */
.label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  margin-block-end: var(--space-1-5);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

/* ── Form Group ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--error-text);
  display: flex;
  gap: var(--space-1);
  align-items: center;
  font-weight: var(--weight-medium);
}

/* ══════════════════════════════════════════
   BADGE
   ══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-0-5) var(--space-2-5);
  border-radius: var(--radius-full);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
  border: 1px solid transparent;
}

.badge--brand {
  background: var(--emerald-100);
  color: var(--emerald-800);
  border-color: var(--emerald-200);
}

[data-theme="dark"] .badge--brand {
  background: rgb(6 78 59 / 0.35);
  color: var(--emerald-400);
  border-color: var(--emerald-800);
}

.badge--neutral {
  background: var(--neutral-100);
  color: var(--neutral-600);
  border-color: var(--neutral-200);
}

[data-theme="dark"] .badge--neutral {
  background: rgb(30 41 59 / 0.6);
  color: var(--neutral-400);
  border-color: var(--neutral-700);
}

.badge--amber {
  background: var(--amber-100);
  color: #92400e;
  border-color: var(--amber-400);
}

.badge--success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.badge--error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

/* ══════════════════════════════════════════
   TAG (Ingredient Category)
   ══════════════════════════════════════════ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border: 1px solid transparent;
  letter-spacing: var(--tracking-wide);
}

.tag--protein {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.tag--sayuran {
  background: var(--emerald-50);
  border-color: var(--emerald-200);
  color: var(--emerald-700);
}

.tag--karbohidrat {
  background: #fefce8;
  border-color: #fde047;
  color: #713f12;
}

.tag--dairy {
  background: var(--blue-50);
  border-color: var(--blue-100);
  color: #1e40af;
}

.tag--bumbu {
  background: #fdf4ff;
  border-color: #e9d5ff;
  color: #7e22ce;
}

.tag--buah {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}

.tag--lainnya {
  background: var(--neutral-100);
  border-color: var(--neutral-200);
  color: var(--neutral-600);
}

/* ══════════════════════════════════════════
   CUSTOM CHECKBOX
   ══════════════════════════════════════════ */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-2) 0;
  min-height: var(--size-touch-min);
  width: 100%;
}

.checkbox-wrapper input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-box {
  flex-shrink: 0;
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-spring);
}

.checkbox-wrapper:hover .checkbox-box {
  border-color: var(--color-brand);
  transform: scale(1.05);
}

.checkbox-wrapper input:checked+.checkbox-box {
  background: var(--gradient-brand);
  border-color: transparent;
  box-shadow: 0 2px 8px rgb(16 185 129 / 0.35);
  transform: scale(1.05);
  animation: checkmark-draw var(--duration-fast) var(--ease-spring);
}

.checkbox-wrapper input:checked+.checkbox-box::after {
  content: '';
  display: block;
  width: 0.55rem;
  height: 0.35rem;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px);
}

.checkbox-wrapper input:focus-visible+.checkbox-box {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.checkbox-label {
  font-size: var(--text-base);
  color: var(--color-text);
  transition: color var(--transition-fast);
  flex: 1;
}

.checkbox-wrapper input:checked~.checkbox-label {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* ══════════════════════════════════════════
   PROGRESS BAR
   ══════════════════════════════════════════ */
.progress {
  width: 100%;
  height: 6px;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.progress__bar {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: var(--radius-full);
  transition: width 700ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgb(255 255 255 / 0.35) 50%, transparent 100%);
  animation: shimmer 2.5s infinite;
}

/* ══════════════════════════════════════════
   SKELETON LOADING
   ══════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(105deg,
      var(--neutral-100) 25%,
      var(--neutral-200) 50%,
      var(--neutral-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-sweep 1.6s ease infinite;
  border-radius: var(--radius-md);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(105deg,
      var(--neutral-800) 25%,
      var(--neutral-700) 50%,
      var(--neutral-800) 75%);
  background-size: 200% 100%;
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-xl);
}

.skeleton-text-lg {
  height: 1.5rem;
  width: 55%;
  margin-block-end: var(--space-2);
}

.skeleton-text {
  height: 1rem;
  width: 100%;
  margin-block-end: var(--space-2);
}

.skeleton-text-sm {
  height: 0.75rem;
  width: 40%;
}

/* ══════════════════════════════════════════
   DIVIDER
   ══════════════════════════════════════════ */
.divider {
  border: none;
  border-block-start: 1px solid var(--color-border);
  margin-block: var(--space-4);
}

/* ══════════════════════════════════════════
   ACTION BAR — Scale Factor
   ══════════════════════════════════════════ */
.action-bar__scaling {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.action-bar__scale-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
  font-weight: var(--weight-medium);
}

.action-bar__scale-input {
  width: 72px;
  min-height: var(--size-touch-min);
  text-align: center;
  font-weight: var(--weight-semibold);
}

/* ══════════════════════════════════════════
   RECIPE PICKER (Meal Plan Modal)
   ══════════════════════════════════════════ */
.recipe-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 50vh;
  overflow-y: auto;
  padding: var(--space-1) 0;
}

.recipe-picker__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  text-align: left;
  width: 100%;
}

.recipe-picker__item:hover {
  background: var(--color-brand-subtle);
  border-color: var(--color-brand);
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
}

.recipe-picker__item:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.recipe-picker__item:active {
  transform: scale(0.98);
}

/* ══════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-4);
  gap: var(--space-4);
}

.empty-state__icon {
  font-size: 3.5rem;
  line-height: 1;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgb(0 0 0 / 0.08));
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text);
}

.empty-state__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  max-width: 280px;
  line-height: var(--leading-relaxed);
}