/* ===================== IkiMochi Ops - Design System ===================== */
/* Mobile-first, warm street-food palette, thumb-friendly touch targets */

:root {
  --primary: #E85D75;       /* warm raspberry-pink, brand */
  --primary-dark: #C43F58;
  --primary-light: #FBE4E9;
  --accent: #F2A65A;        /* warm caramel/mochi orange */
  --accent-dark: #D98730;
  --bg: #FFF8F1;             /* warm cream background */
  --card: #FFFFFF;
  --border: #F0E0D6;
  --text: #3A2B27;           /* warm dark brown */
  --muted: #8A7A72;
  --success: #3F9D63;
  --success-light: #E4F5EA;
  --warning: #E8A33D;
  --warning-light: #FCF0DA;
  --danger: #E15252;
  --danger-light: #FBE7E5;
  --info: #4A90B8;
  --info-light: #E8F2F7;
  --radius: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: var(--safe-bottom);
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.4rem; margin: 0 0 12px; font-weight: 800; }
h2 { font-size: 1.1rem; margin: 0 0 10px; font-weight: 700; }
h3 { font-size: 1rem; margin: 0 0 8px; font-weight: 700; }

/* ===================== Layout ===================== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}
body.has-bottom-nav .container {
  padding-bottom: calc(84px + var(--safe-bottom));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(58, 43, 39, 0.04);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ===================== Top header (slim, for gudang/outlet) ===================== */
