/* ============================================================
   KELAVA CRM CLONE — Design System
   Primary: #29B6C6  |  Accent: #F4874B  |  BG: #F5F5F5
   Mobile frame: 390px max-width, centered
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: #E8E8E8;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

/* ── Mobile shell ── */
.phone-shell {
  width: 100%;
  max-width: 390px;
  min-height: 100vh;
  background: #FFFFFF;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.18);
}

/* ── Status bar (fake) ── */
.status-bar {
  height: 28px;
  background: #29B6C6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}
.status-bar .time {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.status-bar .icons {
  display: flex;
  gap: 6px;
  align-items: center;
}
.status-bar .icons svg { color: #fff; }

/* ── Top bar / Header ── */
.topbar {
  height: 56px;
  background: #29B6C6;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
.topbar-back {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}
.topbar-back svg { width: 24px; height: 24px; }
.topbar-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.topbar-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  position: relative;
}
.topbar-icon svg { width: 22px; height: 22px; }
.topbar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: #FF3B30;
  border-radius: 50%;
}

/* ── Page content ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  background: #FFFFFF;
  padding-bottom: 72px; /* space for bottom nav */
  -webkit-overflow-scrolling: touch;
}
.page-content.no-bottom-nav {
  padding-bottom: 0;
}

/* ── Bottom navigation ── */
.bottom-nav {
  height: 64px;
  background: #FFFFFF;
  border-top: 1px solid #E8E8E8;
  display: flex;
  position: sticky;
  bottom: 0;
  z-index: 100;
  flex-shrink: 0;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #9E9E9E;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  padding: 8px 0;
  transition: color 0.15s;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: #29B6C6; }
.bottom-nav-item span { font-size: 10px; line-height: 1; }

/* ── Cards ── */
.card {
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  padding: 16px;
  margin: 12px 16px;
}
.card-section {
  background: #FFFFFF;
  border-radius: 8px;
  margin: 8px 16px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

/* ── Section rows (label + value) ── */
.detail-row {
  padding: 10px 16px;
  border-bottom: 1px solid #F0F0F0;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  font-size: 11px;
  color: #9E9E9E;
  margin-bottom: 2px;
}
.detail-value {
  font-size: 14px;
  color: #1A1A1A;
  font-weight: 500;
}

/* ── Form fields ── */
.form-group {
  padding: 12px 16px 0;
}
.form-label {
  font-size: 12px;
  color: #1A1A1A;
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}
.form-label .required { color: #E53E3E; }
.form-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid #C0C0C0;
  outline: none;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: #1A1A1A;
  padding: 6px 0 8px;
  background: transparent;
}
.form-input:focus { border-bottom-color: #29B6C6; }
.form-input::placeholder { color: #B0B0B0; }
.form-textarea {
  width: 100%;
  border: 1px solid #E0E0E0;
  border-radius: 6px;
  outline: none;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: #1A1A1A;
  padding: 10px 12px;
  background: transparent;
  resize: none;
  min-height: 80px;
}
.form-textarea:focus { border-color: #29B6C6; }

/* ── Select / Dropdown ── */
.form-select-wrapper {
  position: relative;
  border-bottom: 1px solid #C0C0C0;
}
.form-select-wrapper:focus-within { border-bottom-color: #29B6C6; }
.form-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: #1A1A1A;
  padding: 6px 28px 8px 0;
  background: transparent;
  cursor: pointer;
}
.form-select option { color: #1A1A1A; }
.select-chevron {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #555;
}
.select-chevron svg { width: 18px; height: 18px; }

/* ── Bordered select (used in step-wizard rows) ── */
.form-select-bordered {
  width: 100%;
  border: 1px solid #E0E0E0;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: #1A1A1A;
  appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 10px center;
  background-size: 16px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
}
.btn:active { opacity: 0.85; }
.btn-primary {
  background: #29B6C6;
  color: #fff;
  padding: 13px 24px;
  width: 100%;
}
.btn-primary:disabled, .btn-primary.disabled {
  background: #B0D8DE;
  cursor: not-allowed;
}
.btn-secondary {
  background: #F0F0F0;
  color: #555;
  padding: 11px 20px;
}
.btn-danger {
  background: #E53E3E;
  color: #fff;
  padding: 11px 20px;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid #C0C0C0;
  color: #555;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.btn-outline.active {
  border-color: #29B6C6;
  color: #29B6C6;
  background: #EAF8FA;
}
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 4px;
}

/* ── Form action footer ── */
.form-footer {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border-top: 1px solid #F0F0F0;
  margin-top: 8px;
}

/* ── GPS banner ── */
.gps-banner {
  background: #29B6C6;
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
}
.gps-banner.scanning { opacity: 0.75; }

/* ── Cached/offline banner ── */
.offline-banner {
  background: #FF9800;
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Section header ── */
.section-header {
  padding: 12px 16px 6px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  background: #F8F8F8;
  border-bottom: 1px solid #EBEBEB;
}

/* ── List items ── */
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #F0F0F0;
  text-decoration: none;
  color: #1A1A1A;
  gap: 12px;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: #F5F5F5; }
.list-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #EAF8FA;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #29B6C6;
}
.list-item-icon svg { width: 18px; height: 18px; }
.list-item-content { flex: 1; min-width: 0; }
.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1A1A1A;
}
.list-item-sub {
  font-size: 12px;
  color: #888;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-right {
  color: #B0B0B0;
  flex-shrink: 0;
}
.list-item-right svg { width: 16px; height: 16px; }

/* ── Unread dot ── */
.unread-dot {
  width: 10px;
  height: 10px;
  background: #E53E3E;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Notification item ── */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #F0F0F0;
}
.notif-content { flex: 1; }
.notif-title {
  font-size: 14px;
  font-weight: 700;
  color: #1A1A1A;
}
.notif-sub {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

/* ── Avatar circle ── */
.avatar-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid #E0E0E0;
  background: #F5F5F5;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto 8px;
  color: #B0B0B0;
}
.avatar-circle svg { width: 44px; height: 44px; }

/* ── Badge pill ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-orange { background: #FFF0E6; color: #F4874B; border: 1px solid #F4874B; }
.badge-teal   { background: #EAF8FA; color: #29B6C6; border: 1px solid #29B6C6; }
.badge-green  { background: #E6F9EE; color: #2DB66A; border: 1px solid #2DB66A; }
.badge-red    { background: #FEECEC; color: #E53E3E; border: 1px solid #E53E3E; }
.badge-gray   { background: #F0F0F0; color: #666;    border: 1px solid #CCC; }

/* ── Lokasi button (orange pill on customer detail) ── */
.btn-lokasi {
  display: inline-block;
  padding: 6px 20px;
  background: transparent;
  border: 1.5px solid #F4874B;
  border-radius: 20px;
  color: #F4874B;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  margin: 4px auto 16px;
}

/* ── Step wizard (QC/TC forms) ── */
.step-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #F0F0F0;
}
.step-number {
  width: 28px;
  height: 28px;
  background: #29B6C6;
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.step-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.step-delete {
  width: 28px;
  height: 28px;
  background: #29B6C6;
  border: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  color: #fff;
}
.step-delete svg { width: 16px; height: 16px; }
.add-row-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: pointer;
  gap: 0;
}
.add-row-btn .line {
  flex: 1;
  height: 1px;
  background: #29B6C6;
}
.add-row-btn .plus-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #29B6C6;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #29B6C6;
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
}

/* ── Signature tap-box (matches real app: tap to open modal) ── */
.signature-box {
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  background: #FAFAFA;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  margin: 8px 0;
  padding: 16px;
  transition: border-color 0.15s;
}
.signature-box:active { border-color: #29B6C6; }
.signature-box .sig-icon {
  width: 44px;
  height: 44px;
  background: #333;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.signature-box .sig-icon svg { width: 24px; height: 24px; }
.signature-box .sig-hint {
  font-size: 12px;
  color: #888;
}
.signature-box.has-sig { border-color: #29B6C6; background: #fff; }
.signature-box.has-sig canvas {
  width: 100%;
  height: 80px;
  display: block;
}

/* ── Signature modal overlay ── */
.sig-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sig-modal-overlay.open { display: flex; }
.sig-modal {
  background: #fff;
  width: 100%;
  max-width: 390px;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sig-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #1A1A1A;
  text-align: center;
}
.sig-modal canvas {
  width: 100%;
  height: 160px;
  border: 1.5px solid #E0E0E0;
  border-radius: 8px;
  background: #FAFAFA;
  display: block;
  touch-action: none;
}
.sig-modal-actions {
  display: flex;
  gap: 10px;
}

/* ── Legacy canvas (kept for non-modal uses) ── */
.signature-wrapper {
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  overflow: hidden;
  background: #FAFAFA;
  position: relative;
  margin: 8px 0;
}
.signature-wrapper canvas {
  width: 100%;
  height: 120px;
  display: block;
  touch-action: none;
}
.signature-clear {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 11px;
  color: #999;
  cursor: pointer;
  background: rgba(255,255,255,0.8);
  padding: 2px 6px;
  border-radius: 4px;
}
.signature-hint {
  position: absolute;
  bottom: 6px;
  left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  color: #BDBDBD;
  pointer-events: none;
}

/* ── Search bar ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #EBEBEB;
}
.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  color: #1A1A1A;
}
.search-input::placeholder { color: #B0B0B0; }
.search-clear {
  width: 24px;
  height: 24px;
  background: #555;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  cursor: pointer;
}
.search-clear svg { width: 14px; height: 14px; }

/* ── Activity tabs ── */
.tab-bar {
  display: flex;
  border-bottom: 2px solid #E0E0E0;
  background: #fff;
}
.tab-item {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab-item.active {
  color: #29B6C6;
  border-bottom-color: #29B6C6;
  font-weight: 700;
}

/* ── Activity card in list ── */
.activity-card {
  margin: 10px 16px;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  overflow: hidden;
}
.activity-card-header {
  background: #EAF8FA;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.activity-card-no {
  font-size: 13px;
  font-weight: 700;
  color: #29B6C6;
}
.activity-card-body {
  padding: 10px 14px;
}
.activity-card-type {
  font-size: 11px;
  font-weight: 700;
  color: #29B6C6;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.activity-card-customer {
  font-size: 14px;
  font-weight: 600;
  color: #1A1A1A;
  margin-bottom: 4px;
}
.activity-card-meta {
  font-size: 12px;
  color: #888;
}
.activity-card-actions {
  display: flex;
  border-top: 1px solid #F0F0F0;
}
.activity-card-btn {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #29B6C6;
  text-decoration: none;
  border-right: 1px solid #F0F0F0;
}
.activity-card-btn:last-child { border-right: none; }
.activity-card-btn.danger { color: #E53E3E; }

/* ── Opportunity card ── */
.opp-card {
  margin: 10px 16px;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  padding: 14px;
  text-decoration: none;
  display: block;
  color: #1A1A1A;
}
.opp-card-name { font-size: 15px; font-weight: 700; color: #1A1A1A; }
.opp-card-customer { font-size: 12px; color: #888; margin-top: 2px; }
.opp-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

/* ── Beranda greeting card ── */
.greeting-card {
  background: #29B6C6;
  color: #fff;
  padding: 16px 20px;
  margin: 12px 16px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
}

/* ── Section divider with label ── */
.section-divider {
  padding: 12px 16px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-divider-title { font-size: 14px; font-weight: 600; color: #555; }
.section-divider-link { font-size: 12px; color: #29B6C6; text-decoration: none; }

/* ── Wave background (login) ── */
.login-wave {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 180px;
  overflow: hidden;
  z-index: 0;
}
.login-wave svg { width: 100%; height: 100%; }

/* ── Checkbox row ── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #F0F0F0;
}
.checkbox-row:last-child { border-bottom: none; }
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #29B6C6;
  flex-shrink: 0;
  cursor: pointer;
}
.checkbox-row label { font-size: 14px; color: #1A1A1A; cursor: pointer; }

/* ── Date/time picker input ── */
.input-datetime {
  width: 100%;
  border: none;
  border-bottom: 1px solid #C0C0C0;
  outline: none;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: #B0B0B0;
  padding: 6px 0 8px;
  background: transparent;
}
.input-datetime:focus { border-bottom-color: #29B6C6; color: #1A1A1A; }

/* ── Utilities ── */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.px-16 { padding-left: 16px; padding-right: 16px; }
.py-8  { padding-top: 8px; padding-bottom: 8px; }
.text-center { text-align: center; }
.text-teal { color: #29B6C6; }
.text-gray { color: #888; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.divider { height: 1px; background: #F0F0F0; margin: 0 16px; }
.spacer-8 { height: 8px; background: #F5F5F5; }
.spacer-12 { height: 12px; background: #F5F5F5; }

/* ── Flash messages ── */
.flash-message {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  flex-shrink: 0;
}
.flash-success { background: #E6F9EE; color: #2DB66A; border-bottom: 1px solid #A8E6BF; }
.flash-error   { background: #FEECEC; color: #E53E3E; border-bottom: 1px solid #F5C6C6; }
.flash-warning { background: #FFF8EC; color: #F4874B; border-bottom: 1px solid #FFD9B3; }

/* ── Inline field error ── */
.field-error-msg {
  font-size: 11px;
  color: #E53E3E;
  padding: 2px 16px 6px;
  display: block;
}
.form-input.has-error, .form-select.has-error { border-bottom-color: #E53E3E; }
.form-textarea.has-error { border-color: #E53E3E; }

/* ── MediaWebView iframe ── */
.webview-frame {
  width: 100%;
  flex: 1;
  border: none;
  display: block;
}

/* ── Printer form ── */
.printer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #F0F0F0;
}
.printer-label { font-size: 14px; color: #1A1A1A; }
.toggle-switch {
  width: 46px;
  height: 26px;
  background: #B0B0B0;
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-switch.on { background: #29B6C6; }
.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on .toggle-knob { left: 23px; }

/* ── Contract form ── */
.contract-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #1A1A1A;
  padding: 14px 16px 6px;
}

/* ── Responsive: desktop framing ── */
@media (min-width: 480px) {
  body { background: #CCCCCC; padding: 20px 0; align-items: flex-start; }
  .phone-shell { border-radius: 16px; min-height: calc(100vh - 40px); }
}
