/* ---------------------------------------------------------------------------
   medly.css — the app's design system, as CSS.

   Every value here is copied from medly_app/lib/app/theme/ so the website and
   the Android app are the same product rather than two that look similar. If a
   token changes in the app, change it here; do not invent a new one.

     colours  : app_colors.dart
     radius   : app_tokens.dart  AppRadius
     spacing  : app_tokens.dart  AppSpacing
     type     : app_typography.dart  AppText

   The app's brand note applies here too: the master plan proposes #0057B8, but
   both shipping apps, the store listing and the icon use emerald #059669.
   Emerald stands.
 --------------------------------------------------------------------------- */

:root {
  /* brand */
  --emerald:      #059669;
  --emerald-dark: #047857;
  --emerald-soft: #ECFDF5;
  --on-primary:   #FFFFFF;

  /* surfaces */
  --bg:           #F7F9FC;
  --surface:      #FFFFFF;
  --surface-muted:#F2F4F7;

  /* text */
  --text:         #172033;
  --text-2:       #667085;
  --text-3:       #98A2B3;

  /* lines */
  --border:       #D0D5DD;
  --divider:      #EAECF0;

  /* status */
  --success:      #16A34A;
  --success-soft: #DCFCE7;
  --warning:      #F59E0B;
  --warning-soft: #FEF3C7;
  --error:        #EF4444;
  --error-soft:   #FEE4E2;
  --info:         #2E90FA;
  --info-soft:    #D1E9FF;
  --skeleton:     #E8ECF2;

  /* radius — AppRadius */
  --r-sm: 8px;  --r-md: 12px; --r-input: 14px; --r-btn: 16px;
  --r-card: 18px; --r-card-lg: 20px; --r-sheet: 28px; --r-pill: 999px;

  /* spacing — AppSpacing */
  --s-xs: 4px; --s-sm: 8px; --s-md: 12px; --s-lg: 16px;
  --s-xl: 20px; --s-2xl: 24px; --s-3xl: 32px;

  /* type — AppText. The app's scale is phone-sized; a desktop page needs a
     little more, so body steps up from 14 to 15 and headings scale with the
     viewport. The ratios between them are unchanged. */
  --lh: 1.25;
  --t-display: clamp(26px, 2.4vw, 34px);
  --t-h1:      clamp(20px, 1.7vw, 26px);
  --t-h2:      clamp(17px, 1.3vw, 20px);
  --t-h3:      15px;
  --t-body:    15px;
  --t-small:   13px;
  --t-caption: 12px;
  --t-overline:10px;

  --shadow-card: 0 1px 2px rgba(23,32,51,.05), 0 8px 24px rgba(23,32,51,.06);
  --shadow-pop:  0 4px 12px rgba(23,32,51,.08), 0 24px 48px rgba(23,32,51,.10);

  --page: 1240px;
  --header-h: 72px;
}

/* --------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--t-body)/1.55 "Inter", -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul { padding: 0; list-style: none; }

/* Everything interactive is at least 48px, as AppSize.minTouchTarget
   requires. A mouse does not need it; a thumb on a phone does, and this is
   the same catalogue the app shows. */
a.btn, button, .tap { min-height: 48px; }

:focus-visible {
  outline: 2px solid var(--emerald);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.wrap { max-width: var(--page); margin: 0 auto; padding: 0 var(--s-xl); }
.muted { color: var(--text-2); }
.tiny  { font-size: var(--t-caption); color: var(--text-2); }

/* -------------------------------------------------------------- header */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  position: sticky; top: 0; z-index: 40;
}
.top__bar {
  display: flex; align-items: center; gap: var(--s-lg);
  height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--emerald); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand__word { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

.search { flex: 1 1 auto; position: relative; max-width: 620px; }
.search input {
  width: 100%; height: 48px; padding: 0 46px 0 44px;
  background: var(--surface-muted);
  border: 1px solid transparent; border-radius: var(--r-input);
  font-size: var(--t-body);
}
.search input::placeholder { color: var(--text-3); }
.search input:focus {
  background: var(--surface); border-color: var(--emerald); outline: none;
}
.search__icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}

