/* ============================================================
   DishDetector – Web-App (Nachbau der App-Screens)
   ============================================================ */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@500;600;700;800&display=swap");
@import url("../brand/brand-tokens.css");

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--dd-font-text);
  color: var(--dd-ink);
  background:
    radial-gradient(1200px 700px at 50% -10%, var(--dd-primary-tint), transparent 60%),
    var(--dd-surface);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Phone frame ---------------- */
.app-shell {
  position: relative;
  width: 100%;
  max-width: 412px;
  height: min(880px, calc(100vh - 48px));
  background: var(--dd-white);
  border-radius: 44px;
  box-shadow:
    var(--dd-shadow-lg),
    0 0 0 11px #0b1220,
    0 0 0 13px #1c2740;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@media (max-width: 460px) {
  body { padding: 0; }
  .app-shell { max-width: 100%; height: 100vh; border-radius: 0; box-shadow: none; }
  .statusbar .notch { display: none; }
}

/* Status bar */
.statusbar {
  flex: none;
  height: 46px;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
  color: var(--dd-ink);
  position: relative;
  z-index: 5;
}
.statusbar .notch {
  position: absolute;
  left: 50%; top: 9px;
  transform: translateX(-50%);
  width: 116px; height: 28px;
  background: #0b1220;
  border-radius: 0 0 18px 18px;
}
.statusbar .sb-right { display: flex; gap: 6px; align-items: center; font-size: 13px; }

/* Scroll viewport for screens */
.viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  position: relative;
}
.viewport::-webkit-scrollbar { display: none; }

.screen { padding: 6px 20px 28px; animation: fade .28s ease; }
.screen.has-tabbar { padding-bottom: 96px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- App header ---------------- */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0 14px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { height: 26px; width: auto; display: block; }
.brand .wordmark { font-family: var(--dd-font-display); font-weight: 800; font-size: 19px; letter-spacing: -.3px; }
.brand .wordmark b { color: var(--dd-primary); font-weight: 800; }
.brand .wordmark span { color: var(--dd-ink); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--dd-border);
  background: var(--dd-white);
  color: var(--dd-ink);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: var(--dd-gray-50); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.ghost { border: none; background: transparent; }

.lang-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--dd-border);
  background: var(--dd-white);
  color: var(--dd-primary);
  font-weight: 600; font-size: 14px;
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
}
.lang-pill:hover { background: var(--dd-primary-tint); }

/* ---------------- Typography ---------------- */
.h1 { font-family: var(--dd-font-display); font-weight: 800; font-size: 28px; letter-spacing: -.6px; line-height: 1.15; color: var(--dd-ink); }
.h2 { font-family: var(--dd-font-display); font-weight: 700; font-size: 20px; letter-spacing: -.3px; color: var(--dd-ink); }
.sub { color: var(--dd-gray-600); font-size: 15px; margin-top: 6px; line-height: 1.45; }
.section-title { font-family: var(--dd-font-display); font-weight: 700; font-size: 17px; color: var(--dd-ink); }
.muted { color: var(--dd-gray-600); }
.center { text-align: center; }

/* ---------------- Buttons ---------------- */
.btn {
  width: 100%;
  border: none; cursor: pointer;
  font-family: var(--dd-font-text);
  font-weight: 600; font-size: 16px;
  padding: 15px 18px;
  border-radius: var(--dd-radius);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .1s, background .15s, box-shadow .15s;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--dd-primary); color: var(--dd-on-primary); box-shadow: 0 8px 20px rgba(30,116,244,.28); }
.btn-primary:hover { background: var(--dd-primary-hover); }
.btn-outline { background: var(--dd-white); color: var(--dd-ink); border: 1.5px solid var(--dd-border); }
.btn-outline:hover { border-color: var(--dd-primary-light); color: var(--dd-primary); }
.btn-sm { padding: 11px 14px; font-size: 14px; border-radius: 12px; width: auto; }

/* ---------------- Search field ---------------- */
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--dd-white);
  border: 1px solid var(--dd-border);
  border-radius: var(--dd-radius);
  padding: 13px 15px;
  color: var(--dd-gray-600);
  font-size: 15px;
}
.search svg { color: var(--dd-gray-400); flex: none; }
.search input {
  flex: 1; min-width: 0;
  border: none; background: transparent; outline: none;
  font-family: var(--dd-font-text); font-size: 15px; color: var(--dd-ink);
}
.search input::placeholder { color: var(--dd-gray-400); }

