/* App-page layout — loaded in addition to style.css */

/* Override body layout for wider app pages */
body.app-page {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

/* Top navigation bar */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: rgba(5, 11, 31, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 3vw, 2rem);
  height: 56px;
  gap: 1rem;
}

.app-nav__brand {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.app-nav__brand span {
  color: var(--accent);
}

.app-nav__links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
}

.app-nav__links a {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  transition: color 140ms ease, background 140ms ease;
}

.app-nav__links a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.app-nav__links a.active {
  color: var(--accent);
  background: rgba(15, 140, 90, 0.18);
}

.app-nav__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.app-nav__right button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.app-nav__right button:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

/* Logged-in user email in the nav bar */
.nav-username {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* Lang switcher inside the nav bar — override card-footer defaults from style.css */
.app-nav .lang-switcher {
  border-top: none;
  padding-top: 0;
  gap: 0.1rem;
}

.app-nav .lang-switcher button {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.76rem;
}

.app-nav .lang-switcher button:hover:not(.active) {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.08);
}

.app-nav .lang-switcher button.active {
  color: var(--accent);
  background: rgba(15, 140, 90, 0.18);
}

/* Page content wrapper */
.app-content {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem);
}

/* App card — wider than auth card */
.app-card {
  background: var(--overlay);
  border-radius: 20px;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  box-shadow: 0 20px 50px rgba(5, 11, 31, 0.35);
  border-top: 4px solid var(--accent);
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.section-header h1,
.section-header h2 {
  margin: 0;
}

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid rgba(5, 11, 31, 0.08);
  margin-bottom: 1.5rem;
}

.tab-nav button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  padding: 0.6rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  transition: color 140ms ease, border-color 140ms ease;
}

.tab-nav button:hover:not(.active) {
  color: var(--heading);
}

.tab-nav button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  animation: fadeIn 180ms ease;
}

.tab-panel.active {
  display: block;
}

/* View switching (like login page) */
.app-view {
  display: none;
  animation: fadeIn 220ms ease;
}

.app-view.active {
  display: block;
}

/* Data list */
.data-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.data-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: #fff;
  flex-wrap: wrap;
}

.data-list__item-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.data-list__item-title {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.97rem;
}

.data-list__item-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.data-list__item-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Tag/badge */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge--owner {
  background: rgba(15, 140, 90, 0.15);
  color: var(--accent);
}

.badge--member {
  background: rgba(5, 11, 31, 0.07);
  color: var(--muted);
}

.badge--allergy,
.badge--intolerance {
  background: var(--danger-muted);
  color: var(--danger);
}

.badge--liked {
  background: rgba(15, 140, 90, 0.12);
  color: var(--accent);
}

.badge--disliked {
  background: rgba(5, 11, 31, 0.07);
  color: var(--muted);
}

/* Inline form panel */
.inline-form {
  border: 1px dashed rgba(5, 11, 31, 0.15);
  border-radius: 14px;
  padding: 1.25rem;
  background: rgba(5, 11, 31, 0.02);
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.inline-form[hidden] {
  display: none;
}

.inline-form h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--heading);
}

.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-row > * {
  flex: 1;
  min-width: 160px;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Suggestion card */
.suggestion-card {
  border: 1px solid var(--input-border);
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.suggestion-card__rank {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.suggestion-card__name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--heading);
  margin: 0;
}

.suggestion-card__ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 0.5rem;
}

.ingredient-tag {
  font-size: 0.72rem;
  background: rgba(15, 140, 90, 0.08);
  color: var(--accent);
  border: 1px solid rgba(15, 140, 90, 0.2);
  border-radius: 20px;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}

.suggestion-card__explanation {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin: 0;
}

.suggestion-card__notes {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  margin: 0;
}

.suggestion-card__actions {
  margin-top: 0.25rem;
}

.suggestions-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
  margin-right: 0.4em;
}

.spinner--dark {
  border-color: rgba(5, 11, 31, 0.15);
  border-top-color: var(--accent);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Collapsible plan */
.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  user-select: none;
  padding: 0.85rem 1rem;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: #fff;
  transition: background 140ms ease;
}

.plan-header:hover {
  background: rgba(15, 140, 90, 0.05);
}

.plan-header__meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.plan-header__date {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.95rem;
}

.plan-header__subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.plan-header__toggle {
  font-size: 0.8rem;
  color: var(--muted);
}

.plan-body {
  display: none;
  padding: 0.75rem 0 0.25rem;
  animation: fadeIn 180ms ease;
}

.plan-body.open {
  display: block;
}

