/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  background: #f5f7fa;
  line-height: 1.5;
}

a { color: #16a34a; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #16a34a;
  color: white;
  padding: 0 1.5rem;
  height: 52px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.navbar-brand a { color: white; font-size: 1.1rem; font-weight: 700; }
.navbar-links a {
  color: rgba(255,255,255,.85);
  margin-left: 1.5rem;
  font-size: .9rem;
}
.navbar-links a:hover { color: white; text-decoration: none; }
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: white;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 700;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 .3rem;
  margin-left: .3rem;
  vertical-align: middle;
  line-height: 1;
}
.navbar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: 1.5rem;
}
.navbar-username {
  color: rgba(255,255,255,.9);
  font-size: .85rem;
}
.navbar-username:hover { color: white; text-decoration: underline; }
.btn-outline {
  background: transparent;
  border: 1px solid currentColor;
  color: white;
}
.btn-outline:hover { background: rgba(255,255,255,.15); }

/* ── Container ── */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ── Flash messages ── */
.flash { padding: .6rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem; }
.flash-notice { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-alert  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-header h1 { font-size: 1.5rem; }
.header-actions { margin-left: auto; display: flex; gap: .5rem; }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: .4rem .9rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary   { background: #16a34a; color: white; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-danger    { background: #ef4444; color: white; }
.btn-sm        { padding: .25rem .6rem; font-size: .8rem; }
button.btn { font-family: inherit; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .85rem; }
.form-control {
  width: 100%;
  padding: .45rem .7rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: .9rem;
  background: white;
}
.form-control:focus { outline: none; border-color: #16a34a; box-shadow: 0 0 0 2px rgba(22,163,74,.2); }
.form-control-sm { padding: .3rem .55rem; font-size: .85rem; }
select.form-control.is-placeholder { color: #9ca3af; }
select.form-control option { color: #111827; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

.error-messages {
  background: #fee2e2; border: 1px solid #fca5a5;
  border-radius: 6px; padding: .75rem 1rem; margin-bottom: 1rem;
  color: #991b1b; font-size: .85rem;
}

.inline-form {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  background: white; padding: .75rem; border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.inline-form .form-control { width: auto; }

/* ── Cards ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.card {
  background: white; border-radius: 10px; padding: 1.1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08); border: 1px solid #e5e7eb;
}
.card h3 { font-size: 1rem; margin-bottom: .3rem; }
.card-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .75rem; }

/* ── Tables ── */
.data-table, .shopping-table, .table {
  width: 100%; border-collapse: collapse; background: white;
  border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.data-table th, .data-table td,
.shopping-table th, .shopping-table td,
.table th, .table td {
  padding: .6rem .9rem; border-bottom: 1px solid #f3f4f6; text-align: left;
}
.data-table th, .shopping-table th, .table th { background: #f9fafb; font-weight: 600; font-size: .8rem; text-transform: uppercase; color: #6b7280; }
.data-table tr:last-child td, .shopping-table tr:last-child td, .table tr:last-child td { border-bottom: none; }
.data-table tr:hover td, .table tr:hover td { background: #fafafa; }
.btn-group, .card-actions { display: flex; flex-wrap: nowrap; gap: .4rem; align-items: center; }
.btn-group form, .card-actions form { display: inline-flex; margin: 0; }
.text-right { text-align: right; }

/* ── Weekly table ── */
.table-wrapper { overflow-x: auto; }

.weekly-table {
  width: 100%; border-collapse: collapse; background: white;
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,.1);
  min-width: 700px;
  table-layout: fixed;
}
.weekly-table th {
  background: #16a34a; color: white;
  padding: .6rem .5rem; text-align: center;
  font-size: .8rem; font-weight: 600;
  width: 13.5%;
}
.weekly-table td { border: 1px solid #e5e7eb; vertical-align: top; }
.meal-label {
  background: #f9fafb; padding: .55rem .75rem;
  font-size: .8rem; color: #374151; width: 100px;
  white-space: nowrap;
}
.weekly-table th.meal-label { width: 100px; }
.meal-cell { padding: .4rem; min-height: 54px; word-wrap: break-word; overflow-wrap: break-word; }

.slot-filled { display: flex; flex-direction: column; gap: .25rem; height: 100%; }

/* Header row: title on the left, options menu on the right */
.slot-header {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
}
.slot-name { font-size: .82rem; font-weight: 500; color: #14532d; }
.slot-name a { color: inherit; }

.slot-name-container {
  flex: 1;
  min-width: 0;
}

.slot-menu {
  position: relative;
  margin-left: auto;
  align-self: flex-start;
}
.slot-menu-toggle {
  background: transparent; border: none; cursor: pointer;
  font-size: 1rem; line-height: 1; padding: .1rem .35rem;
  color: #6b7280; border-radius: 4px;
}
.slot-menu-toggle:hover { background: #e5e7eb; color: #374151; }

.slot-menu-dropdown {
  display: none;
  flex-direction: column;
  position: fixed; z-index: 1000;
  padding: .25rem;
  min-width: 110px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.slot-menu-dropdown.open { display: flex; }
.slot-menu-dropdown form { margin: 0; }

.slot-menu-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none; cursor: pointer;
  font-size: .8rem; padding: .35rem .5rem; border-radius: 4px;
  color: #374151; text-decoration: none;
}
.slot-menu-item:hover { background: #f3f4f6; text-decoration: none; }
.slot-menu-item-danger { color: #b91c1c; }
.slot-menu-item-danger:hover { background: #fee2e2; }

.slot-add {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 44px; color: #9ca3af;
  font-size: 1.3rem; border-radius: 6px;
  border: 1.5px dashed #d1d5db; transition: all .15s;
}
.slot-add:hover { border-color: #16a34a; color: #16a34a; text-decoration: none; background: #f0fdf4; }

/* ── Shopping list ── */
.shopping-list { margin-top: 2rem; }
.shopping-list h2 { font-size: 1.2rem; margin-bottom: .75rem; }

/* ── Print (weekly plan) ── */
@media print {
  @page { size: landscape; margin: 5mm; }

  html, body { height: auto; }
  body { background: white; font-size: 9px; }

  .navbar, .header-actions, .flash, .shopping-list,
  .confirm-overlay, .slot-menu, .slot-menu-dropdown, .slot-add {
    display: none !important;
  }

  .container { max-width: none; padding: 0; margin: 0; }

  .page-header { margin-bottom: .3rem; }
  .page-header h1 { font-size: 1.2rem; }

  .table-wrapper { overflow: visible; }

  .weekly-table {
    width: 100%; min-width: 0; table-layout: fixed;
    box-shadow: none; border: 1px solid #e5e7eb;
  }
  .weekly-table th { padding: .2rem; font-size: .72rem; color: #1a1a2e; background: #e5e7eb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .weekly-table td { padding: .15rem; }

  .meal-label { width: 55px; padding: .2rem; font-size: .68rem; }
  .meal-cell { padding: .15rem; min-height: 0; }

  .slot-filled { gap: .12rem; min-width: 0; }
  .slot-name-container, .slot-name { min-width: 0; }
  .slot-name { font-size: .68rem; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

  .ingredients-list { margin-top: .12rem; padding-top: .12rem; min-width: 0; }
  .ingredient-item {
    font-size: .62rem; line-height: 1.25; margin-bottom: 0; min-width: 0;
  }
  .ingredient-amount, .ingredient-unit { margin-right: .15rem; flex-shrink: 0; }
  .ingredient-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ── Ingredient table in forms ── */
.ingredient-table { width: 100%; border-collapse: collapse; }
.ingredient-table th { font-size: .8rem; color: #6b7280; padding: .3rem .4rem; text-align: left; }
.ingredient-table td { padding: .25rem .4rem; }
.ingredient-row td { vertical-align: middle; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: .15rem .5rem;
  background: #dcfce7; color: #15803d; border-radius: 99px;
  font-size: .75rem; margin: .1rem .1rem 0 0;
}
.badge-admin    { background: #fef3c7; color: #92400e; }
.badge-user     { background: #dcfce7; color: #15803d; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-pending  { background: #fee2e2; color: #991b1b; }

/* ── Auth ── */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 3rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
}
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check input { width: auto; }
.form-hint { color: #6b7280; font-size: .8rem; margin-left: .5rem; }
.form-actions { margin-top: 1.25rem; }
.page-title { font-size: 1.4rem; margin-bottom: 1.25rem; }

/* ── Confirm modal ── */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.confirm-dialog {
  background: white;
  border-radius: 12px;
  padding: 1.75rem 2rem;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.confirm-message {
  font-size: 1rem;
  color: #1a1a2e;
  margin-bottom: 1.5rem;
  text-align: center;
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}
.text-muted { color: #6b7280; }
.small { font-size: .82rem; }
.empty-state { color: #9ca3af; font-style: italic; margin-top: 1rem; }
h1 { font-size: 1.6rem; margin-bottom: 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }

/* ── Ingredients list in weekly plan ── */
.ingredients-list {
  margin-top: .4rem;
  padding-top: .4rem;
  border-top: 1px dashed #e5e7eb;
}

.ingredient-item {
  display: flex;
  font-size: .8rem;
  margin-bottom: .25rem;
  align-items: baseline;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color .15s;
}

.ingredient-item:hover {
  background: #f0fdf4;
}

.ingredient-item.ingredient-highlighted {
  background: #fef08a;
}

tr.ingredient-item {
  display: table-row;
}

tr.ingredient-item:hover td {
  background: #f0fdf4;
}

tr.ingredient-item.ingredient-highlighted td {
  background: #fef08a;
}

.ingredient-amount {
  font-weight: 600;
  color: #16a34a;
  margin-right: .3rem;
}

.ingredient-unit {
  color: #4b5563;
  margin-right: .3rem;
  font-size: 0.8em;
}

.ingredient-name {
  color: #374151;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