.top-header {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-header .brand { font-weight: 800; font-size: 1.05rem; }
.top-header .brand a { color: #fff; }
.top-header .right { display: flex; align-items: center; gap: 10px; }
.top-header .bell { color: #fff; position: relative; font-size: 1.3rem; }
.top-header .badge {
  position: absolute; top: -6px; right: -10px;
  background: #fff; color: var(--danger); border-radius: 10px;
  padding: 0 5px; font-size: 0.65rem; font-weight: 800; min-width: 16px; text-align: center;
}
.top-header .user-chip { font-size: 0.8rem; opacity: 0.95; }
.top-header .link-btn { background: none; border: none; color: #fff; font-size: 0.85rem; text-decoration: underline; padding: 0; cursor: pointer; }

/* ===================== Admin/Owner full top nav (wraps on mobile) ===================== */
.topnav {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topnav a { color: #fff; margin-right: 2px; font-size: 0.9rem; }
.topnav a:hover { text-decoration: underline; }
.topnav-brand a { font-weight: 800; font-size: 1.05rem; }
.topnav-links { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; row-gap: 6px; }
.topnav-sep { opacity: 0.55; }
.topnav-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-chip { background: rgba(255,255,255,0.22); padding: 4px 10px; border-radius: 12px; font-size: 0.78rem; }
.link-btn { background: none; border: none; color: #fff; cursor: pointer; text-decoration: underline; font-size: 0.85rem; padding: 0; }
.bell { position: relative; }
.badge {
  background: #fff; color: var(--danger); border-radius: 10px;
  padding: 0 6px; font-size: 0.7rem; font-weight: 800; margin-left: 3px;
}

/* ===================== Bottom tab bar (gudang/outlet, mobile-first) ===================== */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(58,43,39,0.06);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 2px 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  min-height: 56px;
}
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a .icon { font-size: 1.35rem; line-height: 1; }
.bottom-nav a.active { color: var(--primary-dark); }
.bottom-nav a .icon-wrap { position: relative; }
.bottom-nav .nav-badge {
  position: absolute; top: -4px; right: -10px;
  background: var(--danger); color: #fff; border-radius: 10px;
  padding: 0 5px; font-size: 0.6rem; font-weight: 800; min-width: 15px; text-align: center;
}

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  min-height: 48px;
  min-width: 48px;
  line-height: 1.2;
  transition: transform 0.06s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #E9DED7; color: var(--text); }
.btn-secondary:hover { background: #DED0C6; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #C43F3F; }
.btn-ok { background: var(--success); }
.btn-ok:hover { background: #327F50; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; min-height: 40px; }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 1.1rem; min-height: 56px; }

form.inline { display: inline; }

/* Sticky action bar - keeps the primary CTA thumb-reachable at the bottom of forms */
.sticky-action-bar {
  position: sticky;
  bottom: calc(var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 14px 0 10px;
  margin-top: 10px;
  display: flex;
  gap: 10px;
}
body.has-bottom-nav .sticky-action-bar { bottom: calc(72px + var(--safe-bottom)); }

/* ===================== Forms ===================== */
label { display: block; margin: 14px 0 6px; font-weight: 700; font-size: 0.88rem; color: var(--text); }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=file], select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--card);
  color: var(--text);
  min-height: 48px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
textarea { min-height: 90px; }
input:disabled { background: #F5EFE9; color: var(--muted); }

/* ===================== Tables (responsive scroll) ===================== */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; min-width: 420px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { background: var(--primary-light); color: var(--primary-dark); font-weight: 700; white-space: nowrap; }
tr:hover { background: #FFFBF7; }

/* ===================== Badges/status ===================== */
.badge-status { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; }
.badge-draft { background: #EFE7E1; color: var(--muted); }
.badge-dikirim { background: var(--warning-light); color: var(--warning); }
.badge-diterima { background: var(--success-light); color: var(--success); }
.badge-bermasalah { background: var(--danger-light); color: var(--danger); }
.badge-low { background: var(--danger-light); color: var(--danger); }
.badge-ok { background: var(--success-light); color: var(--success); }

/* ===================== Toasts (replaces alert()/flash-div) ===================== */
#toast-region {
  position: fixed;
  left: 0; right: 0;
  top: calc(12px + var(--safe-top));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 14px;
}
.toast {
  pointer-events: auto;
  max-width: 480px;
  width: 100%;
  background: var(--text);
  color: #fff;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
.toast .icon { font-size: 1.1rem; }

/* legacy inline flash (still used as fallback / non-JS) */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.9rem; font-weight: 600; }
.flash-success { background: var(--success-light); color: var(--success); border: 1px solid #BFE3CA; }
.flash-error { background: var(--danger-light); color: var(--danger); border: 1px solid #F0C4BD; }
.flash-info { background: var(--info-light); color: var(--info); border: 1px solid #C8DEF0; }

/* ===================== Progress bar ===================== */
.progress-wrap { margin: 6px 0 4px; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.progress-track { background: var(--border); border-radius: 20px; height: 12px; overflow: hidden; }
.progress-fill { background: var(--success); height: 100%; border-radius: 20px; transition: width 0.3s ease; }
.progress-fill.zero { background: var(--border); }

/* ===================== Task/checklist rows ===================== */
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--card);
}
.task-row.done { background: var(--success-light); border-color: #BFE3CA; }
.task-row .title { font-weight: 600; font-size: 0.95rem; }
.task-row .shift-tag { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.task-toggle {
  min-width: 48px; min-height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.task-toggle.checked { background: var(--success); border-color: var(--success); color: #fff; }

/* ===================== Misc ===================== */
.helper-text { color: var(--muted); font-size: 0.85rem; }
.login-wrap { max-width: 420px; margin: 0 auto; padding: 24px 16px; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.team-btn {
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  min-height: 64px;
}
.team-btn:hover { border-color: var(--primary); text-decoration: none; }
.team-btn .emoji { font-size: 1.6rem; }
.team-btn.owner { border-style: dashed; color: var(--muted); }

.stat-tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; min-width: 130px; flex: 1; }
.stat-tile .num { font-size: 1.6rem; font-weight: 800; color: var(--primary-dark); }
.stat-tile .label { color: var(--muted); font-size: 0.78rem; }

canvas.sig-pad { border: 1.5px dashed var(--border); border-radius: var(--radius-sm); background: #fff; touch-action: none; width: 100%; max-width: 320px; height: auto; }

.gps-status { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 600; margin-top: 8px; }
.gps-status.pending { background: var(--warning-light); color: var(--warning); }
.gps-status.ok { background: var(--success-light); color: var(--success); }
.gps-status.error { background: var(--danger-light); color: var(--danger); }

.selfie-preview { width: 100%; max-width: 240px; border-radius: var(--radius); border: 2px solid var(--border); display: block; margin-top: 10px; }
.selfie-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; max-width: 240px; aspect-ratio: 1 / 1;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--primary-light); color: var(--primary-dark);
  font-weight: 700; cursor: pointer; font-size: 0.95rem;
}
.selfie-btn .icon { font-size: 2.2rem; }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  .container { max-width: 900px; }
}
