/* ============================================================
   style.css — Cebulla Bar
   ============================================================ */

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

:root {
  --bg:        #0d0c10;
  --surface:   #171520;
  --surface-2: #1e1c2a;
  --border:    #252235;
  --border-2:  #312e44;
  --amber:     #d4a843;
  --amber-glow:rgba(212,168,67,0.12);
  --amber-dim: #8a6e2a;
  --text:      #e8e2d4;
  --text-2:    #b0a89e;
  --muted:     #6b6478;
  --green:     #27ae60;
  --yellow:    #f1c40f;
  --orange:    #e67e22;
  --red:       #e74c3c;
  --lime:      #84cc16;
}

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: 'Inter', system-ui, sans-serif; overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* NAV */
#top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(13,12,16,0.92); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; height: 56px;
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-logo  { font-size: 22px; line-height: 1; }
.nav-title { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 700; color: var(--amber); line-height: 1.1; }
.nav-sub   { font-size: 10px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 1px; }
.nav-tabs  { display: flex; gap: 2px; }
.nav-tab {
  padding: 6px 12px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  font-family: 'Inter', sans-serif; background: transparent; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.nav-tab.active { background: var(--amber); color: #0d0c10; }

/* PAGES */
.page          { display: none; padding-top: 72px; padding-bottom: 32px; min-height: 100vh; }
.page.active   { display: block; }
.page-chat.active { display: flex; flex-direction: column; padding-bottom: 0; }

.container { max-width: 680px; margin: 0 auto; padding: 0 18px; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 16px 0 4px; flex-wrap: wrap;
}
.page-header-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.page-title { font-family: 'Playfair Display', serif; font-size: 24px; font-weight: 900; color: var(--text); line-height: 1.1; padding-top: 16px; }
.page-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; margin-bottom: 16px; }

/* SCAN HERO */
.scan-hero {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 26px 20px; text-align: center; margin: 16px 0; position: relative; overflow: hidden;
}
.scan-hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--amber-glow) 0%, transparent 70%);
  pointer-events: none;
}
.btn-scan {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--amber); color: #0d0c10; border: none; border-radius: 10px;
  padding: 13px 26px; font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 4px 20px rgba(212,168,67,0.28); transition: transform 0.1s;
}
.btn-scan:active { transform: scale(0.97); }
.scan-hint { font-size: 12px; color: var(--muted); margin-top: 10px; }
.btn-link  { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; margin-top: 6px; font-family: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* RECIPES */
.recipe-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s;
}
.recipe-card:hover { border-color: var(--border-2); }
.recipe-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.recipe-name        { font-weight: 600; font-size: 14px; line-height: 1.3; color: var(--text); }
.recipe-glass       { font-size: 11px; color: var(--muted); margin-top: 2px; }
.recipe-description { font-size: 12px; color: var(--text-2); margin: 6px 0; line-height: 1.5; }
.recipe-ing-list    { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.recipe-ing-tag     { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.recipe-tags        { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.recipe-tag         { font-size: 10px; padding: 1px 7px; border-radius: 10px; background: rgba(212,168,67,0.1); border: 1px solid rgba(212,168,67,0.3); color: var(--amber); font-weight: 500; }
.recipe-source-badge { font-size: 10px; color: var(--muted); }
.rd-ingredient      { font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--border); line-height: 1.5; }
.rd-ingredient:last-child { border-bottom: none; }

/* SUBSCRIPTION / UPGRADE */
.plan-card {
  background: var(--bg); border: 2px solid var(--border); border-radius: 10px;
  padding: 14px 10px; cursor: pointer; transition: all 0.15s; text-align: center;
}
.plan-card:hover     { border-color: var(--border-2); }
.plan-card-active    { border-color: var(--amber) !important; background: rgba(212,168,67,0.08) !important; }

.trial-banner {
  background: rgba(212,168,67,0.08); border-bottom: 1px solid rgba(212,168,67,0.2);
  padding: 8px 18px; display: flex; align-items: center; justify-content: space-between;
  font-size: 12px;
}
.trial-banner-text { color: var(--amber); font-weight: 600; }
.trial-banner-sub  { color: var(--muted); font-size: 11px; }

/* SEARCH BAR */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin: 14px 0 10px;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  pointer-events: none;
}
.search-field {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 36px 10px 36px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.search-field:focus { border-color: var(--amber-dim); }
.search-field::placeholder { color: var(--muted); }
/* Hide native clear button on webkit */
.search-field::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute;
  right: 10px;
  background: var(--border);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.search-clear:hover { background: var(--border-2); color: var(--text); }

/* FILTER CHIPS */
.filter-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  white-space: nowrap; padding: 5px 12px; border-radius: 20px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  font-size: 12px; cursor: pointer; font-weight: 500; font-family: inherit; transition: all 0.12s;
}
.filter-chip.active { border-color: var(--amber); color: var(--amber); background: var(--amber-glow); }

/* BOTTLE CARDS */
.bottle-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 14px 11px; margin-bottom: 8px;
  display: grid; grid-template-columns: 10px 1fr auto;
  gap: 0 12px; align-items: start;
  transition: border-color 0.15s;
}
.bottle-card:hover { border-color: var(--border-2); }