.top__actions { display: flex; align-items: center; gap: var(--s-sm); flex: none; }
.iconbtn {
  display: grid; place-items: center; width: 48px; height: 48px;
  border-radius: var(--r-md); border: 0; background: transparent;
  color: var(--text); cursor: pointer; position: relative;
}
.iconbtn:hover { background: var(--surface-muted); }
.badge {
  position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: var(--r-pill);
  background: var(--emerald); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* nav strip of categories */
.navstrip { border-top: 1px solid var(--divider); }
.navstrip__list {
  display: flex; gap: var(--s-xl); overflow-x: auto;
  scrollbar-width: none; padding: 0;
}
.navstrip__list::-webkit-scrollbar { display: none; }
.navstrip a {
  display: inline-flex; align-items: center; height: 46px;
  font-size: var(--t-small); font-weight: 600; color: var(--text-2);
  white-space: nowrap; border-bottom: 2px solid transparent;
}
.navstrip a:hover, .navstrip a[aria-current="page"] {
  color: var(--emerald); border-bottom-color: var(--emerald);
}

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 22px;            /* AppSize.buttonHeight */
  border: 0; border-radius: var(--r-btn);
  background: var(--emerald); color: var(--on-primary);
  font-size: var(--t-body); font-weight: 700; cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--emerald-dark); }
.btn--ghost {
  background: transparent; color: var(--emerald);
  border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--emerald-soft); border-color: var(--emerald); }
.btn--sm { height: 40px; padding: 0 16px; font-size: var(--t-small); }
.btn--block { width: 100%; }

/* ---------------------------------------------------------------- pieces */
.section { margin: var(--s-3xl) 0; }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-lg); margin-bottom: var(--s-lg);
}
.section__title { font-size: var(--t-h2); font-weight: 700; }
.section__link { font-size: var(--t-small); font-weight: 600; color: var(--emerald); }

.hero {
  border-radius: var(--r-card-lg); overflow: hidden;
  box-shadow: var(--shadow-card); background: var(--surface);
}
.hero img { width: 100%; height: auto; }

/* category tiles — AppSize.tileIcon is 64 in the app */
.tiles {
  display: grid; gap: var(--s-md);
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}
.tile {
  background: var(--surface); border: 1px solid var(--divider);
  border-radius: var(--r-card); padding: var(--s-lg) var(--s-sm);
  text-align: center; transition: border-color .15s ease, transform .15s ease;
}
.tile:hover { border-color: var(--emerald); transform: translateY(-2px); }
.tile__icon {
  width: 64px; height: 64px; margin: 0 auto var(--s-sm);
  border-radius: var(--r-md); background: var(--emerald-soft);
  display: grid; place-items: center; overflow: hidden;
}
.tile__icon img { width: 100%; height: 100%; object-fit: cover; }
.tile__name { font-size: var(--t-small); font-weight: 600; line-height: 1.3; }
.tile__count { font-size: var(--t-overline); color: var(--text-3); margin-top: 2px; }

/* -------------------------------------------------------- product cards */
.grid {
  display: grid; gap: var(--s-lg);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--divider);
  border-radius: var(--r-card); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.card:hover { box-shadow: var(--shadow-card); border-color: var(--border); }
