/* ─── Variables ───────────────────────────────────────────── */
:root {
  --bg:           #16120e;
  --bg-card:      #1f1812;
  --bg-input:     #261d15;
  --bg-hover:     #2a2018;
  --border:       #3a2c1f;
  --border-light: #4a3a28;
  --accent:       #f59e0b;
  --accent-hover: #d97706;
  --accent-light: #fbbf24;
  --accent-glow:  rgba(245, 158, 11, 0.25);
  --accent2:      #ea580c;
  --groq:         #f97316;
  --gemini:       #3b82f6;
  --openai:       #22c55e;
  --text:         #f5ead9;
  --text-muted:   #b39a7c;
  --text-dim:     #6b5640;
  --success:      #22c55e;
  --error:        #ef4444;
  --warning:      #f59e0b;
  --radius:       10px;
  --radius-sm:    7px;
}

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

/* ─── Base ────────────────────────────────────────────────── */
html {
  width: 100%;
  min-height: 100vh;
  margin: 0;
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.app-container {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

body::-webkit-scrollbar { width: 4px; }
body::-webkit-scrollbar-track { background: transparent; }
body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Screens ─────────────────────────────────────────────── */
.screen { display: block; }
.screen.hidden { display: none; }
.hidden { display: none !important; }

.msg-error {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--error);
  font-size: 12px;
  padding: 8px 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ─── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #1a1410;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover { background: linear-gradient(135deg, #fbbf24, #f59e0b); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-full { width: 100%; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost:hover { color: var(--text); border-color: var(--border-light); background: var(--bg-hover); }
.btn-ghost.btn-accent { color: var(--accent-light); border-color: rgba(245,158,11,0.35); }
.btn-ghost.btn-accent:hover { background: rgba(245,158,11,0.1); border-color: var(--accent); }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover { border-color: var(--border-light); color: var(--text); background: var(--bg-hover); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent-light);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 8px;
  width: 100%;
  justify-content: center;
}

.btn-add:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-light); background: rgba(245,158,11,0.06); }
.btn-add:disabled { opacity: 0.35; cursor: not-allowed; }

.copy-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  border-radius: 5px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.copy-btn:hover { border-color: var(--border); color: var(--text-muted); background: var(--bg-hover); }
.copy-btn.copied { color: var(--success); border-color: rgba(34,197,94,0.3); }

.copy-all-btn {
  width: auto;
  height: auto;
  padding: 6px 12px;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid rgba(245,158,11,0.3);
  color: var(--accent-light);
  margin-top: 10px;
}
.copy-all-btn:hover { background: rgba(245,158,11,0.1); border-color: var(--accent); }


/* ─── Header ──────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

/* ─── AI Selector ─────────────────────────────────────────── */
.ai-selector {
  display: flex;
  gap: 6px;
  padding: 12px 16px 0;
}

.ai-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 0;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-tab:hover { border-color: var(--border-light); color: var(--text); }

.ai-tab.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(245,158,11,0.12);
  box-shadow: 0 0 0 1px rgba(245,158,11,0.25);
}

.ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Config Warning ──────────────────────────────────────── */
.config-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 16px 0;
  padding: 8px 12px;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-sm);
  color: var(--warning);
  font-size: 12px;
}

/* ─── Form sections ───────────────────────────────────────── */
.form-section {
  padding: 14px 16px 0;
}

.form-row {
  display: flex;
  gap: 12px;
  padding: 14px 16px 0;
}

.form-half { flex: 1; padding: 0; }

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.form-label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}

.form-label-hint {
  text-transform: none;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0;
}

.form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23b39a7c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ─── Ingredients dynamic list ────────────────────────────── */
.ingredients-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ingredient-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ingredient-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ingredient-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.ingredient-input::placeholder { color: var(--text-dim); }

