/* Global layout */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background-color: #7bc29a;
  color: #133136;
}

h1,
h2,
h3 {
  color: #0b262b;
  margin-top: 0;
}

/* Navbar */
.navbar {
  background-color: #ffffff;
  border-bottom: 1px solid #d4e5e7;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.navbar-spacer {
  height: 64px;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  flex: 1;
  min-width: 0;
  position: relative;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  flex-shrink: 0;
}

.navbar-logo {
  height: 38px;
  width: auto;
  display: block;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.navbar-links a {
  text-decoration: none;
  color: #134b5f;
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
}

.navbar-links a:hover {
  text-decoration: underline;
}

.navbar-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: none;
  background: #e8f0f2;
  border-radius: 8px;
  cursor: pointer;
  color: #134b5f;
}

.navbar-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.navbar-hamburger:hover {
  background: #d4e5e7;
}

.navbar-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #fff;
  border-bottom: 1px solid #d4e5e7;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  padding: 12px 0;
  flex-direction: column;
  z-index: 99;
}

.navbar-dropdown a {
  display: block;
  padding: 12px 24px;
  text-decoration: none;
  color: #134b5f;
  font-weight: 500;
  font-size: 15px;
}

.navbar-dropdown a:hover {
  background: #e8f0f2;
  text-decoration: none;
}

.navbar-dropdown-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 8px 24px;
}

.navbar-dropdown-form {
  margin: 0;
  padding: 0;
}

.navbar-dropdown-btn {
  display: block;
  width: 100%;
  padding: 12px 24px;
  border: none;
  background: none;
  text-align: left;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: #134b5f;
  cursor: pointer;
}

.navbar-dropdown-btn:hover {
  background: #e8f0f2;
}

.navbar-collapsed .navbar-hamburger {
  display: flex;
}

.navbar-collapsed .navbar-links {
  display: none;
}

.navbar-collapsed .navbar-profile-link,
.navbar-collapsed .navbar-logout {
  display: none;
}

.navbar-collapsed .navbar-dropdown.navbar-dropdown-open {
  display: flex;
}

.favorite-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #a0b8be;
  display: flex;
  align-items: center;
  justify-content: center;
}

.favorite-btn:not(.favorited):hover {
  color: #8fa8b0;
}

.favorite-btn.favorited,
.favorite-btn.favorited:hover {
  color: #d4a800;
}

.favorite-star {
  width: 24px;
  height: 24px;
}

@media (max-width: 640px) {
  .navbar-hamburger {
    display: flex;
  }
  .navbar-links {
    display: none;
  }
  .navbar-dropdown.navbar-dropdown-open {
    display: flex;
  }
}

.navbar-profile-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e8f0f2;
  color: #134b5f;
  transition: background 0.15s;
}

.navbar-profile-link:hover {
  background: #d4e5e7;
}

.navbar-profile-icon {
  width: 20px;
  height: 20px;
}

