/* ===================================================
   AbuelaTienda — charte ergonomique pour senior
   Tailles minimales : police 20px+, boutons 100px+,
   contraste élevé, aucune icône seule.
   =================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #ffffff;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 22px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

#app {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  overflow: hidden;
}

.screen[hidden] { display: none; }

/* ================= TOPBAR ================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #f4f4f4;
  border-bottom: 3px solid #d0d0d0;
  min-height: 88px;
}

.topbar__title {
  font-size: 30px;
  font-weight: 700;
  flex: 1;
  text-align: center;
}

.topbar__rate {
  font-size: 22px;
  font-weight: 600;
  color: #005c99;
  background: #e6f2fa;
  padding: 10px 16px;
  border-radius: 12px;
}

.back-btn {
  min-width: 130px;
  min-height: 72px;
  padding: 0 24px;
  font-size: 24px;
  font-weight: 700;
  background: #ffffff;
  border: 3px solid #1a1a1a;
  border-radius: 14px;
}

.back-btn:active { background: #e8e8e8; }

.add-btn {
  min-width: 130px;
  min-height: 72px;
  padding: 0 20px;
  font-size: 24px;
  font-weight: 700;
  background: #1f8a3e;
  color: #ffffff;
  border-radius: 14px;
}
.add-btn:active { background: #176a2f; }

.topbar--home {
  background: #1a1a1a;
  color: #ffffff;
  border-bottom: none;
  justify-content: space-between;
  min-height: 96px;
}

.brand {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #1f8a3e;
  vertical-align: middle;
  transition: background 0.2s;
}
.sync-dot--saving  { background: #d97706; animation: pulse 1s infinite; }
.sync-dot--offline { background: #c62828; }
.sync-dot--error   { background: #c62828; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.rate-badge {
  background: #ffcf3f;
  color: #1a1a1a;
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.rate-badge__label { font-size: 18px; }
.rate-badge__value { font-size: 30px; }
.rate-badge__unit { font-size: 18px; }

/* ================= HOME ================= */
.home-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 20px;
  padding: 24px;
}

.home-tile {
  border-radius: 24px;
  color: #ffffff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  transition: transform 0.05s ease;
}
.home-tile:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }

.home-tile__title {
  font-size: 44px;
  font-weight: 800;
}
.home-tile__hint {
  font-size: 20px;
  opacity: 0.95;
}