.btn-remove-ingredient {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-remove-ingredient:hover { border-color: var(--error); color: var(--error); background: rgba(239,68,68,0.08); }

/* ─── Servings selector ───────────────────────────────────── */
.servings-options {
  display: flex;
  gap: 6px;
}

.servings-btn {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 0;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.servings-btn:hover { border-color: var(--border-light); color: var(--text); background: var(--bg-hover); }
.servings-btn.active { background: rgba(245,158,11,0.15); border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px rgba(245,158,11,0.2); }

/* ─── Input Group ─────────────────────────────────────────── */
.input-group {
  padding: 16px 16px 16px;
}

/* ─── Loading Screen ──────────────────────────────────────── */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
  min-height: 260px;
  justify-content: center;
}

.loading-icon {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.loading-ring {
  position: absolute;
  inset: 0;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loading-msg {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 28px;
  min-height: 18px;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.step-dot.pending { background: var(--border); }
.step-dot.active { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: pulse 1.2s ease infinite; }
.step-dot.done { background: var(--success); }

.step.active { color: var(--text); }
.step.done { color: var(--success); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── Results Header ──────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  gap: 8px;
}

.results-meta {
  font-size: 11px;
  color: var(--text-dim);
  flex: 1;
  text-align: center;
}

/* ─── Dish Card ───────────────────────────────────────────── */
.dish-card {
  position: relative;
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(234,88,12,0.05));
  border-bottom: 1px solid var(--border);
  padding: 18px 16px 16px;
}

.dish-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 8px;
}

.dish-times {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dish-times .vi-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ─── Result Sections ─────────────────────────────────────── */
.result-section {
  border-bottom: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
  cursor: pointer;
  user-select: none;
}

.section-icon { font-size: 14px; flex-shrink: 0; }

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.section-content {
  padding: 0 14px 12px;
}

/* List items */
.result-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.result-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 6px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: border-color 0.15s;
}

.result-list li:hover { border-color: var(--border); }

.list-num {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  background: rgba(245,158,11,0.18);
  color: var(--accent-light);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* Ingredient items with quantity */
.ingredient-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  padding: 7px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.ingredient-item:hover { border-color: var(--border); }
.ingredient-item .ing-name { color: var(--text); }
.ingredient-item .ing-qty { color: var(--accent-light); font-weight: 600; white-space: nowrap; flex-shrink: 0; }

/* Substitutions / variations */
.substitution-item {
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  margin-bottom: 5px;
}
.substitution-item:hover { border-color: var(--border); }
.substitution-item:last-child { margin-bottom: 0; }

.sub-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.sub-original { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--text-dim); }
.sub-arrow { color: var(--accent); font-weight: 700; flex-shrink: 0; }
.sub-replacement { color: var(--text); font-weight: 600; }

.sub-note {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.45;
}

/* Plating */
.plating-text {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
  white-space: pre-line;
}

/* ─── Results Footer ──────────────────────────────────────── */
.results-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

.ai-badge {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
}

.footer-meta {
  font-size: 11px;
  color: var(--text-dim);
}

/* ─── Info cards (calorías / maridaje) ────────────────────── */
.info-cards {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
}

.info-card {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}

.info-card-icon { font-size: 18px; flex-shrink: 0; }
.info-card-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 3px; }
.info-card-value { font-size: 12.5px; color: var(--text); line-height: 1.4; font-weight: 500; }

/* ─── Notes Section ───────────────────────────────────────── */
.notes-section { border-bottom: none; }

.notes-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

.notes-form { padding: 0 14px 12px; }

.note-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  line-height: 1.5;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 8px;
  display: block;
}

.note-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.note-textarea::placeholder { color: var(--text-dim); }

.notes-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.notes-list {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s;
}

.note-card:hover { border-color: var(--border-light); }

.note-card-text {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
  white-space: pre-wrap;
  margin-bottom: 8px;
  word-break: break-word;
}

.note-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-card-date { font-size: 11px; color: var(--text-dim); }

.note-card-actions { display: flex; gap: 6px; }

.btn-note-action {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-dim);
  font-size: 11px;
  padding: 3px 9px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-note-action:hover { color: var(--text); border-color: var(--border-light); background: var(--bg-hover); }
.btn-note-action.danger:hover { color: var(--error); border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.06); }

.note-edit-area {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  line-height: 1.5;
  padding: 8px 10px;
  resize: vertical;
  min-height: 70px;
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
  margin-bottom: 8px;
  display: block;
  width: 100%;
}

.notes-empty {
  padding: 10px 14px 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
