/* ============================================================
   NHH Project Tracker — light theme
   ============================================================ */

:root {
  --bg:         #ffffff;
  --bg-2:       #f8fafc;
  --bg-3:       #f1f5f9;
  --primary:    #2563eb;
  --primary-hover:#1d4ed8;
  --accent:     #f97316;
  --green:      #16a34a;
  --yellow:     #ca8a04;
  --pink:       #db2777;
  --purple:     #7c3aed;
  --teal:       #0d9488;
  --text:       #0f172a;
  --muted:      #475569;
  --border:     rgba(0,0,0,0.08);
  --shadow:     0 6px 20px rgba(0,0,0,0.06);
  --radius:     18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: #ffffff !important;
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* Navbar */
.navbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(140%) blur(18px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.navbar-brand {
  font-weight: 800; font-size: 1.05rem; letter-spacing: 0.2px;
  color: #0f172a;
}
.navbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.brand-line { display:flex; align-items:center; justify-content:space-between; padding: 10px 16px 6px 16px; }
.brand-title { font-weight:800; font-size:1.1rem; color:#0f172a; letter-spacing:0.2px; }
.brand-logo { height:48px; width:48px; display:block; object-fit:contain; flex-shrink:0; margin-top:19px; }
.nav-link {
  color: #1e293b; text-decoration: none; font-size: 0.88rem; font-weight: 600;
  padding: 8px 10px; border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-link:hover { background: #eef2ff; color: #2563eb; }
.nav-logout { opacity: 0.75; }
.user-badge { font-size: 0.78rem; opacity: 0.85; }

/* Content wrapper */
.content { max-width: 960px; margin: 0 auto; padding: 18px 16px; }

/* Cards + surfaces */
.login-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px 22px;
  max-width: 390px; width: 100%;
}
.job-card, .rec-card, .stat-card, .login-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.job-card { padding: 18px; }

/* Typography */
.job-address { font-weight: 800; font-size: 1.1rem; margin-bottom: 10px; }
.page-header { display: flex; align-items: center; gap: 12px; margin: 18px 0; flex-wrap: wrap; }
.page-header h2 { margin: 0; font-weight: 800; letter-spacing: 0.2px; }
.phase-header {
  background: #f1f5f9;
  color: #0f172a;
  padding: 14px 16px;
  font-weight: 700; font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff; border: none; padding: 10px 16px; border-radius: 999px;
  font-size: 0.92rem; font-weight: 700; cursor: pointer; text-decoration: none;
  box-shadow: 0 8px 18px rgba(37,99,235,0.18);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(37,99,235,0.25); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%); }
.btn-secondary {
  background: transparent; color: #0f172a; border: 1.5px solid #cbd5e1;
  box-shadow: none;
}
.btn-secondary:hover { background: #f8fafc; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; border-radius: 999px; }
.btn-back { background: transparent; color: #2563eb; padding: 4px 8px; box-shadow: none; }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* Pill badges */
.badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge-pct { background: #eef2ff; color: #1e40af; }
.badge-ok { background: #dcfce7; color: #14532d; }
.badge-alert { background: #fee2e2; color: #450a0a; }

/* Progress */
.progress-bar { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #16a34a); border-radius: 999px; }
.job-stats { font-size: 0.82rem; color: var(--muted); }

/* Checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.phase-header { cursor: pointer; user-select: none; }
.phase-header .phase-toggle { display: inline-block; width: 20px; transition: transform 0.2s ease; font-size: 0.8rem; cursor: pointer; }
.phase-header { cursor: pointer; }
.phase-block.collapsed .phase-toggle { transform: rotate(-90deg); }
.phase-block.collapsed .phase-items { display: none; }
.phase-meta { font-size: 0.8rem; font-weight: 700; opacity: 0.8; margin-left: 8px; }

.checklist-item { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.section-jump { padding: 8px 12px; border-radius: 999px; border: 1px solid #cbd5e1; background: #ffffff; color: #0f172a; font-size: 0.88rem; font-weight: 700; }
.checklist-item:last-child { border-bottom: none; }
.item-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.item-number { font-weight: 800; line-height: 1.5; flex-shrink: 0; color: #2563eb; }
.item-text { flex: 1; font-size: 0.95rem; line-height: 1.5; }
.item-status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

/* Modal */
.photo-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.85);
  align-items: center; justify-content: center;
  z-index: 9999;
}
.photo-modal img { max-width: 92vw; max-height: 92vh; border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,0.6); }
.hidden-file-input {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Notes */
.note-panel { margin-top: 12px; }
.note-textarea {
  width: 100%; padding: 12px;
  background: #ffffff; color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-family: inherit; font-size: 0.92rem; resize: vertical; min-height: 64px;
}
.note-actions { display: flex; gap: 10px; margin-top: 10px; justify-content: flex-end; }
.item-note-display {
  background: #eef2ff; border-left: 3px solid #2563eb;
  padding: 10px 14px; border-radius: 12px; font-size: 0.88rem; margin-top: 10px;
}

/* Photos */
.photo-thumbs { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.photo-thumb {
  width: 96px; height: 96px; border-radius: 12px; overflow: hidden;
  cursor: pointer; box-shadow: var(--shadow); position: relative; background: #fff;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove {
  position: absolute; top: 4px; right: 4px;
  background: rgba(15,23,42,0.8); color: #fff; border: none;
  border-radius: 999px; padding: 2px 9px; font-size: 0.72rem; font-weight: 700; cursor: pointer;
}

/* Status controls */

.alert-item.status-completed { border-left: 5px solid #16a34a; opacity: 0.82; }
.alert-item.status-completed .alert-item-text { color: #15803d; }
.completed-section { margin-top: 18px; border-top: 2px dashed var(--border); padding-top: 12px; }
.completed-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 10px;
  font-weight: 700; color: #15803d; cursor: pointer; user-select: none;
}
.completed-toggle:hover { background: #d1fae5; }
#completed-caret { font-size: 0.8rem; }
.completed-list { margin-top: 10px; }

/* Subitems — checklist-style (colored tappable checkbox + status pill, connector line) */
.subitems-block { margin-top: 10px; margin-left: 36px; padding-left: 18px; border-left: 2px solid #e2e8f0; }
.subitems-label { font-size: 0.7em; color: #94a3b8; font-weight: 700; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.subitem-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.subitem-check { width: 20px; height: 20px; border-radius: 5px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: #fff; cursor: pointer; border: 2px solid #cbd5e1; background: #fff; transition: background .15s, border-color .15s; user-select: none; }
.subitem-check.s-not_started { background: #fff; color: #94a3b8; }
.subitem-check.s-in_progress { background: #f59e0b; border-color: #f59e0b; }
.subitem-check.s-completed { background: #16a34a; border-color: #16a34a; }
.subitem-text { flex: 1; font-size: 0.9em; color: #334155; }
.subitem-pill { padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 11px; cursor: pointer; user-select: none; border: 1px solid transparent; }
.subitem-pill.s-not_started { background: #f1f5f9; color: #475569; }
.subitem-pill.s-in_progress { background: #fef3c7; color: #b45309; }
.subitem-pill.s-completed { background: #dcfce7; color: #15803d; }
.subitem-del { font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid #fecaca; background: #fff; color: #b91c1c; cursor: pointer; }

/* Item-level status pill (tappable, opens shared popover) — matches subitem style */
.status-pill { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 0.85rem; cursor: pointer; border: 1.5px solid transparent; user-select: none; }
.status-pill .status-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.status-pill .status-caret { margin-left: 2px; font-size: 10px; opacity: .55; }
.status-pill.s-not_started { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.status-pill.s-in_progress { background: #fef9c3; color: #854d0e; border-color: #fcd34d; }
.status-pill.s-completed { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-dot.s-not_started { background: #94a3b8; }
.status-dot.s-in_progress { background: #f59e0b; }
.status-dot.s-completed { background: #16a34a; }

/* status popover */
.subitem-pop { position: absolute; z-index: 60; background: #fff; border: 1px solid #cbd5e1; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 6px; min-width: 160px; display: none; }
.subitem-pop.open { display: block; }
.subitem-pop .pop-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.subitem-pop .pop-item:hover { background: #f1f5f9; }
.subitem-pop .pop-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.pop-dot.s-not_started { background: #94a3b8; }
.pop-dot.s-in_progress { background: #f59e0b; }
.pop-dot.s-completed { background: #16a34a; }

/* Checklist - bolder colors */
.checklist-item.status-not_started { background: #cbd5e1; border-left: 5px solid #475569; }
.checklist-item.status-in_progress { background: #fbbf24; border-left: 5px solid #b45309; }
.checklist-item.status-completed { background: #4ade80; border-left: 5px solid #15803d; }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 360px; }
.admin-table th, .admin-table td { padding: 12px 10px; border-bottom: 1px solid var(--border); color: #0f172a; }
.admin-table th { background: #f8fafc; font-weight: 700; letter-spacing: 0.2px; }
.admin-table tbody tr:nth-child(odd) td { background: #ffffff; }
.admin-table tbody tr:nth-child(even) td { background: #f8fafc; }
.admin-table tbody tr:hover td { background: #eef2ff; }
.admin-table tbody tr.status-not_started td { background: #f8fafc; }
.admin-table tbody tr.status-in_progress td { background: #fffbeb; }
.admin-table tbody tr.status-completed td { background: #f0fdf4; }
.admin-table tbody tr.status-not_started td:first-child { box-shadow: inset 4px 0 0 #64748b; }
.admin-table tbody tr.status-in_progress td:first-child { box-shadow: inset 4px 0 0 #d97706; }
.admin-table tbody tr.status-completed td:first-child { box-shadow: inset 4px 0 0 #15803d; }

/* Animations */
[data-highlighted] { animation: jumpPulse 1.6s ease-in-out; }
@keyframes jumpPulse {
  0% { box-shadow: inset 0 0 0 0 rgba(37,99,235,0); }
  40% { box-shadow: inset 0 0 0 6px rgba(37,99,235,0.25); }
  100% { box-shadow: inset 0 0 0 0 rgba(37,99,235,0); }
}
li[data-highlighted="1"] { animation: jumpPulseLi 1.6s ease-in-out; }
@keyframes jumpPulseLi {
  0% { background-color: rgba(37,99,235,0); }
  40% { background-color: rgba(37,99,235,0.15); }
  100% { background-color: rgba(37,99,235,0); }
}

/* Misc */
.alert { padding: 14px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.alert-error { background: #fee2e2; color: #450a0a; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.footer { text-align: center; padding: 22px; color: var(--muted); font-size: 0.78rem; }
.lang-toggle {
  background: #2563eb; color: #fff; border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 800; cursor: pointer;
}
.login-card h1 { color: #0f172a; text-align: center; margin-top: 0; }
.login-logo { display: block; width: 120px; max-width: 100%; height: auto; margin: 0 auto 16px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.login-form label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 0.88rem; color: #0f172a; }
.login-form input, .rec-form textarea {
  width: 100%; padding: 12px;
  background: #ffffff; color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; font-size: 1rem;
}
.header-logo { height: 28px; width: auto; display: inline-block; margin-left: 8px; vertical-align: middle; }
.rec-form { display: block; width: 100%; max-width: 640px; }
.rec-form-title { font-weight: 800; font-size: 1.05rem; color: #0f172a; display: block; margin: 0 0 8px; }
.rec-form-textarea { display: block; width: 100%; padding: 12px; background: #ffffff; color: var(--text); border: 1px solid var(--border); border-radius: 14px; font-size: 1rem; resize: vertical; min-height: 96px; box-sizing: border-box; }
.rec-form-submit { display: inline-block; margin-top: 10px; }
.login-form label { font-weight: 700; font-size: 0.88rem; color: #0f172a; }

/* Responsive */
@media (max-width: 520px) {
  .navbar { padding: 10px 12px; }
  .content { padding: 14px 12px; }
}

/* High Priority page */
.job-card { background: #fff; border-radius: 12px; margin-bottom: 16px; box-shadow: var(--shadow); }
.job-address { padding: 14px 16px; font-weight: 700; border-bottom: 1px solid var(--border); }
.job-address a { color: #0f172a; text-decoration: none; }
.alert-list { padding: 0; }
.alert-item { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.alert-item.status-not_started { background: #cbd5e1; border-left: 5px solid #475569; }
.alert-item.status-in_progress { background: #fbbf24; border-left: 5px solid #b45309; }
.alert-item.status-completed { background: #4ade80; border-left: 5px solid #15803d; }
.alert-item:last-child { border-bottom: none; }
.alert-item-text { font-size: 0.95rem; line-height: 1.5; margin-bottom: 6px; }
.alert-item-actions { display: flex; align-items: center; gap: 12px; }