.bottle-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }

.bottle-info-col { min-width: 0; }
.bottle-name { font-weight: 600; font-size: 14px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bottle-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Horizontal pip bar — full on left, drains right */
.level-bar-wrap { margin-top: 10px; }
.level-pips {
  display: flex; gap: 4px; margin-bottom: 3px;
}
.level-pip {
  flex: 1; height: 6px; border-radius: 3px; border: none;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
}
.level-pip:hover { transform: scaleY(1.6); }
.level-bar-labels {
  display: flex; justify-content: space-between;
}
.level-bar-labels span { font-size: 9px; color: var(--muted); }

/* Right column — level label + delete */
.bottle-right {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 6px;
}
.level-tag { font-size: 11px; font-weight: 600; white-space: nowrap; }
.edit-btn, .delete-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 4px; border-radius: 4px; display: flex; align-items: center;
  transition: color 0.15s, background 0.15s;
}
.edit-btn:hover   { color: var(--amber); background: rgba(212,168,67,0.08); }
.delete-btn:hover { color: var(--red);   background: rgba(231,76,60,0.08); }

.empty-state  { text-align: center; padding: 52px 0; color: var(--muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* BUTTONS */
.btn-primary {
  width: 100%; padding: 12px; background: var(--amber); color: #0d0c10;
  border: none; border-radius: 10px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.85; }
.btn-ghost {
  width: 100%; padding: 11px; background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
  cursor: pointer; font-family: inherit; margin-top: 8px;
}
.btn-outline {
  padding: 7px 14px; background: transparent; color: var(--text-2);
  border: 1px solid var(--border-2); border-radius: 6px; font-size: 12px;
  font-weight: 500; cursor: pointer; font-family: inherit; transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover { border-color: var(--amber-dim); color: var(--amber); }
.btn-sm     { padding: 6px 12px; font-size: 11px; }
.btn-danger { color: var(--red) !important; border-color: rgba(231,76,60,0.3) !important; }
.btn-danger:hover { border-color: var(--red) !important; }

/* SHOPPING */
.inline-add { display: flex; gap: 8px; margin-bottom: 16px; }
.inline-add .field { flex: 1; margin-bottom: 0; }
.shopping-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 6px; display: flex; align-items: center; gap: 10px;
  transition: opacity 0.2s;
}
.shopping-item.checked { opacity: 0.45; }
.shopping-check {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-2);
  background: transparent; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.shopping-check.done { background: var(--green); border-color: var(--green); }
.shopping-check.done::after { content: '✓'; font-size: 10px; color: #fff; font-weight: 700; }
.shopping-name { flex: 1; font-size: 14px; font-weight: 500; }
.shopping-item.checked .shopping-name { text-decoration: line-through; }
.shopping-note { font-size: 11px; color: var(--muted); }

/* SCANNER */
#scanner-wrap { display: none; position: fixed; inset: 0; background: #000; z-index: 200; flex-direction: column; align-items: center; justify-content: center; }
#scanner-wrap.open { display: flex; }
#scanner-video { width: 100%; height: 100%; object-fit: cover; }
.scanner-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.scanner-frame {
  width: min(320px,80vw); height: 200px; border: 2px solid var(--amber); border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55); animation: pulse-border 2s ease-in-out infinite;
}
@keyframes pulse-border {
  0%,100% { border-color: var(--amber); box-shadow: 0 0 0 9999px rgba(0,0,0,0.55), 0 0 20px rgba(212,168,67,0.2); }
  50%      { border-color: #f0c060;     box-shadow: 0 0 0 9999px rgba(0,0,0,0.55), 0 0 30px rgba(212,168,67,0.5); }
}
.scanner-label  { color: rgba(255,255,255,0.8); font-size: 13px; margin-top: 16px; }
.scanner-close  { position: absolute; top: 20px; right: 20px; pointer-events: all; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.scanner-manual-btn { position: absolute; bottom: 40px; pointer-events: all; background: transparent; border: 1px solid rgba(255,255,255,0.3); color: rgba(255,255,255,0.7); padding: 8px 20px; border-radius: 20px; font-size: 13px; cursor: pointer; font-family: inherit; }

/* MODAL */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 300; align-items: flex-end; justify-content: center; }
.modal-backdrop.open { display: flex; }
.modal-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: 18px 18px 0 0; padding: 18px 20px 40px; width: 100%; max-width: 680px; animation: slideup 0.22s ease; max-height: 92vh; overflow-y: auto; }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-handle { width: 40px; height: 4px; background: var(--border-2); border-radius: 2px; margin: 0 auto 18px; }
.modal-title  { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 700; margin-bottom: 14px; }

/* FORM */
.field-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 5px; display: block; }
.field-hint  { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 10px; }
.field {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; color: var(--text); font-size: 14px; width: 100%;
  font-family: inherit; margin-bottom: 12px; outline: none; transition: border-color 0.15s;
  appearance: none; -webkit-appearance: none;
}
.field:focus { border-color: var(--amber-dim); }
select.field { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b6478' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
select.field option { background: var(--surface); }
.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* SETTINGS */
.settings-group { margin-top: 22px; }
.api-notice  { font-size: 11px; color: var(--muted); margin-top: 5px; }
.api-notice a { color: var(--amber); text-decoration: none; }

/* CHAT */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 18px 12px;
  display: flex; flex-direction: column; gap: 12px;
  max-width: 680px; width: 100%; margin: 0 auto; min-height: 0;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg-bubble { max-width: 82%; padding: 10px 13px; border-radius: 14px; font-size: 13px; line-height: 1.58; white-space: pre-wrap; word-break: break-word; }
.msg.user .msg-bubble { background: var(--amber); color: #0d0c10; border-radius: 14px 14px 4px 14px; }
.msg.ai   .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; }
.typing-wrap   { display: flex; }
.typing-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; padding: 12px 14px; display: flex; gap: 4px; align-items: center; }
.typing-dot    { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,100%{opacity:0.3;transform:translateY(0)} 50%{opacity:1;transform:translateY(-3px)} }

.chat-bar { background: var(--bg); border-top: 1px solid var(--border); padding: 10px 18px 24px; max-width: 680px; width: 100%; margin: 0 auto; }
.chat-suggestions { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chat-suggestions::-webkit-scrollbar { display: none; }
.suggestion { white-space: nowrap; padding: 5px 11px; border-radius: 14px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; font-family: inherit; transition: border-color 0.12s, color 0.12s; }
.suggestion:hover { border-color: var(--amber-dim); color: var(--text-2); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; color: var(--text); font-size: 13px; outline: none; font-family: inherit; transition: border-color 0.15s; }
.chat-input:focus { border-color: var(--amber-dim); }
.btn-send { padding: 10px 18px; background: var(--amber); color: #0d0c10; border: none; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 13px; font-family: inherit; white-space: nowrap; }
.btn-send:disabled { background: var(--border); color: var(--muted); cursor: default; }

/* TOAST */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px); background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text); padding: 10px 18px; border-radius: 20px; font-size: 13px; font-weight: 500; opacity: 0; transition: opacity 0.22s, transform 0.22s; z-index: 500; white-space: nowrap; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* SHIMMER */
.shimmer { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; height: 64px; margin-bottom: 8px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
  .nav-title  { font-size: 14px; }
  .page-header { flex-direction: column; }
}