.home-tile--sell     { background: #1f8a3e; }
.home-tile--products { background: #005c99; }
.home-tile--rate     { background: #d97706; }
.home-tile--report   { background: #6d28d9; }

.home-foot {
  padding: 14px 24px;
  background: #f4f4f4;
  font-size: 18px;
  text-align: center;
  border-top: 2px solid #d0d0d0;
}

/* ================= SELL ================= */
.sell-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  overflow: hidden;
}

.sell-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ================= SEARCH BAR ================= */
.search-bar {
  position: relative;
  padding: 12px 16px 0;
}
.search-bar__input {
  width: 100%;
  min-height: 68px;
  border: 3px solid #1a1a1a;
  border-radius: 14px;
  padding: 10px 60px 10px 20px;
  font-size: 24px;
  font-weight: 600;
  background: #fff;
  font-family: inherit;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.search-bar__input:focus { outline: 3px solid #005c99; }
.search-bar__input::-webkit-search-cancel-button,
.search-bar__input::-webkit-search-decoration { display: none; }

.search-bar__clear {
  position: absolute;
  right: 22px;
  top: 12px;
  min-width: 60px;
  min-height: 68px;
  padding: 0 12px;
  font-size: 28px;
  font-weight: 800;
  color: #c62828;
  background: transparent;
  border-radius: 12px;
}
.search-bar__clear:active { background: #ffe1e1; }

.empty-search {
  padding: 30px 20px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #666;
}

.product-grid {
  padding: 16px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  align-content: start;
  flex: 1;
}

.product-card {
  position: relative;
  background: #ffffff;
  border: 3px solid #d0d0d0;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 170px;
  transition: transform 0.05s ease;
}
.product-card:active { transform: scale(0.97); background: #f4f4f4; }

.product-card__photo {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.product-card__name {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  min-height: 46px;
  display: flex;
  align-items: center;
}

.product-card__price {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.product-card__price-usd {
  font-size: 24px;
  font-weight: 800;
  color: #1a1a1a;
}
.product-card__price-bs {
  font-size: 18px;
  font-weight: 700;
  color: #005c99;
}

.product-card__badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #c62828;
  color: white;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
}

.product-card--out {
  opacity: 0.45;
}

/* Ticket */
.ticket {
  background: #fafafa;
  border-left: 3px solid #d0d0d0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
}
.ticket__title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
}
.ticket__list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 2px solid #e0e0e0;
}
.ticket__empty {
  padding: 20px 8px;
  color: #666;
  font-size: 18px;
  text-align: center;
}
.ticket__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 4px;
  border-bottom: 1px solid #e6e6e6;
  align-items: center;
}
.ticket__item-name {
  font-size: 18px;
  font-weight: 600;
}
.ticket__item-price {
  grid-column: 1;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.ticket__item-usd { font-size: 20px; font-weight: 800; color: #1a1a1a; }
.ticket__item-bs  { font-size: 18px; font-weight: 700; color: #005c99; }
.ticket__qty {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ticket__qty-btn {
  min-width: 44px;
  min-height: 44px;
  border: 2px solid #1a1a1a;
  border-radius: 10px;
  font-size: 24px;
  font-weight: 700;
  background: #ffffff;
}
.ticket__qty-btn:active { background: #ddd; }
.ticket__qty-value {
  min-width: 32px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
}

.ticket__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 10px;
  border-top: 3px solid #1a1a1a;
  font-size: 22px;
  font-weight: 700;
}
.ticket__total-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.ticket__total-usd { font-size: 34px; font-weight: 800; color: #1a1a1a; }
.ticket__total-bs  { font-size: 22px; font-weight: 700; color: #1f8a3e; }

/* ================= BUTTONS ================= */
.btn {
  min-height: 72px;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 700;
  padding: 14px 20px;
  margin-top: 10px;
  width: 100%;
}

.btn--big {
  min-height: 100px;
  font-size: 28px;
}

.btn--primary {
  background: #005c99;
  color: #ffffff;
}
.btn--primary:active { background: #004070; }
.btn--primary:disabled { background: #b0b0b0; color: #eee; }

.btn--success {
  background: #1f8a3e;
  color: #ffffff;
}
.btn--success:active { background: #176a2f; }
.btn--success:disabled { background: #b0b0b0; color: #eee; }

.btn--warn {
  background: #d97706;
  color: #ffffff;
}
.btn--warn:active { background: #a55a04; }

.btn--ghost {
  background: #ffffff;
  color: #1a1a1a;
  border: 3px solid #1a1a1a;
}
.btn--ghost:active { background: #eee; }

/* ================= PAY ================= */
.pay-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.pay-summary {
  background: #f4f4f4;
  border-radius: 16px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pay-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 22px;
}
.pay-summary__due-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.pay-summary__due-usd { font-size: 34px; font-weight: 800; color: #1a1a1a; }
.pay-summary__due-bs  { font-size: 24px; font-weight: 700; color: #005c99; }

.pay-summary__received { font-size: 30px; font-weight: 700; }

.pay-summary__row--change {
  border-top: 2px solid #d0d0d0;
  padding-top: 10px;
  margin-top: 6px;
}
.pay-summary__change-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.pay-summary__change     { font-size: 36px; font-weight: 800; color: #1f8a3e; }
.pay-summary__change-alt { font-size: 22px; font-weight: 700; color: #666; }
.pay-summary__change--neg     { color: #c62828; }
.pay-summary__change-alt--neg { color: #c62828; }

/* Currency selector */
.pay-ccy {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  flex-wrap: wrap;
}
.pay-ccy__label { font-size: 20px; font-weight: 700; }
.pay-ccy__btn {
  min-height: 60px;
  padding: 8px 20px;
  border: 3px solid #1a1a1a;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 700;
  background: #fff;
}
.pay-ccy__btn.is-active {
  background: #1a1a1a;
  color: #fff;
}
.pay-ccy__btn:active { transform: scale(0.98); }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.key {
  min-height: 84px;
  border-radius: 14px;
  background: #ffffff;
  border: 3px solid #1a1a1a;
  font-size: 32px;
  font-weight: 800;
}
.key:active { background: #ddd; }
.key--wide { }
.key--erase { background: #ffe1e1; border-color: #c62828; color: #c62828; }

/* ================= PAID ================= */
.paid-body {
  flex: 1;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  text-align: center;
}
.paid-check {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: #1f8a3e;
  color: #ffffff;
  font-size: 90px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.paid-title {
  font-size: 44px;
  font-weight: 800;
}
.paid-change {
  font-size: 22px;
}
.paid-change__value {
  font-size: 52px;
  font-weight: 800;
  color: #005c99;
  margin-top: 6px;
}
.paid-change__alt {
  font-size: 26px;
  font-weight: 700;
  color: #666;
}

/* ================= PRODUCTS ================= */
.products-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.products-hint {
  background: #fff8e6;
  border: 2px solid #d97706;
  color: #5a3800;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 18px;
  margin-bottom: 14px;
}
.products-hint strong { color: #1f8a3e; }
.product-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.product-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  padding: 14px;
  border: 2px solid #d0d0d0;
  border-radius: 14px;
  align-items: center;
}
.product-row__photo {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.product-row__body { display: flex; flex-direction: column; gap: 4px; }
.product-row__name { font-size: 22px; font-weight: 700; }
.product-row__meta { font-size: 18px; color: #444; }
.product-row__stock {
  font-size: 20px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
  background: #e6f2fa;
  color: #005c99;
}
.product-row__stock--low { background: #ffe1c2; color: #a55a04; }

/* ================= FORM ================= */
.form-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { font-size: 20px; font-weight: 700; }
.field__input {
  min-height: 72px;
  border: 3px solid #1a1a1a;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 26px;
  font-weight: 600;
  background: #fff;
}
.field__input:focus { outline: 3px solid #005c99; }
.field__input--warn { border-color: #c62828; background: #fff5f5; }
.field__hint { font-size: 18px; color: #005c99; font-weight: 600; }
.field__hint--good { color: #1f8a3e; font-weight: 700; }
.field__hint--warn { color: #a55a04; font-weight: 700; }
.field__warn { font-size: 18px; color: #c62828; font-weight: 700; }

/* Product form — coût USD/Bs */
.cost-block {
  border: 2px solid #d0d0d0;
  border-radius: 14px;
  padding: 14px;
  margin: 0;
}
.cost-block .field__label { padding: 0 6px; font-weight: 800; }
.cost-mode { margin-bottom: 12px; }

.sub-field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.sub-field__label { font-size: 18px; font-weight: 700; }

.date-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.date-pills__label { font-size: 18px; font-weight: 700; width: 100%; }
.date-pill {
  min-height: 56px;
  padding: 8px 18px;
  border: 3px solid #1a1a1a;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  background: #fff;
}
.date-pill.is-active { background: #1a1a1a; color: #fff; }
.date-pill:active { transform: scale(0.97); }

.computed-cost {
  margin-top: 12px;
  background: #e8f5eb;
  border: 2px solid #1f8a3e;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 20px;
  font-weight: 700;
  color: #0f5a25;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.computed-cost strong { font-size: 30px; color: #1f8a3e; }

/* ================= RATE ================= */
.rate-body {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}
.rate-big {
  background: #ffcf3f;
  border-radius: 20px;
  padding: 28px;
  text-align: center;
}
.rate-big__label { font-size: 22px; font-weight: 700; }
.rate-big__value { font-size: 72px; font-weight: 900; line-height: 1.05; margin: 6px 0; }
.rate-big__unit { font-size: 22px; font-weight: 700; }
.rate-big--manual { background: #ffb060; }

.rate-meta {
  background: #f4f4f4;
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.manual-rate {
  background: #fff8e6;
  border: 3px solid #d97706;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ================= REPORT ================= */
.report-body {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}
.mood {
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  background: #e8f5eb;
}
.mood--bad { background: #fdecea; }
.mood__face { font-size: 96px; line-height: 1; }
.mood__text { font-size: 24px; font-weight: 700; margin-top: 8px; }

.report-numbers {
  background: #f4f4f4;
  border-radius: 16px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.report-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 22px;
}
.report-row strong { font-size: 28px; }
.report-row--gain strong { color: #1f8a3e; font-size: 32px; }
.report-row--gain.loss strong { color: #c62828; }

.report-detail {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 2px solid #d0d0d0;
}
.report-detail li {
  padding: 12px 4px;
  border-bottom: 1px solid #e6e6e6;
  display: flex;
  justify-content: space-between;
  font-size: 20px;
}

/* ================= TOAST ================= */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #ffffff;
  padding: 16px 24px;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 700;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* ================= RESPONSIVE ================= */
@media (max-width: 800px) {
  .sell-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .ticket {
    border-left: none;
    border-top: 3px solid #d0d0d0;
    max-height: 45vh;
  }
  .home-grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
  }
  .home-tile__title { font-size: 36px; }
}
