/* EM Corporation — Postieri (PWA)
   Mobile-first. Pa varësi nga Bootstrap/Metronic. */

:root {
  --green: #198754;
  --green-dark: #12603c;
  --green-soft: #e8f5ee;
  --ink: #14211b;
  --muted: #6b7b73;
  --line: #e3e9e6;
  --bg: #f5f7f6;
  --card: #ffffff;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --warn: #b7791f;
  --warn-soft: #fdf5e5;
  --info: #2b6cb0;
  --info-soft: #e8f1fb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 33, 27, 0.08), 0 1px 2px rgba(20, 33, 27, 0.04);
  --nav-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Duhet para rregullave me display: elementet e fshehura kanë display:flex/grid,
   që përndryshe e mbivendos display:none-in e atributit [hidden]. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  /* Faqja vetë nuk rrëshqet kurrë - rrëshqet vetëm .main brenda saj.
     Kështu shiriti i browser-it nuk fshihet/shfaqet dhe navigimi poshtë
     nuk lëviz e nuk lë hapësirë bosh nën vete. */
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ---------- Layout ---------- */

/* Shell-i: tri shtresa — koka, përmbajtja, navigimi.

   'position: fixed; inset: 0' në vend të 100dvh: në Safari të iPhone-it
   njësitë vh/dvh nuk përputhen me zonën e dukshme kur ka shirit poshtë,
   dhe mbetej një rrip bosh nën navigim. Me inset:0 shell-i përputhet
   saktësisht me viewport-in, sido që të jetë. */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  z-index: 20;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
  padding: calc(var(--safe-top) + 14px) 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(18, 96, 60, 0.18);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar .sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  opacity: 0.85;
}

.topbar .spacer {
  margin-left: auto;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.16);
  border: 0;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.28);
}

/* E vetmja zonë që rrëshqet */
.main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 14px 20px;
}

.screen[hidden] {
  display: none !important;
}

/* ---------- Bottom nav ---------- */

/* Statik në fund të shell-it, jo 'fixed' - nuk lëviz dhe nuk lë hapësirë. */
.nav {
  flex: 0 0 auto;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -1px 10px rgba(20, 33, 27, 0.05);
}

.nav button {
  background: none;
  border: 0;
  min-height: var(--nav-h);
  padding: 8px 1px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  /* Pesë etiketa në ekran të ngushtë - "Manifestet" është më e gjata */
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.nav button svg {
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease-out;
}

.nav button[aria-current="true"] {
  color: var(--green);
}

.nav button[aria-current="true"] svg {
  transform: translateY(-1px);
  stroke-width: 2;
}

/* Rrethim i butë pas ikonës aktive - më i pastër se një vijë e varur sipër */
.nav button[aria-current="true"]::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 27px;
  border-radius: 999px;
  background: var(--green-soft);
  z-index: 0;
}

.nav button svg,
.nav button {
  position: relative;
}

.nav button svg {
  z-index: 1;
}

