/* ============================================================
   GUNAJASA MAINTENANCE PWA — app.css
   ============================================================ */

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

:root {
  --navy:    #1a3a5c;
  --navy-d:  #0f2840;
  --blue:    #2563eb;
  --green:   #16a34a;
  --amber:   #d97706;
  --red:     #dc2626;
  --bg:      #f4f6f9;
  --surface: #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --muted:   #64748b;
  --radius:  10px;
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior: none;
}

/* ── Login Screen ────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; z-index: 999;
  background: linear-gradient(160deg, #0f2840 0%, #1a3a5c 50%, #1e4976 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 20px;
  padding: 32px 28px; width: 100%; max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}
.login-logo {
  width: 60px; height: 60px; background: var(--navy);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-weight: 800; font-size: 18px; color: #fff; letter-spacing: -1px;
}
.login-title { text-align: center; margin-bottom: 6px; }
.login-title h1 { font-size: 20px; font-weight: 700; color: var(--navy); }
.login-title p  { font-size: 12px; color: var(--muted); margin-top: 3px; }
.login-divider  { height: 1px; background: var(--border); margin: 20px 0; }
.login-field { margin-bottom: 14px; position: relative; }
.login-field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }
.login-field input {
  width: 100%; padding: 11px 40px 11px 14px;
  border: 1.5px solid var(--border); border-radius: 9px;
  font-size: 15px; color: var(--text); outline: none;
  transition: border 0.15s, box-shadow 0.15s; background: #fff;
}
.login-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.login-field .field-icon {
  position: absolute; right: 12px; bottom: 11px;
  font-size: 18px; color: var(--muted); cursor: pointer;
}
.login-error {
  display: none; background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
  font-size: 13px; color: #dc2626; text-align: center;
}
.login-btn {
  width: 100%; padding: 13px; border: none;
  border-radius: 9px; background: var(--navy); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.login-btn:hover  { background: #0f2840; }
.login-btn:active { transform: scale(0.98); }
.login-btn.loading { opacity: 0.7; pointer-events: none; }
.login-footer { text-align: center; font-size: 11px; color: #94a3b8; margin-top: 20px; }

/* ── App Shell ────────────────────────────────────────────── */
#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-header .logo {
  width: 38px; height: 38px;
  background: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 11px; color: var(--navy);
  letter-spacing: -0.5px; flex-shrink: 0;
}
.app-header h1 { font-size: 15px; font-weight: 600; line-height: 1.2; }
.app-header p  { font-size: 11px; opacity: 0.7; margin-top: 1px; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.btn-icon {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.2); }

/* ── Bottom Nav ──────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 520px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px 4px 8px;
  cursor: pointer; color: var(--muted);
  font-size: 10px; gap: 3px; border: none; background: none;
  transition: color 0.15s;
}
.nav-item i { font-size: 22px; }
.nav-item.active { color: var(--blue); }
.nav-item.active i { font-weight: 600; }

/* ── Screen Management ───────────────────────────────────── */
.screen { display: none; padding-bottom: 80px; }
.screen.active { display: block; }

/* ── Step Progress ───────────────────────────────────────── */
.step-bar {
  background: var(--navy-d);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 0;
}
.step-item {
  flex: 1; text-align: center;
  font-size: 10px; color: rgba(255,255,255,0.45);
  cursor: pointer; padding: 5px 2px; border-radius: 6px;
  transition: all 0.2s;
}
.step-item .s-icon { font-size: 18px; display: block; margin-bottom: 1px; }
.step-item.active  { background: var(--blue); color: #fff; }
.step-item.done    { color: rgba(255,255,255,0.75); }
.step-connector { width: 12px; height: 1px; background: rgba(255,255,255,0.15); flex-shrink: 0; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 12px 14px;
  overflow: hidden;
}
.card-header {
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--navy);
  text-transform: uppercase; letter-spacing: 0.4px;
  display: flex; align-items: center; gap: 8px;
}
.card-header i { font-size: 16px; color: var(--blue); }
.card-body { padding: 14px; }

/* ── Form Fields ─────────────────────────────────────────── */
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px;
}
.field input,
.field select,
.field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px;
  background: #fff; color: var(--text);
  outline: none; transition: border 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.field textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ── Status Selector ─────────────────────────────────────── */
