/* === CC Field — Custom styles (Bootstrap 5 is the base) === */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --cc-blue:     #ebf8ff;
  --cc-blue-mid: #bee3f8;
  --cc-blue-dark:#1a4a6b;
  --cc-brand:    #007fff;
}

/* ── Base ──────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f6f8;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── Appointment type color bars & badges ──────────────────── */
.bar-initial   { background: #90CDF5; }
.bar-emergency { background: #F68F8E; }
.bar-followup  { background: #E28DF5; }
.bar-estimate  { background: #93F5A2; }
.bar-recurring { background: #F3F491; }
.bar-firm      { background: #F2B172; }
.bar-animal    { background: #C8A46E; }

.badge-initial   { background: #90CDF5 !important; color: #1a4a6b !important; }
.badge-emergency { background: #F68F8E !important; color: #6b0000 !important; }
.badge-followup  { background: #E28DF5 !important; color: #4a006b !important; }
.badge-estimate  { background: #93F5A2 !important; color: #006b1a !important; }
.badge-recurring { background: #F3F491 !important; color: #5a5a00 !important; }
.badge-firm      { background: #F2B172 !important; color: #6b3000 !important; }
.badge-animal    { background: #C8A46E !important; color: #3d1f00 !important; }

/* ── Login ─────────────────────────────────────────────────── */
#loginView {
  min-height: 100dvh;
  background: linear-gradient(135deg, #ebf8ff 0%, #bee3f8 100%);
}

.login-logo { max-width: 180px; }

/* ── App Shell ─────────────────────────────────────────────── */
#appView {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--cc-blue);
  border-bottom: 1px solid var(--cc-blue-mid);
  padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
  flex-shrink: 0;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--cc-blue-dark);
}

.page-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 80px;
}

/* ── Bottom Tab Bar ────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid #dee2e6;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  color: #adb5bd;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  min-height: 56px;
  transition: color 0.15s;
  user-select: none;
}

.tab-item.active { color: var(--cc-brand); }

.tab-icon {
  width: 22px;
  height: 22px;
  margin-bottom: 3px;
  stroke: currentColor;
  fill: none;
}

/* ── Appointment Cards ─────────────────────────────────────── */
.appt-card {
  display: flex;
  background: white;
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.1s;
  text-decoration: none;
  color: inherit;
}
.appt-card:active { transform: scale(0.98); }

.appt-color-bar { width: 6px; flex-shrink: 0; }

.appt-body { padding: 12px 14px; flex: 1; min-width: 0; }

.appt-time {
  font-size: 11px;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.appt-customer {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appt-address {
  font-size: 13px;
  color: #6c757d;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appt-chevron {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #ced4da;
  font-size: 20px;
  flex-shrink: 0;
}

/* ── Week Selector ─────────────────────────────────────────── */
.week-selector {
  display: flex;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 12px;
}

.week-day-btn {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  cursor: pointer;
  border-right: 1px solid #f0f0f0;
  transition: background 0.15s;
}
.week-day-btn:last-child { border-right: none; }
.week-day-btn.active { background: var(--cc-brand); color: white; }

.week-day-name { font-size: 10px; font-weight: 600; text-transform: uppercase; }
.week-day-num  { font-size: 18px; font-weight: 600; }
.week-day-dot  {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cc-brand);
  margin: 2px auto 0;
}
.week-day-btn.active .week-day-dot { background: white; }

.week-day-availability {
  font-size: 9px;
  font-weight: 600;
  color: #6c757d;
  margin-top: 2px;
  white-space: nowrap;
}
.week-day-btn.active .week-day-availability { color: rgba(255,255,255,0.85); }

/* ── Detail Sheet ──────────────────────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
}

.detail-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  z-index: 201;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-handle-bar {
  width: 40px; height: 4px;
  background: #dee2e6;
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.detail-sheet-header {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.detail-back-btn {
  background: none;
  border: none;
  font-size: 15px;
  color: var(--cc-brand);
  font-family: inherit;
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
  min-width: 50px;
}

.detail-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.detail-header-actions { min-width: 50px; text-align: right; }

.detail-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

/* ── Info Rows ─────────────────────────────────────────────── */
.info-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f8f9fa;
  align-items: flex-start;
}
.info-row:last-of-type { border-bottom: none; }

.info-label {
  font-size: 11px;
  font-weight: 700;
  color: #adb5bd;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 80px;
  padding-top: 2px;
}

.info-value { font-size: 15px; flex: 1; }

/* ── Work Group Cards ──────────────────────────────────────── */
.wg-card {
  background: white;
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}

.wg-header {
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8f9fa;
}

.wg-expand-icon { color: #ced4da; font-size: 20px; transition: transform 0.2s; }
.wg-expand-icon.open { transform: rotate(90deg); }

.wg-line {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid #f0f0f0;
  gap: 10px;
}

.wg-line-desc { flex: 1; font-size: 14px; }

.wg-line-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.status-pending    { background: #f0f0f0;  color: #6c757d; }
.status-started    { background: #bee3f8;  color: #1a4a6b; }
.status-complete   { background: #93F5A2;  color: #006b1a; font-weight: 700; }
.status-inprogress { background: #bee3f8;  color: #1a4a6b; }
.status-ready      { background: #93F5A2;  color: #006b1a; font-weight: 700; }

/* ── Focused Work Group view (opened from an appointment) ───── */
.wg-focused-back {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #0d6efd;
  cursor: pointer;
  padding: 4px 0 14px;
  user-select: none;
}

.wg-focused-header { cursor: default; }

.wg-line-status.wg-line-readonly {
  cursor: default;
  opacity: 0.65;
}

/* ── Estimate Cards ────────────────────────────────────────── */
.est-offline-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #FFA500;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Loading ───────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

/* ── Misc ──────────────────────────────────────────────────── */
.section-header {
  font-size: 11px;
  font-weight: 700;
  color: #adb5bd;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 14px 0 8px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #adb5bd;
}

.empty-state-icon { font-size: 48px; margin-bottom: 10px; }

.fw-note {
  background: #fff8e1;
  border-left: 3px solid #FFA500;
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  font-size: 13px;
  color: #6c757d;
}

/* ── Home Stat Card ────────────────────────────────────────── */
.home-stat-card {
  background: linear-gradient(135deg, var(--cc-blue-dark) 0%, #1565c0 100%);
  color: white;
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.home-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.75;
}
.home-stat-value {
  font-size: 30px;
  font-weight: 700;
  margin: 4px 0 0;
}

.tier-progress-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.2);
}

.tier-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.tier-current-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.75;
}

.tier-remaining-label {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
}

.tier-progress-track {
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  overflow: hidden;
}

.tier-progress-fill {
  height: 100%;
  background: white;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.tier-progress-top-tier {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
  text-align: center;
}

/* ── Record Cards (Traps, Check Valves) ────────────────────── */
.record-card {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.1s;
  overflow: hidden;
}
.record-card:active { transform: scale(0.98); }

.record-card-body { padding: 10px 12px; flex: 1; min-width: 0; }

.record-card-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}

.record-card-meta {
  font-size: 12px;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Week Navigation ────────────────────────────────────────── */
.week-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  text-align:center
}

.week-nav-btn {
  padding-bottom:8px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 20px;
  width: 36px;
  height: 36px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cc-brand);
  line-height: 1;
  flex-shrink: 0;
}
.week-nav-btn:active { background: #f0f0f0; }

.week-nav-label {
  font-size: 12px;
  font-weight: 600;
  color: #6c757d;
  text-align: center;
  flex: 1;
  padding: 0 8px;
}

/* ── Customer Search ────────────────────────────────────────── */
.search-form-card {
  background: white;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ── Customer Activity Log ──────────────────────────────────── */
.activity-item {
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}
.activity-item:last-child { border-bottom: none; }

.activity-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.activity-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.activity-type-note        { background: #fff8e1; color: #b45309; }
.activity-type-appointment { background: #bee3f8; color: #1a4a6b; }
.activity-type-estimate    { background: #93F5A2; color: #006b1a; }
.activity-type-invoice     { background: #f5d0fe; color: #6b006b; }
.activity-type-call        { background: #fef3c7; color: #92400e; }

.activity-date {
  font-size: 11px;
  color: #adb5bd;
}

.activity-summary {
  font-size: 14px;
  color: #374151;
  line-height: 1.4;
}

/* ── Resource Topics & Articles ─────────────────────────────── */
.resource-topic {
  background: white;
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}

.resource-topic-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  background: #f8f9fa;
  user-select: none;
}
.resource-topic-header:active { background: #f0f0f0; }

.resource-topic-title {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
}

.resource-topic-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--cc-blue-mid);
  color: var(--cc-blue-dark);
  border-radius: 10px;
  padding: 2px 8px;
  margin-right: 8px;
}

.resource-articles {
  border-top: 1px solid #f0f0f0;
}

.resource-article {
  padding: 12px 16px;
  border-bottom: 1px solid #f8f9fa;
  cursor: pointer;
  transition: background 0.1s;
}
.resource-article:last-child { border-bottom: none; }
.resource-article:active { background: #f8f9fa; }

.resource-article-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.resource-article-preview {
  font-size: 12px;
  color: #6c757d;
  line-height: 1.4;
}

/* ── Nearby Equipment Banner (Schedule view) ────────────────── */
.nearby-banner {
  background: #ebf8ff;
  border: 1px solid #bee3f8;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.nearby-banner-title {
  font-size: 11px;
  font-weight: 700;
  color: #1a4a6b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.nearby-banner-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #bee3f8;
}
.nearby-banner-item:last-child { border-bottom: none; }

.nearby-banner-info { flex: 1; min-width: 0; }

.nearby-banner-label {
  font-size: 13px;
  font-weight: 600;
  color: #1a4a6b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-banner-addr {
  font-size: 11px;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-banner-btn {
  font-size: 12px !important;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Dollar prefix on price inputs */
.input-dollar {
  position: relative;
}
.input-dollar::before {
  content: "$";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #adb5bd;
  pointer-events: none;
  z-index: 5;
}
.input-dollar input { padding-left: 24px; }

/* ── Nag Screen (open-trap reminder) ──────────────────────── */
.nag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
}

.nag-modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 20px;
  z-index: 501;
  width: calc(100% - 48px);
  max-width: 340px;
  padding: 28px 20px 20px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.nag-avatar-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
}

.nag-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--cc-brand);
  color: white;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nag-hat {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%) rotate(-8deg);
  font-size: 34px;
  line-height: 1;
}

.nag-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.nag-message {
  font-size: 14px;
  color: #495057;
  text-align: left;
}

.nag-trap-item {
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}
.nag-trap-item:last-child { border-bottom: none; }

/* ── Generic Confirm Modal (invoice send/payment confirmations) ── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 600;
}

.confirm-modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 20px;
  z-index: 601;
  width: calc(100% - 48px);
  max-width: 340px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.confirm-modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-modal-message {
  font-size: 14px;
  color: #495057;
}