/* ---------------- Cards ---------------- */
.card {
  background: var(--dd-white);
  border: 1px solid var(--dd-border);
  border-radius: var(--dd-radius-lg);
  box-shadow: var(--dd-shadow);
}
.list-card { padding: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* ---------------- Food thumb / photo ---------------- */
.thumb {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  flex: none;
  display: grid; place-items: center;
  background-size: cover; background-position: center;
}
.thumb .ph { font-size: 26px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb.sm { width: 60px; height: 60px; }
.thumb.md { width: 76px; height: 76px; }
.thumb.lg { width: 100%; height: 200px; border-radius: 18px; }
.thumb.lg .ph { font-size: 64px; }

/* ---------------- Chips / tags ---------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  background: var(--dd-gray-100); color: var(--dd-gray-600);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip-veg    { background: #E7F7EE; color: var(--dd-success); }
.chip-nonveg { background: #FDEAEA; color: var(--dd-danger); }
.chip-spice  { background: #FCEFE0; color: #C77A1A; }
.chip-soft   { background: var(--dd-primary-tint); color: var(--dd-primary); }
.chip-cuisine{ background: var(--dd-gray-100); color: var(--dd-ink-soft); }

/* filter row (scrollable) */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600;
  padding: 8px 13px; border-radius: 999px;
  border: 1px solid var(--dd-border); background: var(--dd-white); color: var(--dd-gray-600);
  display: inline-flex; align-items: center; gap: 5px;
}
.filter.active { background: var(--dd-primary); color: #fff; border-color: var(--dd-primary); }

/* ---------------- Toggle switch ---------------- */
.switch { position: relative; width: 46px; height: 28px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--dd-gray-200); transition: background .2s; pointer-events: none;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s; pointer-events: none;
}
.switch input:checked ~ .track { background: var(--dd-primary); }
.switch input:checked ~ .knob { transform: translateX(18px); }

/* ---------------- Watson tip ---------------- */
.watson {
  display: flex; gap: 12px; align-items: center;
  background: var(--dd-primary-tint);
  border: 1px solid color-mix(in srgb, var(--dd-primary) 18%, transparent);
  border-radius: 16px; padding: 12px 14px;
}
.watson img { width: 40px; height: 40px; flex: none; object-fit: contain; }
.watson .txt { font-size: 13.5px; color: var(--dd-ink-soft); line-height: 1.4; }
.watson .txt b { color: var(--dd-primary); }

/* ---------------- List item (dish row) ---------------- */
.dish-row { display: flex; gap: 13px; padding: 12px; border-radius: 16px; cursor: pointer; transition: background .15s; align-items: center; }
.dish-row:hover { background: var(--dd-gray-50); }
.dish-row .title { font-weight: 700; font-size: 15.5px; color: var(--dd-ink); }
.dish-row .desc { font-size: 13px; color: var(--dd-gray-600); margin-top: 2px; line-height: 1.35; }
.dish-row .meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
.price { font-family: var(--dd-font-display); font-weight: 700; color: var(--dd-ink); }
.kcal { font-size: 12px; color: var(--dd-gray-600); }
.divider { height: 1px; background: var(--dd-border); margin: 2px 12px; }

.link { color: var(--dd-primary); font-weight: 600; font-size: 14px; cursor: pointer; background: none; border: none; }
.link:hover { text-decoration: underline; }

/* info rows (dish detail) */
.info-row { display: flex; align-items: flex-start; gap: 12px; padding: 15px 4px; cursor: default; }
.info-row .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--dd-primary-tint); color: var(--dd-primary); display: grid; place-items: center; flex: none; }
.info-row .k { font-weight: 700; font-size: 14.5px; }
.info-row .v { font-size: 13.5px; color: var(--dd-gray-600); margin-top: 3px; line-height: 1.45; }

.note {
  display: flex; gap: 8px; align-items: center;
  font-size: 12.5px; color: var(--dd-gray-600);
  background: var(--dd-gray-50); border: 1px solid var(--dd-border);
  padding: 9px 12px; border-radius: 10px;
}
.note svg { flex: none; color: var(--dd-primary); }

