/* =============================================
   RecipeFinder — CSS
   Mobile-first responsive design
   ============================================= */

:root {
  --primary: #e85d04;
  --primary-dark: #d45203;
  --primary-light: #fff3e6;
  --accent: #dc2626;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.15);
  --transition: .2s ease;
  --max-width: 1200px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn--primary {
  background: var(--primary);
  color: var(--white);
}
.btn--primary:hover { background: var(--primary-dark); }
.btn--ghost {
  background: transparent;
  color: var(--gray-700);
}
.btn--ghost:hover { background: var(--gray-100); }
.btn--sm { padding: 4px 10px; font-size: .8rem; }
.btn--danger { background: var(--danger); color: var(--white); }
.btn--danger:hover { opacity: .9; }

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}
.header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}
.search-bar {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border-radius: 999px;
  padding: 6px 14px;
}
.search-bar input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: .875rem;
  width: 100%;
  outline: none;
}
.search-bar .material-icons-outlined { color: var(--gray-400); font-size: 20px; }
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-700);
  margin-left: auto;
}

/* Mobile nav */
.mobile-nav {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--gray-200);
}
.mobile-nav.open { display: flex; }

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #f97316 100%);
  color: var(--white);
  padding: 48px 16px;
  text-align: center;
}
.hero h1 { font-size: 2rem; font-weight: 700; margin-bottom: 12px; }
.hero p { font-size: 1.05rem; opacity: .9; max-width: 500px; margin: 0 auto; }

/* ===== CATEGORIES ===== */
.categories {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 60px;
  z-index: 90;
}
.categories__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.categories__inner::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip--active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.section-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
}

/* ===== RECIPE GRID ===== */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ===== RECIPE CARD ===== */
.recipe-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}
.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.recipe-card__img {
  height: 180px;
  background: var(--gray-200);
  overflow: hidden;
  position: relative;
}
.recipe-card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.recipe-card__img .placeholder-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-light), var(--gray-100));
}
.recipe-card__img .placeholder-img .material-icons-outlined {
  font-size: 48px;
  color: var(--primary);
  opacity: .5;
}
.recipe-card__category {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--white);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: capitalize;
}
.recipe-card__body {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.recipe-card__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-card__desc {
  font-size: .82rem;
  color: var(--gray-500);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.recipe-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
}
.recipe-card__author {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--gray-500);
}
.recipe-card__author img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.recipe-card__likes {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .8rem;
  color: var(--gray-500);
}
.recipe-card__likes .material-icons-outlined { font-size: 18px; }
.recipe-card__likes.liked { color: var(--accent); }
.recipe-card__likes.liked .material-icons-outlined { font-variation-settings: 'FILL' 1; }
.recipe-card__meta {
  display: flex;
  gap: 12px;
  font-size: .75rem;
  color: var(--gray-400);
  margin-bottom: 8px;
}
.recipe-card__meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}
.recipe-card__meta .material-icons-outlined { font-size: 14px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}
.modal-overlay.open {
  display: flex;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  margin: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--white);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}
.modal__close:hover { background: var(--gray-100); }
.modal__body { padding: 0; }

/* Recipe detail inside modal */
.detail-img {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
}
.detail-img-placeholder {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-light), var(--gray-100));
  border-radius: var(--radius) var(--radius) 0 0;
}
.detail-img-placeholder .material-icons-outlined {
  font-size: 64px;
  color: var(--primary);
  opacity: .4;
}
.detail-content { padding: 24px; }
.detail-content h2 { font-size: 1.5rem; margin-bottom: 8px; }
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: .85rem;
  color: var(--gray-500);
  margin-bottom: 16px;
}
.detail-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.detail-meta .material-icons-outlined { font-size: 18px; }
.detail-description {
  color: var(--gray-600);
  margin-bottom: 20px;
  font-size: .95rem;
}
.detail-section { margin-bottom: 20px; }
.detail-section h3 {
  font-size: 1.05rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-section ul {
  list-style: none;
  padding: 0;
}
.detail-section ul li {
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.detail-section ul li::before {
  content: '•';
  color: var(--primary);
  font-weight: bold;
  flex-shrink: 0;
}
.detail-section ol {
  padding-left: 20px;
}
.detail-section ol li {
  padding: 6px 0;
  font-size: .9rem;
}
.detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
  margin-top: 8px;
  flex-wrap: wrap;
}
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: 2px solid var(--gray-200);
  border-radius: 999px;
  background: var(--white);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.like-btn:hover { border-color: var(--accent); color: var(--accent); }
.like-btn.liked {
  background: #fef2f2;
  border-color: var(--accent);
  color: var(--accent);
}
.like-btn .material-icons-outlined { font-size: 20px; }

/* Detail author */
.detail-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.detail-author img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.detail-author-info { font-size: .85rem; }
.detail-author-info .name { font-weight: 600; color: var(--gray-800); }
.detail-author-info .date { color: var(--gray-400); font-size: .78rem; }

/* Comments section */
.comments-section { margin-top: 24px; }
.comments-section h3 { font-size: 1.05rem; margin-bottom: 12px; }
.comment-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.comment-form input {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .875rem;
  outline: none;
}
.comment-form input:focus { border-color: var(--primary); }
.comment-list { list-style: none; }
.comment-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.comment-item img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.comment-body { flex: 1; }
.comment-body .name { font-weight: 600; font-size: .82rem; }
.comment-body .text { font-size: .85rem; color: var(--gray-600); margin-top: 2px; }
.comment-body .time { font-size: .72rem; color: var(--gray-400); margin-top: 4px; }

/* ===== FORM MODAL ===== */
.modal--form { padding: 28px; max-width: 600px; }
.modal--form h2 { margin-bottom: 20px; font-size: 1.25rem; }
.recipe-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
}
.form-group label small { font-weight: 400; color: var(--gray-400); }
.form-group input,
.form-group textarea,
.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .875rem;
  outline: none;
  transition: border var(--transition);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
}
.form-group textarea { resize: vertical; }
.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--gray-400);
}
.empty-state p { margin-top: 12px; }

/* ===== LOADER ===== */
.loader {
  display: flex;
  justify-content: center;
  padding: 32px;
}
.loader.hidden { display: none; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  box-shadow: var(--shadow);
  animation: toastIn .3s ease;
  max-width: 340px;
}
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 24px 16px;
  font-size: .82rem;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

/* ===== DELETE BTN IN DETAIL ===== */
.detail-owner-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ===== RESPONSIVE ===== */

/* Tablet */
@media (max-width: 768px) {
  .nav { display: none; }
  .hamburger { display: block; }
  .search-bar { max-width: 220px; }
  .hero h1 { font-size: 1.6rem; }
  .hero { padding: 36px 16px; }
  .recipe-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; }
  .modal--form { padding: 20px; }
  .form-row { grid-template-columns: 1fr 1fr; }
}

/* Mobile */
@media (max-width: 480px) {
  .header__inner { gap: 8px; }
  .search-bar { max-width: none; flex: 1; }
  .logo span:last-child { display: none; }
  .hero h1 { font-size: 1.35rem; }
  .hero p { font-size: .9rem; }
  .recipe-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .recipe-card__img { height: 160px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-img { height: 200px; }
  .detail-content { padding: 16px; }
  .detail-content h2 { font-size: 1.2rem; }
  .toast-container { left: 16px; right: 16px; }
  .toast { max-width: 100%; }
  .btn__label { display: none; }
}