.navbar-logout button {
  border: none;
  background: #36b59d;
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.navbar-logout button:hover {
  background: #2aa18b;
}

.lang-switch {
  display: flex;
  align-items: center;
}

.lang-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #d4e5e7;
  border-radius: 8px;
  background: #fff;
  font-size: 20px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.lang-toggle:hover {
  border-color: #36b59d;
  background: #e8f0f2;
}

.auth-lang-switch {
  margin-bottom: 16px;
  font-size: 14px;
}

.auth-lang-switch .lang-switch a {
  color: #134b5f;
}

/* Hide logo on narrow viewports immediately (matches 640px collapse) to prevent flicker before JS runs */
@media (max-width: 640px) {
  .navbar .navbar-logo-link {
    display: none;
  }
}

@media (max-width: 600px) {
  .navbar {
    padding: 0 10px;
    gap: 8px;
  }
  .navbar-links {
    gap: 10px;
  }
  .navbar-links a {
    font-size: 13px;
  }
  .navbar-logout button {
    padding: 6px 12px;
    font-size: 13px;
  }
  .navbar-profile-link {
    width: 32px;
    height: 32px;
  }
  .navbar-profile-icon {
    width: 18px;
    height: 18px;
  }
}

/* Auth pages (login / register) */
.auth-body {
  background-color: #7bc29a;
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-container {
  background: #ffffff;
  padding: 32px 28px 24px 28px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-logo {
  max-width: 200px;
  height: auto;
  margin-bottom: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-input {
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #c3d7da;
  font-size: 14px;
  width: 100%;
}

.auth-input:focus {
  outline: none;
  border-color: #36b59d;
  box-shadow: 0 0 0 2px rgba(54, 181, 157, 0.25);
}

.auth-button {
  margin-top: 4px;
  padding: 10px 14px;
  border-radius: 6px;
  border: none;
  background-color: #36b59d;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.auth-button:hover {
  background-color: #2aa18b;
}

.auth-error {
  color: #c62828;
  font-size: 13px;
  margin-top: 8px;
  margin-bottom: 0;
}

.auth-success {
  color: #2e7d32;
  font-size: 13px;
  margin-top: 8px;
  margin-bottom: 0;
}

.auth-link {
  margin-top: 16px;
  font-size: 14px;
}

.auth-link a {
  color: #134b5f;
  text-decoration: none;
  font-weight: 500;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* Content pages */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

@media (max-width: 600px) {
  .page-container {
    padding: 16px 12px;
  }
}

/* Buttons on content pages */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
}

.btn-primary {
  background-color: #36b59d;
  color: #fff;
}

.btn-primary:hover {
  background-color: #2aa18b;
}

.btn-danger {
  background-color: #e57373;
  color: #fff;
}

.btn-danger:hover {
  background-color: #d32f2f;
}

.btn-secondary {
  background-color: #f3f6f7;
  color: #134b5f;
}

.btn-secondary:hover {
  background-color: #e2ecef;
}

/* Form inputs on content pages */
.form-input {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #c3d7da;
  font-size: 14px;
}

.form-input:focus {
  outline: none;
  border-color: #36b59d;
  box-shadow: 0 0 0 2px rgba(54, 181, 157, 0.25);
}

textarea.form-input {
  resize: vertical;
  width: 100%;
  max-width: 500px;
}

/*
 * Flex (not grid): in a grid row, track height is the tallest item and some
 * browsers still stretch peers; flex + align-items:flex-start keeps each card
 * only as tall as its own content when one card expands.
 */
.recipe-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.recipe-grid > .recipe-card {
  display: flex;
  flex-direction: column;
  flex: 0 0 calc((100% - 32px) / 3);
  max-width: calc((100% - 32px) / 3);
  min-width: 0;
}

@media (max-width: 900px) {
  .recipe-grid > .recipe-card {
    flex: 0 0 calc((100% - 16px) / 2);
    max-width: calc((100% - 16px) / 2);
  }
}

@media (max-width: 600px) {
  .recipe-grid > .recipe-card {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Recipe cards */
.recipe-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow-wrap: break-word;
  word-break: break-word;
  box-sizing: border-box;
}

.recipe-card-compact {
  display: flex;
  flex-direction: column;
}

.recipe-card-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #eef4f5;
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.recipe-card-media img.recipe-card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.recipe-card-media--placeholder {
  color: #a0b8be;
}

.recipe-card-media--placeholder svg {
  width: 40%;
  max-width: 96px;
  height: auto;
  opacity: 0.65;
}

.recipe-card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  min-height: 3rem;
}

.recipe-card-title-row h3 {
  margin: 0;
  flex: 1 1 120px;
  min-width: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  max-height: calc(1.3em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.recipe-toggle-btn {
  width: 100%;
  margin-top: auto;
  flex-shrink: 0;
}

.recipe-card-details {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e4eef0;
  flex-shrink: 0;
  scroll-margin-top: 80px;
}

.recipe-card-details[hidden] {
  display: none !important;
}

.recipe-form-preview {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center;
  background: #eef4f5;
  border-radius: 6px;
  margin-bottom: 8px;
  display: block;
}

.form-error {
  color: #c0392b;
  margin-bottom: 12px;
  font-size: 14px;
}

.form-hint {
  color: #6b8a91;
  font-size: 13px;
  margin: 4px 0 0;
}

.recipe-actions {
  margin-top: 12px;
  padding-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.recipe-actions .btn {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 13px;
  padding: 6px 10px;
}

@media (max-width: 480px) {
  .recipe-actions .btn {
    font-size: 12px;
    padding: 6px 8px;
  }
}

/* Shopping list */
.shopping-list-content {
  max-width: 600px;
}

.shopping-item {
  background: #ffffff;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
}

.shopping-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  width: 100%;
}

ul {
  padding-left: 18px;
}

button {
  font-family: inherit;
}

/* Ingredient inputs */
.ingredient-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  align-items: stretch;
}

.ingredient-row input[name="ingredientNames"] {
  flex: 1 1 140px;
  min-width: 0;
  max-width: 280px;
}

.form-input-amount {
  flex: 0 1 100px;
  min-width: 60px;
  max-width: 120px;
  -moz-appearance: textfield;
  appearance: textfield;
}

.form-input-unit {
  flex: 0 0 70px;
  min-width: 70px;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid #c3d7da;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
  box-sizing: border-box;
}

.form-input-unit:focus {
  outline: none;
  border-color: #36b59d;
  box-shadow: 0 0 0 2px rgba(54, 181, 157, 0.25);
}

@media (max-width: 480px) {
  .ingredient-row input[name="ingredientNames"] {
    flex: 1 1 100%;
    max-width: none;
  }

  .form-input-amount {
    flex: 1 1 80px;
  }

  .form-input-unit {
    flex: 0 0 65px;
    min-width: 65px;
    font-size: 13px;
  }
}

/* Profile page */
/* Admin users list */
.admin-users-list {
  max-width: 600px;
}

.admin-user-card {
  margin-bottom: 8px;
}

.profile-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 32px 28px;
  max-width: 420px;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: #e8f0f2;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #134b5f;
}

.profile-avatar svg {
  width: 36px;
  height: 36px;
}

.profile-card h2 {
  margin-bottom: 24px;
}

.profile-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}

.profile-label {
  font-weight: 600;
  color: #0b262b;
  font-size: 14px;
}

.profile-value {
  color: #4a6b72;
  font-size: 14px;
}

.profile-delete-section {
  margin-top: 28px;
  padding-top: 20px;
}

.profile-delete-warning {
  font-size: 13px;
  color: #888;
  margin-bottom: 16px;
}

.profile-delete-btn {
  padding: 10px 24px;
  font-size: 14px;
}
