/* PeoplesMart Producer PWA — light, low-bandwidth, thumb-friendly. */

:root {
  --brand: #14532d;
  --brand-light: #166534;
  --accent: #b45309;
  --danger: #b91c1c;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --surface: #ffffff;
  --canvas: #f9fafb;
  --radius: 10px;
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari",
    "Noto Sans Telugu", "Noto Sans Tamil", "Noto Sans Bengali", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background: var(--surface);
  padding: 0.5rem 1rem;
  z-index: 100;
}

/* ---------------------------------------------------------------- banners */

.banner {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  text-align: center;
}

.banner[hidden] {
  display: none;
}

.banner-offline {
  background: #fef3c7;
  color: #78350f;
}

.banner-pending {
  background: #dbeafe;
  color: #1e3a8a;
}

/* ---------------------------------------------------------------- header */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--brand);
  color: #fff;
  padding: 0.75rem 1rem 0.6rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.header-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 0.2rem;
}

#locale-select {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
  min-height: 36px;
}

#locale-select option {
  color: var(--ink);
}

/* ---------------------------------------------------------------- layout */

main {
  padding: 1rem;
  max-width: 640px;
  margin: 0 auto;
}

.view[hidden] {
  display: none;
}

h2 {
  font-size: 1.15rem;
  margin: 0.25rem 0 0.75rem;
}

h3 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0.9rem;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.error {
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

.error[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- forms */

form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.7rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 1px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 0.75rem 0 0;
  background: var(--surface);
}

legend {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0 0.35rem;
}

.btn {
  min-height: var(--tap);
  padding: 0.7rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-top: 0.75rem;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:active {
  background: var(--brand-light);
}

.btn-secondary {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--brand);
  margin-top: 0.4rem;
}

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-button {
  background: none;
  border: none;
  color: inherit;
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
  padding: 0.35rem;
  min-height: 36px;
}

/* ---------------------------------------------------------------- tabs */

.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar[hidden] {
  display: none;
}

.tab {
  flex: 1;
  min-height: 56px;
  padding: 0.5rem 0.25rem;
  background: none;
  border: none;
  border-top: 3px solid transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  color: var(--brand);
  border-top-color: var(--brand);
  background: #f0fdf4;
}

/* ---------------------------------------------------------------- cards */

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  white-space: nowrap;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-accepted { background: #dbeafe; color: #1e40af; }
.badge-packed { background: #e0e7ff; color: #3730a3; }
.badge-shipped { background: #d1fae5; color: #065f46; }
.badge-low { background: #fee2e2; color: #991b1b; }
.badge-queued { background: #fef3c7; color: #92400e; }
.badge-failed { background: #fee2e2; color: #991b1b; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.card-actions .btn {
  flex: 1 1 auto;
  margin-top: 0;
}

.stock-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.stock-row input {
  width: 5.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stock-row .btn {
  margin-top: 0;
  min-height: 42px;
  padding: 0 0.9rem;
}

.balance {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin: 0 0 1rem;
}

.balance strong {
  font-size: 1.35rem;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- photo queue */

.photo-queue {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.photo-queue li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.photo-queue .thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex: none;
}

.photo-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 50;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.toast[hidden] {
  display: none;
}

.toast.toast-error {
  background: var(--danger);
  color: #fff;
}

/* ---------------------------------------------------------------- large text */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media (min-width: 640px) {
  body {
    font-size: 16px;
  }
  .tabbar {
    position: static;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    margin: 0 0 1rem;
  }
}