.nav button:active svg {
  transform: scale(0.92);
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -14px 12px;
  padding: 0 14px 2px;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab[aria-selected="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 2px 8px rgba(25, 135, 84, 0.28);
}

/* Numëruesi si rrethim i vogël, jo thjesht tekst */
.tab .count {
  display: inline-block;
  min-width: 18px;
  margin-left: 3px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.tab[aria-selected="true"] .count {
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  margin-bottom: 10px;
  /* Shirit ngjyre majtas - ngjyra vendoset nga statusi i badge-it brenda */
  border-left: 3px solid var(--line);
  transition: box-shadow 0.15s ease-out;
}

.card:has(.badge.pending) { border-left-color: var(--warn); }
.card:has(.badge.accepted) { border-left-color: var(--info); }
.card:has(.badge.in_warehouse) { border-left-color: var(--green); }
.card:has(.badge.delivering) { border-left-color: #6b46c1; }
.card:has(.badge.delivered) { border-left-color: var(--green-dark); }
.card:has(.badge.rejected),
.card:has(.badge.unaccepted) { border-left-color: var(--danger); }
.card:has(.badge.returned) { border-left-color: var(--warn); }
.card:has(.badge.uploaded) { border-left-color: var(--info); }

.order-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}

.order-no {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.02em;
}

/* Kartat përmbledhëse (shpenzimet) */
.sum-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.sum-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sum-k {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.sum-v {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.sum-v.ok {
  color: var(--green-dark);
}

.sum-v.warn {
  color: var(--warn);
}

.mb-3 {
  margin-bottom: 12px;
}

.order-price {
  margin-left: auto;
  font-weight: 700;
  font-size: 15.5px;
  color: var(--green-dark);
  background: var(--green-soft);
  padding: 3px 9px;
  border-radius: 8px;
  white-space: nowrap;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.row {
  display: flex;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 3px;
}

.row svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  margin-top: 2px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
}

.row b {
  color: var(--ink);
  font-weight: 550;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.badge.pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.accepted {
  background: var(--info-soft);
  color: var(--info);
}

.badge.in_warehouse {
  background: var(--green-soft);
  color: var(--green-dark);
}

.badge.delivering {
  background: #efe7fb;
  color: #6b46c1;
}

.badge.delivered {
  background: var(--green-soft);
  color: var(--green-dark);
}

.badge.rejected,
.badge.unaccepted {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.returned {
  background: var(--warn-soft);
  color: var(--warn);
}

/* Statuse që i ka vetëm manifesti */
.badge.uploaded {
  background: var(--info-soft);
  color: var(--info);
}

.badge.dogan {
  background: #efe7fb;
  color: #6b46c1;
}

.badge.opened,
.badge.deleted {
  background: #eef1f0;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

/* ---------- Buttons ---------- */

.btn {
  flex: 1 1 auto;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

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

.btn.danger {
  background: var(--danger-soft);
  border-color: #f6d4d4;
  color: var(--danger);
}

.btn.warn {
  background: var(--warn-soft);
  border-color: #f2e2c0;
  color: var(--warn);
}

.btn.block {
  width: 100%;
  flex: none;
}

.btn.lg {
  min-height: 50px;
  font-size: 15.5px;
}

/* ---------- States ---------- */

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
}

.empty svg {
  width: 46px;
  height: 46px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.3;
  opacity: 0.5;
  margin-bottom: 10px;
}

.skeleton {
  height: 96px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: linear-gradient(100deg, #eef1f0 30%, #f7f9f8 50%, #eef1f0 70%);
  background-size: 220% 100%;
  animation: sk 1.2s infinite linear;
}

@keyframes sk {
  to {
    background-position: -220% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* ---------- Login ---------- */

/* Njësoj si shell-i: body-t i është hequr rrëshqitja, prandaj ekrani i
   kyçjes duhet ta mbushë vetë viewport-in dhe të rrëshqasë brenda vetes. */
.login {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  padding: 32px 22px calc(32px + var(--safe-bottom));
  background: var(--card);
}

.login img {
  width: 120px;
  align-self: center;
  margin-bottom: 6px;
}

.login h2 {
  margin: 0 0 4px;
  font-size: 21px;
  text-align: center;
  letter-spacing: -0.02em;
}

.login p.lead {
  margin: 0 0 26px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.field {
  margin-bottom: 13px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  background: #fbfcfc;
  /* 16px shmang zoom-in automatik të Safari-t në iPhone */
  font-size: 16px;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: -2px;
  background: #fff;
}

.alert {
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13.5px;
  margin-bottom: 13px;
  display: none;
}

.alert.show {
  display: block;
}

.alert.err {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert.ok {
  background: var(--green-soft);
  color: var(--green-dark);
}

/* ---------- Scanner ---------- */

#reader {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

#reader video {
  width: 100% !important;
  height: auto !important;
  display: block;
}

.scan-hint {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  margin: 12px 0 16px;
}

/* ---------- Sheet (modal) ---------- */

.sheet-bg {
  position: fixed;
  inset: 0;
  background: rgba(20, 33, 27, 0.45);
  z-index: 40;
  display: flex;
  align-items: flex-end;
}

.sheet-bg[hidden] {
  display: none !important;
}

.sheet {
  background: var(--card);
  width: 100%;
  border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(18px + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
  animation: up 0.18s ease-out;
}

@keyframes up {
  from {
    transform: translateY(14px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet {
    animation: none;
  }
}

.sheet .grip {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 6px auto 14px;
}

.sheet h3 {
  margin: 0 0 3px;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.sheet .sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  /* Mbi navigimin statik, që të mos e mbulojë */
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  z-index: 50;
  background: var(--ink);
  color: #fff;
  border-radius: 11px;
  padding: 12px 15px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(20, 33, 27, 0.25);
  /* Fshehja bëhet me visibility, jo me translate: toast-i rri 76px mbi fund,
     prandaj zhvendosja poshtë nuk e nxirrte dot plotësisht nga ekrani dhe
     mbetej si shirit i zi mbi ikonat e navigimit. */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out,
    visibility 0s linear 0.2s;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.2s ease-out, transform 0.2s ease-out, visibility 0s;
}

.toast.err {
  background: var(--danger);
}

.toast.ok {
  background: var(--green);
}

/* ---------- Profile / install ---------- */

.list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}

.list .item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}

.list .item:last-child {
  border-bottom: 0;
}

.list .item .k {
  color: var(--muted);
}

.list .item .v {
  margin-left: auto;
  font-weight: 600;
  text-align: right;
}

/* ---------- Njoftimet ---------- */

.notif {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 15px;
  margin-bottom: 14px;
  border-left: 3px solid var(--line);
}

.notif.on {
  border-left-color: var(--green);
}

.notif.off {
  border-left-color: var(--warn);
}

.notif-head {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}

.notif-head svg {
  flex: 0 0 22px;
  margin-top: 1px;
  color: var(--muted);
}

.notif.on .notif-head svg {
  color: var(--green);
}

.notif h4 {
  margin: 0;
  font-size: 15px;
}

.notif-status {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.notif.on .notif-status {
  color: var(--green-dark);
  font-weight: 600;
}

.notif-hint {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--warn-soft);
  border-radius: 9px;
  padding: 9px 11px;
}

.notif-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.notif-actions:empty,
.notif-actions:not(:has(button:not([hidden]))) {
  display: none;
}

.install {
  background: var(--green-soft);
  border: 1px solid #cfe8db;
  border-radius: var(--radius);
  padding: 14px 15px;
  margin-bottom: 14px;
}

.install h4 {
  margin: 0 0 6px;
  font-size: 14.5px;
  color: var(--green-dark);
}

.install ol {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--ink);
}

.install li {
  margin-bottom: 4px;
}

.offline {
  background: var(--warn-soft);
  color: var(--warn);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 7px;
}

.offline[hidden] {
  display: none !important;
}