.status-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px;
}
.status-opt {
  border: 1.5px solid var(--border);
  border-radius: 8px; padding: 10px 6px;
  text-align: center; cursor: pointer;
  transition: all 0.15s; font-size: 12px; font-weight: 500;
  color: var(--muted); background: #fafafa;
}
.status-opt i { display: block; font-size: 22px; margin-bottom: 4px; }
.status-opt.sel-selesai { background:#f0fdf4; border-color:#16a34a; color:#15803d; }
.status-opt.sel-proses  { background:#fffbeb; border-color:#d97706; color:#b45309; }
.status-opt.sel-tunda   { background:#fef2f2; border-color:#dc2626; color:#b91c1c; }

/* ── Material rows ───────────────────────────────────────── */
.mat-row { display:flex; gap:7px; margin-bottom:8px; align-items:center; }
.mat-row input {
  flex:1; padding:9px 10px;
  border:1px solid var(--border); border-radius:8px;
  font-size:13px; color:var(--text); background:#fff; outline:none;
  transition: border 0.15s;
}
.mat-row input:focus { border-color:var(--blue); }
.mat-row .qty { flex:0 0 60px; }
.mat-row .sat { flex:0 0 70px; }
.btn-del {
  width:32px; height:32px; flex-shrink:0;
  background:none; border:1px solid #fecaca;
  border-radius:7px; cursor:pointer; color:#dc2626;
  display:flex; align-items:center; justify-content:center; font-size:16px;
}
.btn-add-mat {
  display:flex; align-items:center; gap:6px;
  font-size:13px; color:var(--blue); border:1px dashed #93c5fd;
  background:#eff6ff; border-radius:8px; padding:9px 14px;
  cursor:pointer; width:100%; justify-content:center; font-weight:500;
  transition: background 0.15s;
}
.btn-add-mat:hover { background:#dbeafe; }

/* ── Photo upload ────────────────────────────────────────── */
.photo-drop {
  border: 2px dashed var(--border);
  border-radius: 10px; padding: 20px;
  text-align: center; cursor: pointer;
  background: #f8fafc; transition: border 0.15s, background 0.15s;
}
.photo-drop:hover  { border-color: var(--blue); background: #eff6ff; }
.photo-drop i      { font-size: 36px; color: var(--muted); margin-bottom: 6px; }
.photo-drop p      { font-size: 13px; color: var(--muted); }
.photo-drop small  { font-size: 11px; color: #94a3b8; }
.photo-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 12px;
}
.photo-thumb-wrap { position:relative; }
.photo-thumb {
  width:100%; aspect-ratio:1; object-fit:cover;
  border-radius:8px; border:1px solid var(--border); display:block;
}
.photo-del {
  position:absolute; top:4px; right:4px;
  width:22px; height:22px; border-radius:50%;
  background:rgba(220,38,38,0.85); color:#fff; border:none;
  font-size:14px; cursor:pointer; display:flex; align-items:center; justify-content:center;
}

/* ── Signature Pad ───────────────────────────────────────── */
.sig-wrap {
  border: 1px solid var(--border);
  border-radius: 8px; background: #fafafa; overflow: hidden;
}
.sig-toolbar {
  display:flex; justify-content:space-between; align-items:center;
  padding: 7px 12px; background: #f1f5f9;
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.sig-toolbar span i { font-size:14px; margin-right:4px; }
.btn-clear-sig {
  font-size:12px; color:var(--red); background:none; border:none; cursor:pointer;
  padding:3px 8px; border-radius:5px; font-weight:500;
}
.btn-clear-sig:hover { background: #fee2e2; }
canvas.sig-canvas {
  display:block; width:100%; height:140px;
  touch-action:none; cursor:crosshair; background:#fff;
}

/* ── Navigation Buttons ──────────────────────────────────── */
.form-nav {
  display:flex; gap:10px; padding:14px;
  background:var(--surface); border-top:1px solid var(--border);
  position:sticky; bottom:0; z-index:10;
}
.btn-back  {
  padding:12px 18px; border:1px solid var(--border);
  border-radius:9px; background:none; color:var(--text);
  font-size:14px; cursor:pointer; font-weight:500;
  transition: background 0.15s;
}
.btn-back:hover { background: var(--bg); }
.btn-primary {
  flex:1; padding:12px; border:none;
  border-radius:9px; background:var(--blue); color:#fff;
  font-size:14px; font-weight:600; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:7px;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover  { background:#1d4ed8; }
.btn-primary:active { transform:scale(0.98); }
.btn-success {
  flex:1; padding:12px; border:none;
  border-radius:9px; background:var(--green); color:#fff;
  font-size:14px; font-weight:600; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:7px;
  transition: background 0.15s;
}
.btn-success:hover { background:#15803d; }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position:fixed; bottom:90px; left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--navy); color:#fff; padding:11px 20px;
  border-radius:20px; font-size:13px; font-weight:500;
  z-index:999; opacity:0; transition:all 0.3s; pointer-events:none; white-space:nowrap;
  display:flex; align-items:center; gap:8px;
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
.toast.success { background:#16a34a; }
.toast.error   { background:#dc2626; }
.toast.info    { background:#2563eb; }

/* ── Sync indicator ──────────────────────────────────────── */
.sync-badge {
  display:inline-flex; align-items:center; gap:4px;
  font-size:11px; padding:3px 8px; border-radius:20px;
  font-weight:500;
}
.sync-badge.online  { background:#f0fdf4; color:#16a34a; }
.sync-badge.offline { background:#fef2f2; color:#dc2626; }
.sync-badge.syncing { background:#eff6ff; color:#2563eb; }
.sync-dot { width:6px; height:6px; border-radius:50%; background:currentColor; }
.sync-dot.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── History / List ──────────────────────────────────────── */
.wo-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:13px 14px;
  margin:10px 14px; cursor:pointer;
  transition:box-shadow 0.15s, border 0.15s;
  display:flex; gap:12px; align-items:flex-start;
}
.wo-card:hover { border-color:#93c5fd; box-shadow:0 2px 8px rgba(37,99,235,0.08); }
.wo-card-icon {
  width:40px; height:40px; border-radius:9px;
  background:#eff6ff; display:flex; align-items:center; justify-content:center;
  font-size:20px; color:var(--blue); flex-shrink:0;
}
.wo-card-body { flex:1; min-width:0; }
.wo-card-title { font-size:14px; font-weight:600; margin-bottom:3px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.wo-card-sub   { font-size:12px; color:var(--muted); display:flex; gap:10px; flex-wrap:wrap; margin-bottom:5px; }
.wo-card-right { display:flex; flex-direction:column; align-items:flex-end; gap:5px; }
.badge {
  display:inline-block; padding:2px 9px;
  border-radius:20px; font-size:11px; font-weight:600;
}
.badge-selesai { background:#f0fdf4; color:#15803d; }
.badge-proses  { background:#fffbeb; color:#b45309; }
.badge-tunda   { background:#fef2f2; color:#b91c1c; }
.badge-offline { background:#f1f5f9; color:#64748b; }

/* ── Dashboard stats ─────────────────────────────────────── */
.stats-grid {
  display:grid; grid-template-columns:repeat(2,1fr); gap:10px;
  padding:14px; padding-bottom:4px;
}
.stat-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:13px;
}
.stat-card .stat-val { font-size:26px; font-weight:700; color:var(--navy); line-height:1; margin-bottom:4px; }
.stat-card .stat-lbl { font-size:12px; color:var(--muted); }
.stat-card.accent-green { border-left:3px solid var(--green); }
.stat-card.accent-amber { border-left:3px solid var(--amber); }
.stat-card.accent-red   { border-left:3px solid var(--red); }
.stat-card.accent-blue  { border-left:3px solid var(--blue); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align:center; padding:48px 24px;
}
.empty-state i { font-size:48px; color:#cbd5e1; margin-bottom:12px; display:block; }
.empty-state h3 { font-size:16px; font-weight:600; color:var(--muted); margin-bottom:6px; }
.empty-state p  { font-size:13px; color:#94a3b8; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  display:flex; gap:8px; padding:12px 14px 0;
  overflow-x:auto; -webkit-overflow-scrolling:touch;
}
.filter-bar::-webkit-scrollbar { display:none; }
.filter-chip {
  flex-shrink:0; padding:6px 13px; border-radius:20px;
  border:1px solid var(--border); background:#fff;
  font-size:12px; font-weight:500; color:var(--muted);
  cursor:pointer; white-space:nowrap; transition:all 0.15s;
}
.filter-chip.active { background:var(--navy); color:#fff; border-color:var(--navy); }

/* ── Search ──────────────────────────────────────────────── */
.search-bar {
  margin:12px 14px 0;
  display:flex; align-items:center;
  background:var(--surface); border:1px solid var(--border);
  border-radius:9px; padding:0 12px; gap:8px;
}
.search-bar i { font-size:18px; color:var(--muted); flex-shrink:0; }
.search-bar input {
  flex:1; border:none; outline:none; background:none;
  padding:10px 0; font-size:14px; color:var(--text);
}

/* ── Settings ────────────────────────────────────────────── */
.setting-row {
  display:flex; align-items:center; gap:12px;
  padding:14px; border-bottom:1px solid var(--border);
  background:var(--surface); cursor:pointer;
}
.setting-row:last-child { border-bottom:none; }
.setting-row i { font-size:20px; color:var(--navy); width:24px; }
.setting-row .setting-info { flex:1; }
.setting-row .setting-info strong { display:block; font-size:14px; font-weight:500; }
.setting-row .setting-info small  { font-size:12px; color:var(--muted); }
.setting-row .chevron { font-size:18px; color:#cbd5e1; }

/* ── Loading overlay ─────────────────────────────────────── */
.overlay {
  position:fixed; inset:0; background:rgba(15,40,64,0.45);
  z-index:200; display:flex; align-items:center; justify-content:center;
  opacity:0; pointer-events:none; transition:opacity 0.2s;
}
.overlay.show { opacity:1; pointer-events:all; }
.overlay-card {
  background:#fff; border-radius:14px; padding:28px 32px;
  text-align:center; box-shadow:0 8px 32px rgba(0,0,0,0.12);
}
.overlay-card i { font-size:36px; color:var(--blue); display:block; margin-bottom:12px; }
.overlay-card p { font-size:14px; font-weight:500; color:var(--navy); }
.spinner {
  width:36px; height:36px; border:3px solid #dbeafe;
  border-top-color:var(--blue); border-radius:50%;
  animation:spin 0.8s linear infinite; margin:0 auto 12px;
}
@keyframes spin { to{transform:rotate(360deg)} }

/* ── Detail modal ────────────────────────────────────────── */
.modal-overlay {
  position:fixed; inset:0; background:rgba(15,40,64,0.5);
  z-index:100; display:flex; align-items:flex-end;
  opacity:0; pointer-events:none; transition:opacity 0.25s;
}
.modal-overlay.show { opacity:1; pointer-events:all; }
.modal-sheet {
  background:#fff; border-radius:18px 18px 0 0;
  width:100%; max-width:520px; margin:0 auto;
  max-height:88vh; overflow-y:auto;
  transform:translateY(100%); transition:transform 0.3s ease;
}
.modal-overlay.show .modal-sheet { transform:translateY(0); }
.modal-header {
  padding:14px 16px 12px; border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; background:#fff; z-index:1;
}
.modal-header h2 { font-size:16px; font-weight:600; }
.btn-close {
  width:32px; height:32px; border-radius:50%;
  background:#f1f5f9; border:none; cursor:pointer;
  display:flex; align-items:center; justify-content:center; font-size:18px; color:var(--muted);
}
.detail-section { padding:14px 16px; border-bottom:1px solid #f1f5f9; }
.detail-section h3 { font-size:11px; font-weight:700; color:var(--blue); text-transform:uppercase; letter-spacing:0.5px; margin-bottom:10px; }
.detail-row { display:flex; justify-content:space-between; padding:5px 0; font-size:13px; }
.detail-row .lbl { color:var(--muted); }
.detail-row .val { font-weight:500; max-width:55%; text-align:right; }
.modal-actions {
  display:flex; gap:10px; padding:14px;
  position:sticky; bottom:0; background:#fff; border-top:1px solid var(--border);
}

/* ── Config screen ───────────────────────────────────────── */
.config-form {
  padding:20px 14px;
}
.config-title {
  font-size:18px; font-weight:700; color:var(--navy); margin-bottom:4px;
}
.config-sub {
  font-size:13px; color:var(--muted); margin-bottom:20px;
}
.btn-block {
  width:100%; padding:13px; border:none;
  border-radius:9px; background:var(--blue); color:#fff;
  font-size:15px; font-weight:600; cursor:pointer; margin-top:8px;
  transition:background 0.15s;
}
.btn-block:hover { background:#1d4ed8; }
.step-dots { display:flex; gap:6px; justify-content:center; margin-bottom:24px; }
.step-dot { width:8px; height:8px; border-radius:50%; background:#e2e8f0; }
.step-dot.done { background:var(--blue); }