/* Sentiment buttons for dish rating */
.sentiment-group {
  display: flex;
  gap: 0.35rem;
}

.sentiment-btn {
  border: 1px solid var(--input-border);
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 140ms ease;
  box-shadow: none;
}

.sentiment-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sentiment-btn.active-love {
  background: rgba(15, 140, 90, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.sentiment-btn.active-hate {
  background: var(--danger-muted);
  border-color: var(--danger);
  color: var(--danger);
}

.sentiment-btn.active-neutral {
  background: rgba(5, 11, 31, 0.07);
  border-color: rgba(5, 11, 31, 0.2);
  color: var(--heading);
}

/* User ID copybox */
.copybox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(5, 11, 31, 0.04);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.copybox code {
  flex: 1;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.8rem;
  color: var(--heading);
  word-break: break-all;
}

.copybox button {
  background: none;
  border: none;
  padding: 0.15rem 0.4rem;
  font-size: 0.78rem;
  color: var(--accent);
  cursor: pointer;
  border-radius: 6px;
  box-shadow: none;
  font-weight: 700;
  transition: background 140ms ease;
}

.copybox button:hover {
  background: var(--accent-muted);
}

/* Ingredient picker dropdown */
.ingredient-dropdown {
  position: absolute;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(5, 11, 31, 0.12);
  max-height: 260px;
  overflow-y: auto;
  width: 100%;
  margin-top: 2px;
}

.ingredient-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background 120ms ease;
}

.ingredient-option:hover {
  background: var(--accent-muted);
}

.ingredient-option__name {
  font-size: 0.92rem;
  color: var(--heading);
  font-weight: 500;
}

.ingredient-option__cat {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Wrap the input + dropdown together so the dropdown can be positioned relative */
#add-pref-form .form-row > div:last-child {
  position: relative;
}

/* Dish list for preferences */
.dish-filter {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dish-filter input {
  flex: 1;
  width: auto;
  min-width: 0;
  max-width: 320px;
}

/* select element */
select {
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  padding: 0.9rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  transition: border-color 140ms ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235d6786' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}

select:focus {
  outline: none;
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 3px rgba(15, 140, 90, 0.15);
}

/* Small button variant */
.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* Danger button */
.btn-danger {
  background: var(--danger-muted);
  color: var(--danger);
  border: 1px solid transparent;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(192, 57, 43, 0.22);
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid rgba(5, 11, 31, 0.08);
  margin: 1.5rem 0;
}

/* Responsive tweaks — phones and narrow tablets */
@media (max-width: 720px) {
  /* Nav: row 1 = brand + language/sign-out, row 2 = page links (scrollable) */
  .app-nav {
    height: auto;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem 0;
    column-gap: 0.5rem;
    row-gap: 0.35rem;
  }

  .app-nav__right {
    margin-left: auto;
    gap: 0.4rem;
  }

  .app-nav__right button {
    padding: 0.3rem 0.55rem;
  }

  .app-nav .lang-switcher button {
    padding: 0.3rem 0.45rem;
  }

  .nav-username {
    max-width: 90px;
  }

  .app-nav__links {
    order: 3;
    flex: 1 0 100%;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.75rem;
    padding: 0 0.75rem 0.5rem;
  }

  .app-nav__links::-webkit-scrollbar {
    display: none;
  }

  .app-nav__links a {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
  }

  /* Content: use the full screen width */
  .app-content {
    padding: 0.75rem 0.6rem 1.5rem;
  }

  .app-card {
    padding: 1.1rem 1rem;
    border-radius: 14px;
  }

  .section-header h1 {
    font-size: 1.3rem;
  }

  .section-header h2 {
    font-size: 1.1rem;
  }

  /* Tabs scroll sideways instead of widening the page */
  .tab-nav {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tab-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-nav button {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.55rem 0.75rem;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row > * {
    min-width: 0;
  }

  .data-list__item {
    padding: 0.75rem;
    gap: 0.6rem;
  }

  .suggestion-card {
    padding: 0.9rem 1rem;
  }

  .dish-filter {
    flex-wrap: wrap;
  }

  .dish-filter input {
    flex: 1 1 100%;
    max-width: none;
  }

  .inline-form {
    padding: 1rem;
  }

  .modal-card {
    padding: 1.25rem;
  }
}

/* Very narrow phones: the nickname is shown on the pages themselves */
@media (max-width: 420px) {
  .nav-username {
    display: none;
  }
}

/* ── Nickname modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 11, 31, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 48px rgba(5, 11, 31, 0.18);
}