.card__media {
  position: relative; aspect-ratio: 4 / 5;      /* same as the app's card */
  background: var(--surface-muted);
}
.card__media img { width: 100%; height: 100%; object-fit: contain; }
.card__off {
  position: absolute; top: 8px; left: 8px;
  background: var(--error); color: #fff;
  font-size: var(--t-overline); font-weight: 800;
  padding: 3px 7px; border-radius: var(--r-sm);
}
.card__rx {
  position: absolute; top: 8px; right: 8px;
  background: var(--info-soft); color: #08539b;
  font-size: var(--t-overline); font-weight: 800;
  padding: 3px 7px; border-radius: var(--r-sm);
}
.card__body { padding: var(--s-md); display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card__name {
  font-size: var(--t-small); font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__pack {
  font-size: var(--t-overline); font-weight: 600; color: var(--text-2);
  background: var(--surface-muted); border-radius: var(--r-sm);
  padding: 2px 6px; align-self: flex-start;
}
.card__foot {
  margin-top: auto; padding-top: var(--s-sm);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card__price { font-size: var(--t-body); font-weight: 800; }
.card__was { font-size: var(--t-caption); color: var(--text-3); text-decoration: line-through; }
.card__add {
  flex: none; width: 40px; height: 40px; border-radius: var(--r-md);
  border: 0; background: var(--emerald-soft); color: var(--emerald);
  font-size: 20px; font-weight: 700; cursor: pointer; line-height: 1;
}
.card__add:hover { background: var(--emerald); color: #fff; }
.card--out { opacity: .55; }

/* rail — horizontal scroll, like the app's product rails */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: 180px;
  gap: var(--s-lg); overflow-x: auto; padding-bottom: var(--s-sm);
  scroll-snap-type: x proximity;
}
.rail > * { scroll-snap-align: start; }
.rail::-webkit-scrollbar { height: 8px; }
.rail::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 4px; }

/* ------------------------------------------------------------ trust bar */
.trust {
  display: grid; gap: var(--s-lg);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  background: var(--surface); border: 1px solid var(--divider);
  border-radius: var(--r-card); padding: var(--s-xl);
}
.trust__item { display: flex; gap: var(--s-md); align-items: flex-start; }
.trust__icon {
  width: 40px; height: 40px; flex: none; border-radius: var(--r-md);
  background: var(--emerald-soft); color: var(--emerald);
  display: grid; place-items: center;
}
.trust__t { font-size: var(--t-small); font-weight: 700; }
.trust__d { font-size: var(--t-caption); color: var(--text-2); }

/* ----------------------------------------------------------- prescription */
.rxcard {
  display: flex; gap: var(--s-xl); align-items: center; flex-wrap: wrap;
  background: linear-gradient(100deg, var(--emerald-soft), #fff 65%);
  border: 1px solid var(--divider); border-radius: var(--r-card-lg);
  padding: var(--s-2xl);
}
.rxcard__body { flex: 1 1 320px; }
.rxcard h3 { font-size: var(--t-h2); font-weight: 700; margin-bottom: 6px; }
.rxcard p  { font-size: var(--t-small); color: var(--text-2); margin-bottom: var(--s-lg); }

/* ---------------------------------------------------------------- footer */
.foot {
  background: var(--surface); border-top: 1px solid var(--divider);
  margin-top: var(--s-3xl); padding: var(--s-3xl) 0 var(--s-xl);
}
/* Explicit tracks, not auto-fit. A repeat(auto-fit, ...) cannot share a track
   list with an fr unit — the whole declaration is invalid and the browser
   falls back to one column, which is exactly what it did. */
.foot__cols {
  display: grid; gap: var(--s-2xl);
  grid-template-columns: 1.8fr 1fr 1fr 1fr;
}
.foot h4 { font-size: var(--t-small); font-weight: 700; margin-bottom: var(--s-md); }
.foot li { margin-bottom: 8px; font-size: var(--t-small); color: var(--text-2); }
.foot a:hover { color: var(--emerald); }
.foot__legal {
  margin-top: var(--s-2xl); padding-top: var(--s-lg);
  border-top: 1px solid var(--divider);
  display: flex; justify-content: space-between; gap: var(--s-lg);
  flex-wrap: wrap; font-size: var(--t-caption); color: var(--text-2);
}

/* ---------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  :root { --header-h: 64px; }
  .wrap { padding: 0 var(--s-lg); }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .top__bar { flex-wrap: wrap; height: auto; padding: var(--s-md) 0; gap: var(--s-md); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-md); }
  .rail { grid-auto-columns: 150px; }
  .rxcard { padding: var(--s-lg); }
  .foot__cols { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .foot__cols { grid-template-columns: 1fr; }
}
