/* =========================================================================
   Toniva — global styles
   Brand palette, no gradients, mobile-first, Kilimall-style layout.
   ========================================================================= */

:root {
  --sky: #0B95EF;
  --sky-dark: #0a7fc9;
  --navy: #001850;
  --navy-soft: #33425c;
  --orange: #FF9D00;
  --orange-dark: #e88c00;
  --teal: #00A8A8;
  --green: #70B030;
  --pink: #E03078;
  --purple: #7838D0;
  --bg: #FFFFFF;
  --bg-soft: #F4F7FB;
  --bg-card: #FFFFFF;
  --line: #E6EAF0;
  --muted: #6b7889;
  --danger: #d93025;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,24,80,.06), 0 1px 3px rgba(0,24,80,.05);
  --shadow: 0 4px 14px rgba(0,24,80,.08);
  --shadow-lg: 0 12px 30px rgba(0,24,80,.12);
  --maxw: 1180px;
  --header-h: 132px;
  --bottomnav-h: 62px;
  --font: "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--navy);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
}
img { max-width: 100%; display: block; }
a { color: var(--sky); text-decoration: none; }
a:hover { color: var(--sky-dark); }
h1,h2,h3,h4 { color: var(--navy); margin: 0 0 .4em; line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 11px 18px; font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  text-decoration: none; line-height: 1; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--sky); color: #fff; }
.btn-primary:hover { background: var(--sky-dark); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-dark); color: #fff; }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--navy); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f3c2be; }
.btn-danger:hover { background: #fdecea; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--sky);
  color: #fff;
  box-shadow: var(--shadow);
}
.header-top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; max-width: var(--maxw); margin: 0 auto;
}
.brand {
  display: inline-flex; align-items: center; flex-shrink: 0;
  height: 100%; text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  height: 100%;
  width: auto;
  max-height: 40px;
  display: block;
  border-radius: 6px;
}
.brand:hover .brand-logo { opacity: .92; }
.footer-brand { display: flex; flex-direction: column; gap: 10px; }
.footer-brand .brand-logo-footer { max-height: 52px; }

.search-bar {
  flex: 1; display: flex; background: #fff; border-radius: var(--radius-sm);
  overflow: visible; min-width: 0; box-shadow: var(--shadow-sm); position: relative;
}
.search-bar select {
  border: 0; background: var(--bg-soft); color: var(--navy);
  padding: 0 24px 0 10px; font-size: .85rem; max-width: 130px; border-right: 1px solid var(--line);
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23001850' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  cursor: pointer; flex-shrink: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.search-bar input {
  flex: 1; min-width: 0; border: 0; padding: 11px 12px; font-size: .95rem; color: var(--navy);
  outline: none;
}
.search-bar button {
  border: 0; background: var(--orange); color: #fff; padding: 0 16px; font-weight: 700; cursor: pointer;
  font-size: 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.search-bar button:hover { background: var(--orange-dark); }

/* ---------- Live search dropdown ---------- */
.live-search {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: #fff; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow); max-height: 70vh; overflow-y: auto;
  border: 1px solid var(--line); border-top: 0;
}
.ls-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  text-decoration: none; color: var(--navy); border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.ls-item:hover { background: var(--bg-soft); }
.ls-item:last-child { border-bottom: 0; }
.ls-thumb { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: var(--bg-soft); display: grid; place-items: center; }
.ls-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ls-noimg { color: var(--muted); font-size: 1.1rem; }
.ls-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ls-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-price { font-size: .8rem; color: var(--sky); font-weight: 700; display: flex; gap: 8px; align-items: center; }
.ls-out { color: var(--muted); font-weight: 600; font-size: .72rem; }
.ls-empty { padding: 16px; text-align: center; color: var(--muted); font-size: .85rem; }

/* Font Awesome icon sizing in UI chrome */
.icon-btn i { font-size: .95rem; }
.bottom-nav .ico i { font-size: 1.25rem; }
.btn i { font-size: .9em; }
.btn.btn-sm i { font-size: .85em; }
.promo-icon .emoji i { font-size: 1.3rem; }
.empty-state .big i { font-size: 3rem; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  color: #fff; background: rgba(255,255,255,.14); border: 0; border-radius: 999px;
  padding: 8px 12px; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.24); color: #fff; }
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px; background: var(--orange); color: #fff;
  font-size: .68rem; min-width: 17px; height: 17px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 4px; font-weight: 700;
}