/* calorie stat block */
.kcal-card { background: var(--dd-primary-tint); border-radius: 18px; padding: 16px; }
.kcal-big { font-family: var(--dd-font-display); font-weight: 800; font-size: 34px; color: var(--dd-primary); line-height: 1; }
.macros { display: flex; gap: 8px; margin-top: 14px; }
.macro { flex: 1; background: #fff; border-radius: 12px; padding: 10px; text-align: center; }
.macro .ml { font-size: 11px; color: var(--dd-gray-600); }
.macro .mv { font-weight: 700; font-size: 13.5px; margin-top: 2px; }
.confbars { display: inline-flex; gap: 3px; }
.confbars i { width: 5px; height: 13px; border-radius: 2px; background: var(--dd-gray-200); display: inline-block; }
.confbars i.on { background: var(--dd-primary); }

/* ingredient pills */
.pills { display: flex; flex-wrap: wrap; gap: 7px; }
.pill { font-size: 12.5px; padding: 6px 11px; border-radius: 999px; background: var(--dd-gray-100); color: var(--dd-ink-soft); font-weight: 500; }

/* ---------------- Sticky bottom action ---------------- */
.sticky-action {
  position: sticky; bottom: 0;
  margin: 18px -20px -28px;
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--dd-white) 72%, transparent);
}

