/* =========================
   1. RESET & BASE
========================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #e7ebef;
  color: #111;
  padding-bottom: 100px;
}


/* =========================
   2. APP HEADER
========================= */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 20px 10px;
}

.app-header h1 {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.header-add-button,
.header-export-button {
  border: none;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-add-button {
  background: #000;
  color: #fff;
}

.header-export-button {
  background: #fff;
  border: 1px solid #d4dbe0;
  color: #111;
}

/* =========================
   3. PAGE LAYOUT
========================= */

.page {
  display: none;
  padding: 20px;
}

.page.active-page {
  display: block;
}

#archive-list {
  padding-bottom: 120px;
}

#archive-page .job-card {
  display: block;
}


/* =========================
   4. GLOBAL BUTTONS
========================= */

.main-button,
.save-button,
.cancel-edit-button {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 18px;
  font-size: 18px;
  font-weight: bold;
  background: #000;
  color: #fff;
}

.cancel-edit-button {
  background: #dcdcdc;
  color: #111;
  border: 1px solid #cfd6dc;
  margin-top: 12px;
}


/* =========================
   5. DASHBOARD CARDS
========================= */

.card {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 22px;
  margin-bottom: 18px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 15px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.status-box {
  background: #f3f5f7;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  font-weight: bold;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 14px;
  font-size: 15px;
  border-bottom: 1px solid #e6e6e6;
}

.stat-row:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* =========================
   6. FORMS
========================= */

input,
select,
textarea {
  width: 100%;
  padding: 16px;
  margin-bottom: 14px;
  border-radius: 12px;
  border: 1px solid #d8dee4;
  font-size: 16px;
  background: #fff;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #666 50%),
    linear-gradient(135deg, #666 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

textarea {
  min-height: 120px;
  resize: none;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 15px;
  font-weight: 700;
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.form-section-title {
  font-size: 14px;
  font-weight: 800;
  margin-top: 18px;
  margin-bottom: 10px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#repair-status {
  display: none;
}

#repair-number {
  background: #f1f3f5;
  border: 1px solid #d8dee4;
  color: #666;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* =========================
   7. FILTERS & SEARCH
========================= */

.filter-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.filter-row button {
    border: 1px solid #000000;
    background: #fff;
    color: #222;
    padding: 5px 12px;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
}

.jobs-toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #e7ebef;
  padding-top: 6px;
  padding-bottom: 10px;
}


/* =========================
   8. JOB CARD
========================= */

.job-card {
  background: #fff;
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.empty-state {
  text-align: center;
  padding: 30px 20px;
}

.empty-state p {
  color: #666;
  font-size: 15px;
  font-weight: 600;
}

.job-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-row {
  margin-bottom: 8px;
}

.job-number {
  font-size: 20px;
  font-weight: 800;
}

.copy-repair-number {
  cursor: pointer;
}

.job-date {
  font-size: 17px;
  color: #222;
}

.dropdown-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.dropdown-row select {
  width: 100%;
  margin-bottom: 0;
  padding: 7px 12px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
}

.job-customer {
  display: block;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 2px;
}

.job-meta {
  font-size: 16px;
  color: #222;
  margin-bottom: 8px;
}

.job-amount {
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
}

.job-type-right {
  font-size: 15px;
  color: #555;
  text-align: right;
  line-height: 1;
}

.job-card-row:nth-of-type(3) {
  border-bottom: 1px solid #e6e6e6;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.job-card-row:nth-of-type(4) {
  border-bottom: 1px solid #e6e6e6;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.select-wrap {
  position: relative;
}

.select-wrap select {
  padding-left: 38px;
}

.status-dot {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.status-received {
  background: #d9a441;
}

.status-ready {
  background: #7bcf8c;
}

.status-delivered {
  background: #6f8fbf;
}

.payment-paid {
  background: #7bcf8c;
}

.payment-unpaid {
  background: #d56a6a;
}

.filter-row button.active-filter {
  background: #000;
  color: #fff;
}

.search-wrap {
  position: relative;
  margin-bottom: 14px;
}

.search-wrap i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #777;
  font-size: 14px;
}

.search-wrap input {
  padding-left: 44px;
  margin-bottom: 0;
}

/* =========================
   9. JOB TAGS & PILLS
========================= */

.info-row {
  justify-content: flex-start;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 8px;
}

.priority-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #c95b52;
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.history-btn {
  border: 1px solid #999;
  background: #fff;
  color: #111;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.job-notes {
  font-size: 14px;
  color: #444;
  line-height: 1.35;
  margin-top: 6px;
}


/* =========================
   10. JOB ACTION BUTTONS
========================= */

.job-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  border-top: 1px solid #e6e6e6;
  padding-top: 14px;
}

.archive-actions {
  grid-template-columns: 1fr 1fr;
}

.job-actions button {
  border: none;
  background: #000;
  color: #fff;
  padding: 10px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.job-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button {
  transition: transform 0.08s ease, opacity 0.08s ease;
}

button:active {
  transform: scale(0.97);
  opacity: 0.85;
}

/* =========================
   11. BOTTOM NAVIGATION
========================= */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #000;
  border-radius: 20px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 999;
}

.bottom-nav button {
  border: none;
  background: transparent;
  padding: 14px 10px;
  font-size: 22px;
  color: #fff;
}

.add-nav-btn i {
  font-size: 40px;
  font-weight: 900;
  position: relative;
  top: -1px;
}

.bottom-nav button:focus {
  outline: none;
}

.bottom-nav button:active {
  opacity: 0.6;
}

.bottom-nav button.active-nav {
  color: #ffffff;
  opacity: 1;
}

.bottom-nav button {
  opacity: 0.45;
}

.refresh-btn {
  opacity: 0.45;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.refresh-btn.loading {
  opacity: 1;
  color: #fff;
}

.refresh-btn.loading i {
  animation: spinRefresh 0.8s linear infinite;
}

@keyframes spinRefresh {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* =========================
   12. MODALS
========================= */

.history-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.history-modal-content {
  background: white;
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 18px;
  padding: 20px;
}

.history-close {
  float: right;
  font-size: 28px;
  border: none;
  background: none;
}

.history-item {
  border-bottom: 1px solid #eee;
  padding: 12px 0;
}

/* =========================
   13. LOCK SCREEN
========================= */

#lock-screen {
  position: fixed;
  inset: 0;
  background: #e7ebef;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-box {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  text-align: center;
}

.lock-box h2 {
  margin-bottom: 20px;
  font-size: 24px;
}

.lock-box input {
  text-align: center;
  font-size: 18px;
  letter-spacing: 2px;
}

.lock-box button {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px;
  background: #000;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.passcode-error {
  display: none;
  color: #ff4d4d;
  font-size: 14px;
  margin-top: 12px;
  margin-bottom: 12px;
  text-align: center;
  font-weight: 600;
}

/* =========================
   14. LOADING OVERLAY
========================= */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.hidden {
  display: none;
}

.loading-box {
  background: #fff;
  padding: 22px 28px;
  border-radius: 16px;
  box-shadow: 0 10px 35px rgba(0,0,0,0.15);
  text-align: center;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #ddd;
  border-top: 4px solid #111;
  border-radius: 50%;
  animation: dingdoc-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

.loading-box p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

@keyframes dingdoc-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================
   15. Toast Notification
========================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  
  background: rgba(34, 197, 94, 0.92);
  color: #fff;

  padding: 12px 18px;

  border-radius: 999px;

  font-size: 14px;
  font-weight: 600;

  z-index: 10000;

  backdrop-filter: blur(8px);

  box-shadow:
    0 10px 25px rgba(0,0,0,0.18),
    0 0 0 1px rgba(255,255,255,0.08);

  opacity: 1;

  transition:
    opacity 0.25s ease,
    bottom 0.25s ease,
    transform 0.25s ease;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  bottom: 70px;
  transform: translateX(-50%) scale(0.96);
}