/* ============================================================
   FAST FOOD NUTRITION CALCULATOR - style.css
   ============================================================ */

/* ============================================================
   1. CSS VARIABLES & RESET
   ============================================================ */
:root {
  --primary:        #e8541a;
  --primary-dark:   #c4410f;
  --primary-light:  #ff7043;
  --accent:         #ffa726;
  --bg:             #f9f6f2;
  --surface:        #ffffff;
  --surface-2:      #f2ede8;
  --border:         #e0d6cc;
  --text:           #2c2c2c;
  --text-muted:     #7a6f65;
  --success:        #2e7d32;
  --danger:         #c62828;
  --shadow-sm:      0 2px 6px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.16);
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      20px;
  --transition:     0.25s ease;
  --font:           'Segoe UI', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   2. CONTAINER
   ============================================================ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ============================================================
   3. HEADER
   ============================================================ */
.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 2.5rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.site-title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
}

.site-tagline {
  font-size: clamp(0.95rem, 2.5vw, 1.2rem);
  opacity: 0.9;
  font-weight: 400;
}

/* ============================================================
   4. AD BANNER
   ============================================================ */
.ad-banner {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ============================================================
   5. EXPLANATION BLOCK
   ============================================================ */
.explanation-block {
  padding: 3rem 0;
  background: var(--surface);
}

.explanation-block h2 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--primary);
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.step {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
}

.step:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.step-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.step h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--primary);
}

.step p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ============================================================
   6. MEAL PLANNER SECTION
   ============================================================ */
.meal-planner {
  padding: 3rem 0;
  background: var(--bg);
}

.meal-planner h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
}

/* ---- Goal Selector ---- */
.planner-goal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.planner-goal label {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
}

.planner-goal select {
  flex: 1;
  min-width: 180px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
}

.planner-goal select:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-autogen {
  background: var(--accent);
  color: #3c2900;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn-autogen:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* ---- Item Selectors ---- */
.planner-selectors {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.selector-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-width: 200px;
}

.selector-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.selector-group select {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
}

.selector-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.selector-group select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Add Button ---- */
.btn-add {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
  align-self: flex-end;
}

.btn-add:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.btn-add:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ---- Quick Item Search ---- */
.quick-search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.quick-search label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.quick-search input {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
}

.quick-search input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-results {
  display: none;
  margin-top: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.search-results.open {
  display: block;
}

.search-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.search-result-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.search-result-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.search-result-restaurant {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.search-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem 0.25rem;
}

.btn-add-small {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-add-small:hover {
  background: var(--primary-dark);
}

/* ---- Chain Grid Filter ---- */
.chain-filter-input {
  width: 100%;
  max-width: 400px;
  display: block;
  margin: 0 auto 1.5rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
}

.chain-filter-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================================
   7. MEAL LIST
   ============================================================ */
.meal-list-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.meal-list-wrapper h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.meal-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.empty-message {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 1.5rem 0;
}

/* ---- Meal Item Row ---- */
.meal-item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  transition: box-shadow var(--transition);
  flex-wrap: wrap;
}

.meal-item-row:hover {
  box-shadow: var(--shadow-sm);
}

.meal-item-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 140px;
}

.meal-item-restaurant {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.meal-item-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.meal-item-macros {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.macro {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
}

.macro.cal {
  background: #fff3e0;
  color: #e65100;
}

.macro.pro {
  background: #e8f5e9;
  color: #2e7d32;
}

.macro.fat {
  background: #fce4ec;
  color: #880e4f;
}

.macro.carb {
  background: #e3f2fd;
  color: #1565c0;
}

/* ---- Remove Button ---- */
.btn-remove {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--danger);
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.btn-remove:hover {
  background: #ffebee;
  border-color: var(--danger);
}

/* ============================================================
   8. MEAL TOTALS
   ============================================================ */
.meal-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.total-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: box-shadow var(--transition);
}

.total-card:hover {
  box-shadow: var(--shadow-md);
}

.total-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.total-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.total-value.under {
  color: var(--success);
}

.total-value.over {
  color: var(--danger);
}

.total-goal {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.2rem;
}

.total-goal.under {
  color: var(--success);
}

.total-goal.over {
  color: var(--danger);
}

/* ============================================================
   9. CALORIE WARNING
   ============================================================ */
.calorie-warning {
  background: #ffebee;
  border: 1px solid #ef9a9a;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.25rem;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  margin-bottom: 1rem;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

/* ============================================================
   10. PLANNER ACTIONS
   ============================================================ */
.planner-actions {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.btn-clear {
  background: transparent;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 2rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-clear:hover {
  background: #ffebee;
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================================
   11. CHAIN GRID
   ============================================================ */
.all-chains {
  padding: 3rem 0;
  background: var(--surface);
}

.all-chains h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
}

.chain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.chain-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.chain-card:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.chain-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: inherit;
}

.chain-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chain-card:hover .chain-count {
  color: rgba(255,255,255,0.8);
}

/* ============================================================
   12. FOOTER
   ============================================================ */
.site-footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,0.85);
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: 0.88rem;
  line-height: 1.8;
}

/* ============================================================
   13. RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .planner-selectors {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-add {
    width: 100%;
    text-align: center;
  }

  .meal-item-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn-remove {
    align-self: flex-end;
  }

  .meal-totals {
    grid-template-columns: repeat(2, 1fr);
  }

  .planner-goal {
    flex-direction: column;
    align-items: stretch;
  }

  .planner-goal select {
    width: 100%;
  }

  .btn-autogen {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .meal-totals {
    grid-template-columns: 1fr 1fr;
  }

  .chain-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .steps-grid {
    grid-template-columns: 1fr;
  }

  .total-value {
    font-size: 1.6rem;
  }
}