/* ============================================================
   GraftrHQ — main.css
   Global styles, page shell, nav, components
   ============================================================ */

/* --- CSS Variables ----------------------------------------- */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --orange: #f97316;
  --orange-tint: rgba(249, 115, 22, 0.10);
  --orange-dark: #ea6c0a;
  --text-primary: #000000;
  --text-secondary: #3c3c43;
  --text-tertiary: #8e8e93;
  --text-placeholder: #8e8e93;
  --separator: rgba(60, 60, 67, 0.12);
  --separator-strong: rgba(60, 60, 67, 0.29);
  --green: #34c759;
  --green-tint: rgba(52, 199, 89, 0.10);
  --red: #ff3b30;
  --red-tint: rgba(255, 59, 48, 0.10);
  --blue: #007aff;
  --blue-tint: rgba(0, 122, 255, 0.10);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 12px;
}

/* --- Reset & base ------------------------------------------ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
}

/* --- Page shell -------------------------------------------- */
.page {
  max-width: 390px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
}

.page-content {
  padding: 0 16px 48px;
}

/* --- Nav bar — sticky frosted glass ----------------------- */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(242, 242, 247, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--separator);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.nav-back {
  color: var(--orange);
  font-size: 17px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.nav-back::before {
  content: '‹';
  font-size: 24px;
  margin-right: 2px;
}

.nav-title {
  font-size: 17px;
  font-weight: 600;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-action {
  color: var(--orange);
  font-size: 17px;
  cursor: pointer;
}

/* --- Status pills ------------------------------------------ */
.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.pill-orange { background: var(--orange-tint); color: var(--orange); }
.pill-blue   { background: var(--blue-tint);   color: var(--blue); }
.pill-green  { background: var(--green-tint);  color: var(--green); }
.pill-red    { background: var(--red-tint);    color: var(--red); }
.pill-grey   { background: rgba(142, 142, 147, 0.12); color: var(--text-secondary); }

/* --- Status banner ----------------------------------------- */
.status-banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.status-banner.orange { background: var(--orange-tint); }
.status-banner.blue   { background: var(--blue-tint); }
.status-banner.green  { background: var(--green-tint); }
.status-banner.red    { background: var(--red-tint); }

.status-banner-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.status-banner.orange .status-banner-label { color: var(--orange); }
.status-banner.blue   .status-banner-label { color: var(--blue); }
.status-banner.green  .status-banner-label { color: var(--green); }
.status-banner.red    .status-banner-label { color: var(--red); }

.status-banner-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}

/* --- Stats row --------------------------------------------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--surface);
  border: 0.5px solid rgba(60, 60, 67, 0.18);
  border-radius: var(--radius);
  padding: 14px 8px 12px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  text-decoration: none;
  display: block;
  transition: transform 0.1s, background 0.1s;
}

.stat-box:active {
  transform: scale(0.97);
  background: var(--surface-2);
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: -1px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
  line-height: 1.3;
}

/* --- Tiles ------------------------------------------------- */
.tile {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  text-decoration: none;
  transition: transform 0.1s;
}

.tile:active { transform: scale(0.99); }

.tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.tile-icon.orange { background: var(--orange-tint); }
.tile-icon.green  { background: var(--green-tint); }
.tile-icon.blue   { background: var(--blue-tint); }

.tile-content { flex: 1; }
.tile-title    { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.tile-subtitle { font-size: 13px; color: var(--text-tertiary); margin-top: 2px; }
.tile-chevron  { font-size: 20px; color: var(--text-tertiary); }

.tile-badge {
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* --- Search bar -------------------------------------------- */
.search-bar {
  background: rgba(118, 118, 128, 0.12);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
}

.search-bar input::placeholder { color: var(--text-tertiary); }

/* --- Toast ------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  border-radius: 22px;
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 500;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
  white-space: nowrap;
  backdrop-filter: blur(20px);
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* --- Bank details box -------------------------------------- */
.bank-details-box {
  background: var(--orange-tint);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 0.5px solid rgba(249, 115, 22, 0.3);
}

.bank-details-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}

.bank-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 0.5px solid rgba(249, 115, 22, 0.2);
}

.bank-detail-row:last-child { border-bottom: none; }
.bank-detail-label { font-size: 14px; color: var(--text-secondary); }
.bank-detail-value { font-size: 15px; font-weight: 700; color: var(--text-primary); }

/* --- Action links — phone, WhatsApp, maps ------------------ */
.contact-links {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.contact-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 11px 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  box-shadow: var(--shadow);
  transition: filter .12s ease;
}
.contact-link:active { filter: brightness(0.88); }
.contact-link svg { flex-shrink: 0; }

.contact-link.phone    { background: var(--blue); }
.contact-link.whatsapp { background: #25D366; }
.contact-link.maps     { background: var(--blue); }

/* --- Booked-date line on job detail card ------------------- */
.job-date-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  margin: 4px 0 14px;
}
.job-date-line .dur {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
/* M3-B: tappable variant — links to /calendar/:date */
.job-date-line-link {
  background: var(--card, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
}
.job-date-line-link .jd-text { flex: 1; min-width: 0; }
.job-date-line-link .jd-chev { color: var(--text-tertiary); flex-shrink: 0; }
.job-date-line-link:active { background: rgba(0,0,0,0.04); }
/* M3-E: extra breathing room between cards on All Jobs */
#jobList .card-group.job-card-search { margin-bottom: 14px; }
#jobList section[data-section] + section[data-section] { margin-top: 12px; }

/* --- Logo, avatar, badge ----------------------------------- */
.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  text-decoration: none;
}

.logo-orange { color: var(--orange); }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.trade-badge {
  display: inline-block;
  background: var(--orange-tint);
  color: var(--orange);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.job-ref {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

/* --- Section helpers --------------------------------------- */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 0 4px;
  margin: 4px 0 8px;
}

.divider {
  height: 0.5px;
  background: var(--separator);
  margin: 12px 0;
}

.gap    { height: 16px; }
.gap-sm { height: 8px; }

/* --- Landing page (Page 1) --------------------------------- */
.hero-headline {
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: -1.2px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  margin: 8px 0 14px;
}

.hero-sub {
  font-size: 17px;
  line-height: 1.45;
  color: var(--text-secondary);
  text-align: center;
  margin: 0 6px 28px;
}

.steps {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-body { flex: 1; min-width: 0; }
.step-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}
.step-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ── Desktop / tablet layout (≥ 768px) ────────────────────────── */
@media (min-width: 768px) {
  body { padding-left: 220px; }

  .page { max-width: 720px; }

  .page-content {
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: 32px;
  }

  /* Hide mobile bottom tab bar, show sidebar */
  .bottom-nav       { display: none !important; }
  .desktop-sidebar  { display: flex !important; }

  /* Post action sheet — still centred in full viewport */
  #postActionSheet { left: 220px; }

  /* Nav bar: full width of page */
  .nav-bar { max-width: 720px; }

  /* Wider stats / tiles breathe a little more */
  .stats-row { gap: 14px; }
  .tile      { padding: 16px 20px; }
  .stat-box  { padding: 18px 10px 14px; }

  /* Toasts clear the sidebar */
  .toast { left: calc(220px + 50%); transform: translateX(-50%) translateY(0); }
  .toast { transform: translateX(-50%) translateY(100px); }
  .toast.show { transform: translateX(-50%) translateY(0); }
}

/* Desktop: cancel the 84px bottom-nav padding injected by _layout.js page() */
@media (min-width: 768px) {
  .page-content { padding-bottom: 32px !important; }
}

/* Desktop: shift post action-sheet overlay right of the sidebar */
@media (min-width: 768px) {
  #postActionSheet { left: 220px !important; }
}