/* ---------------- Tab bar ---------------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 78px;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--dd-border);
  display: flex; align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--dd-gray-400); font-size: 11px; font-weight: 600;
  transition: color .15s;
}
.tab.active { color: var(--dd-primary); }
.tab svg { width: 23px; height: 23px; }

/* scan camera screen */
.viewfinder {
  position: relative; border-radius: 22px; overflow: hidden;
  background: linear-gradient(135deg,#2a2f45,#0b1220);
  aspect-ratio: 3/4; display: grid; place-items: center; color: #fff;
}
.viewfinder .menu-paper {
  width: 78%; background: #f3ece0; color: #2c2418; border-radius: 8px;
  padding: 16px 16px; font-size: 11px; box-shadow: 0 12px 30px rgba(0,0,0,.4); transform: rotate(-1deg);
}
.menu-paper h4 { font-family: var(--dd-font-display); text-align: center; font-size: 13px; margin-bottom: 10px; letter-spacing: .5px; }
.menu-paper .mi { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed #cdbfa6; }
.menu-paper .mi span:first-child { font-weight: 600; }
.corner { position: absolute; width: 30px; height: 30px; border: 3px solid var(--dd-primary-light); }
.corner.tl { top: 18px; left: 18px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.corner.tr { top: 18px; right: 18px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.corner.bl { bottom: 18px; left: 18px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.corner.br { bottom: 18px; right: 18px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }
.scanline { position: absolute; left: 8%; right: 8%; height: 2px; background: var(--dd-primary-light); box-shadow: 0 0 12px 2px var(--dd-primary-light); animation: scan 2.4s ease-in-out infinite; }
@keyframes scan { 0%,100% { top: 22%; } 50% { top: 78%; } }

/* live camera + captured frame */
.viewfinder video, .viewfinder .cam-shot {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0;
  background: #0b1220;
}
.shutter {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: 62px; height: 62px; border-radius: 50%; cursor: pointer; z-index: 3;
  background: #fff; border: 4px solid rgba(255,255,255,.55);
  box-shadow: 0 4px 14px rgba(0,0,0,.35); transition: transform .1s;
}
.shutter:active { transform: translateX(-50%) scale(.92); }
.cam-error {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 24px;
  background: rgba(11,18,32,.55); color: #fff; font-size: 13.5px; backdrop-filter: blur(2px);
}
.scan-source {
  display: flex; align-items: center; gap: 12px;
  background: var(--dd-primary-tint); border: 1px solid var(--dd-border);
  border-radius: 14px; padding: 10px 12px;
}
.scan-source img { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; flex: none; }

.detected-bar {
  background: #fff; border: 1px solid var(--dd-border); border-radius: 18px;
  padding: 12px; box-shadow: var(--dd-shadow); margin-top: -34px; position: relative; z-index: 2;
}
.detected-strip { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.detected-strip::-webkit-scrollbar { display: none; }
.detected-item { flex: none; width: 96px; cursor: pointer; }
.detected-item .thumb { width: 96px; height: 64px; border-radius: 12px; }
.detected-item .nm { font-size: 11.5px; font-weight: 600; margin-top: 5px; line-height: 1.2; }
.detected-item .pr { font-size: 11px; color: var(--dd-gray-600); }

/* table / bill */
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--dd-primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; border: 2px solid #fff; }
.member-tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 4px 0; }
.member-tabs::-webkit-scrollbar { display: none; }
.member-tab { flex: none; display: flex; align-items: center; gap: 7px; padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--dd-border); background: #fff; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.member-tab.active { border-color: var(--dd-primary); background: var(--dd-primary-tint); color: var(--dd-primary); }
.member-tab .avatar { width: 26px; height: 26px; font-size: 11px; border: none; }

.line { display: flex; justify-content: space-between; padding: 9px 0; font-size: 14.5px; }
.line.total { font-family: var(--dd-font-display); font-weight: 800; font-size: 18px; border-top: 1px solid var(--dd-border); margin-top: 4px; padding-top: 13px; }
.line .muted { color: var(--dd-gray-600); }

.banner { display: flex; gap: 11px; padding: 13px; border-radius: 14px; font-size: 13px; line-height: 1.4; }
.banner-info { background: #FFF6E8; border: 1px solid #F4DDB0; color: #8a5a12; }
.banner-info b { color: #6b4509; }
.banner-info svg { color: var(--dd-warning); flex: none; }
.banner-danger { background: #FDEAEA; border: 1px solid #F3C0C2; color: #9b2c2f; font-weight: 600; }
.banner-danger svg { color: var(--dd-danger); flex: none; }
.banner .bic { flex: none; color: var(--dd-warning); }

.tip-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.tip-opt { border: 1.5px solid var(--dd-border); background: #fff; border-radius: 12px; padding: 11px 6px; text-align: center; cursor: pointer; }
.tip-opt.active { border-color: var(--dd-primary); background: var(--dd-primary-tint); }
.tip-opt .tt { font-weight: 700; font-size: 14px; color: var(--dd-ink); }
.tip-opt .ts { font-size: 10.5px; color: var(--dd-gray-600); margin-top: 2px; }

.split-box { background: var(--dd-primary-tint); border-radius: 14px; padding: 14px; display: flex; justify-content: space-between; align-items: center; }
.split-box .perhead { font-family: var(--dd-font-display); font-weight: 800; font-size: 22px; color: var(--dd-primary); }

/* discovery */
.disco-card { padding: 12px; display: flex; gap: 12px; cursor: pointer; }
.disco-feature { overflow: hidden; }
.disco-feature .hero { height: 130px; }
.badge { position: absolute; top: 8px; left: 8px; background: rgba(11,18,32,.78); color: #fff; font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.badge.live { background: var(--dd-success); display: inline-flex; align-items: center; gap: 4px; position: static; }
.stars { color: var(--dd-accent-gold); font-weight: 700; font-size: 13px; }

.feat-pad { padding: 14px; }

/* onboarding language list */
.lang-item { display: flex; align-items: center; gap: 13px; padding: 13px 14px; border-radius: 14px; cursor: pointer; border: 1.5px solid transparent; }
.lang-item:hover { background: var(--dd-gray-50); }
.lang-item.active { border-color: var(--dd-primary); background: var(--dd-primary-tint); }
.lang-item .flag { font-size: 24px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 1px solid var(--dd-border); }
.lang-item .lname { font-weight: 600; font-size: 15px; }
.lang-item .lnat { font-size: 12.5px; color: var(--dd-gray-600); }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--dd-gray-200); flex: none; display: grid; place-items: center; }
.lang-item.active .radio { border-color: var(--dd-primary); background: var(--dd-primary); color: #fff; }

/* misc */
.spacer { height: 16px; }
.health-card { display: flex; gap: 12px; align-items: center; padding: 14px; }
.health-card .hic { width: 38px; height: 38px; border-radius: 10px; background: #E7F7EE; color: var(--dd-success); display: grid; place-items: center; flex: none; }
.opt-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.opt-row .oic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.tap { cursor: pointer; }
.fav { color: var(--dd-gray-400); cursor: pointer; }
.fav.on { color: var(--dd-primary); }
.toast {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: var(--dd-ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .3s; z-index: 50; box-shadow: var(--dd-shadow-lg); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Loading overlay ---------------- */
.loading-overlay {
  position: absolute; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: rgba(245,248,252,.86); backdrop-filter: blur(3px);
  color: var(--dd-ink); font-weight: 600; font-size: 14.5px; text-align: center; padding: 24px;
}
.loading-overlay[hidden] { display: none; }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid var(--dd-primary-tint); border-top-color: var(--dd-primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- RTL (Arabic) ---------------- */
[dir="rtl"] .switch .knob { left: auto; right: 3px; }
[dir="rtl"] .switch input:checked ~ .knob { transform: translateX(-18px); }
[dir="rtl"] .back-btn svg { transform: scaleX(-1); }
[dir="rtl"] .dish-row > svg,
[dir="rtl"] .opt-row > svg,
[dir="rtl"] .info-row > svg,
[dir="rtl"] .disco-card > svg,
[dir="rtl"] .link svg { transform: scaleX(-1); }
[dir="rtl"] .scanline { animation: none; }