/* category tab strip */
.cat-strip {
  background: #fff; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.cat-strip::-webkit-scrollbar { display: none; }
.cat-strip .inner { display: inline-flex; gap: 4px; padding: 8px 14px; max-width: var(--maxw); }
.cat-strip a {
  color: var(--navy-soft); font-weight: 600; font-size: .85rem; padding: 7px 13px;
  border-radius: 999px; white-space: nowrap; transition: background .15s, color .15s;
}
.cat-strip a:hover { background: var(--bg-soft); color: var(--navy); }
.cat-strip a.active { background: var(--sky); color: #fff; }

/* ---------- Promo icon row ---------- */
.promo-icons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 14px 0 4px; }
.promo-icon {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; padding: 12px 6px; background: var(--bg-card);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); color: var(--navy);
  font-size: .76rem; font-weight: 600;
}
.promo-icon .emoji {
  width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.5rem; color: #fff;
}
.promo-icon:hover { box-shadow: var(--shadow); transform: translateY(-2px); transition: .15s; }

/* ---------- Promo grid ---------- */
.section { padding: 18px 0; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.section-head h2 { margin: 0; font-size: 1.15rem; }
.section-head a { font-size: .85rem; font-weight: 600; }
.promo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.promo-card {
  border-radius: var(--radius); padding: 18px 14px; color: #fff; min-height: 120px;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow-sm);
}
.promo-card h3 { color: #fff; font-size: 1.05rem; margin: 0; }
.promo-card p { margin: 4px 0 0; font-size: .8rem; opacity: .95; }
.promo-card .tag {
  align-self: flex-start; background: rgba(255,255,255,.22); padding: 4px 10px;
  border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .3px;
}

/* ---------- Product cards ---------- */
.product-row {
  display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none;
  padding: 4px 2px 10px; margin: 0 -2px; scroll-snap-type: x mandatory;
}
.product-row::-webkit-scrollbar { display: none; }
.product-row > * { scroll-snap-align: start; flex: 0 0 auto; width: 150px; }

.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.product-card {
  background: var(--bg-card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; position: relative;
  transition: box-shadow .15s, transform .15s;
}
.product-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.product-card .thumb {
  aspect-ratio: 1/1; background: var(--bg-soft); display: grid; place-items: center;
  font-size: 3rem; position: relative; overflow: hidden;
}
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-card .thumb .pct { position: absolute; top: 8px; left: 8px; }
.product-card .body { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card .name {
  font-size: .85rem; font-weight: 600; color: var(--navy); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.2em;
}
.product-card .price { font-size: 1rem; font-weight: 800; color: var(--navy); }
.product-card .compare { font-size: .76rem; color: var(--muted); text-decoration: line-through; }
.product-card .add-btn {
  margin-top: 6px; background: var(--sky); color: #fff; border: 0; border-radius: 8px;
  padding: 8px; font-weight: 700; cursor: pointer; font-size: .82rem;
}
.product-card .add-btn:hover { background: var(--sky-dark); }

/* badges */
.badge-pill {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px;
  font-size: .68rem; font-weight: 700; letter-spacing: .3px;
}
.badge-sale { background: var(--orange); color: #fff; }
.badge-new { background: var(--green); color: #fff; }
.badge-hot { background: var(--pink); color: #fff; }
.badge-stock-out { background: #eef1f6; color: var(--muted); }
.pct { background: var(--orange); color: #fff; font-weight: 700; font-size: .7rem;
  padding: 3px 7px; border-radius: 6px; }

/* ---------- Bottom mobile nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 16px rgba(0,24,80,.06);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: .68rem; font-weight: 600; position: relative;
}
.bottom-nav a .ico { font-size: 1.3rem; line-height: 1; }
.bottom-nav a.active { color: var(--sky); }
.bottom-nav a .badge {
  position: absolute; top: 4px; left: 50%; margin-left: 8px; background: var(--orange);
  color: #fff; font-size: .62rem; min-width: 15px; height: 15px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 3px; font-weight: 700;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 5px; color: var(--navy); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; font-size: .95rem; color: var(--navy); background: #fff; outline: none;
  transition: border .15s, box-shadow .15s; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--sky); box-shadow: 0 0 0 3px rgba(11,149,239,.15);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.field .err { font-size: .8rem; color: var(--danger); margin-top: 4px; }

.card {
  background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px;
}
.card + .card { margin-top: 14px; }

/* ---------- Flash messages ---------- */
.flash { border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 14px; font-size: .9rem; font-weight: 500; }
.flash.success { background: #e9f7e9; color: #1e7a32; border: 1px solid #bfe6c4; }
.flash.error { background: #fdecea; color: #b3261e; border: 1px solid #f3c2be; }
.flash.info { background: #e8f3ff; color: #0a5fa8; border: 1px solid #c4e1fb; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.table tr:hover td { background: var(--bg-soft); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--navy); color: #c7d2e3; padding: 30px 0 24px; margin-top: 30px; font-size: .85rem;
}
.site-footer h4 { color: #fff; font-size: .95rem; margin-bottom: 10px; }
.site-footer a { color: #c7d2e3; }
.site-footer a:hover { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); margin-top: 22px; padding-top: 14px; font-size: .78rem; color: #93a3bd; }

/* ---------- Admin layout ---------- */
.admin-shell { display: grid; grid-template-columns: 1fr; gap: 14px; padding: 14px 0; }
.admin-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav a {
  padding: 9px 14px; border-radius: 999px; background: var(--bg-soft); color: var(--navy);
  font-weight: 600; font-size: .85rem; white-space: nowrap;
}
.admin-nav a.active, .admin-nav a:hover { background: var(--sky); color: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-card { background: var(--bg-card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.stat-card .num { font-size: 1.6rem; font-weight: 800; color: var(--navy); }
.stat-card .lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }

/* ---------- Utilities ---------- */
.row { display: flex; gap: 12px; }
.col { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mt0 { margin-top: 0; } .mt1 { margin-top: 8px; } .mt2 { margin-top: 16px; }
.mb0 { margin-bottom: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .big { font-size: 3rem; margin-bottom: 8px; }
.hide { display: none !important; }

/* ---------- Responsive (tablet+) ---------- */
@media (min-width: 600px) {
  :root { --header-h: 64px; }
  body { font-size: 16px; }
  .promo-icons { grid-template-columns: repeat(8, 1fr); }
  .promo-grid { grid-template-columns: repeat(4, 1fr); }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .product-row > * { width: 180px; }
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  h1 { font-size: 1.8rem; }
}

@media (min-width: 900px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
  .product-row > * { width: 210px; }
  .bottom-nav { display: none; }
  body { padding-bottom: 0; }
  .header-actions .label { display: inline; }
  .cat-strip { position: sticky; top: var(--header-h); z-index: 49; }
  .admin-shell { grid-template-columns: 220px 1fr; }
  .admin-nav { flex-direction: column; overflow: visible; }
  .admin-nav a { white-space: normal; }
}

@media (min-width: 1100px) {
  .product-grid { grid-template-columns: repeat(5, 1fr); }
}

/* hide labels on tiny screens */
@media (max-width: 420px) {
  .header-actions .label { display: none; }
  .icon-btn { padding: 8px 10px; }
  .brand-logo { max-height: 32px; }
  .footer-brand .brand-logo-footer { max-height: 40px; }
}

/* ---------- Mobile header: search bar on its own row ---------- */
@media (max-width: 899px) {
  .site-header {
    transition: transform .25s ease;
  }
  .site-header.hide-up { transform: translateY(-100%); }
}
@media (max-width: 599px) {
  .header-top {
    flex-wrap: wrap; gap: 8px; padding: 8px 12px;
  }
  .search-bar {
    flex: 1 1 100%; order: 3;
  }
  .brand { order: 1; }
  .header-actions { order: 2; margin-left: auto; }
  .search-bar select { max-width: 110px; }
}
