/* ============================================================
   JOBSITE MODE — Field/Jobsite-Specific Styles
   ============================================================
   Source: css/styles.css lines 1609-1615
   Also includes HandyTime (lines 1543-1607) and
   Time Tracking (lines 1160-1261)
   ============================================================ */

/* ---------- Jobsite Mode ---------- */
#jobsite-container { max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
#js-main-grid { min-width: 0; }
#js-main-grid > div { min-width: 0; overflow: hidden; }
@media (max-width: 900px) {
  #js-main-grid { grid-template-columns: 1fr !important; }
}

/* =============================================
   HANDYTIME — Task Queue & Button Grid (source: lines 1543-1607)
   ============================================= */
.ht-btn-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.ht-btn { min-height: 56px; font-size: 0.9rem; border-radius: var(--radius); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.ht-btn-row { display: flex; gap: 0.5rem; }
.ht-btn-row > * { flex: 1; }

.ht-task-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.35rem 0.4rem; font-size: 0.75rem; min-height: 36px;
  border-bottom: 1px solid rgba(255,255,255,0.04); transition: all 0.15s;
}
.ht-task-active {
  background: rgba(34,197,94,0.06); border-left: 3px solid var(--green);
  padding-left: 0.5rem;
}
.ht-task-done {
  opacity: 0.45; text-decoration: line-through;
}

.ht-drag-handle {
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; margin-right: 0.2rem;
  font-size: 1.1rem; color: var(--gray-500); cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none;
  border-radius: 4px; transition: color 0.15s, background 0.15s;
}
.ht-drag-handle:active { cursor: grabbing; color: var(--gold); background: rgba(212,175,55,0.08); }

.ht-task-dragging {
  opacity: 0.5; transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35); z-index: 100;
  background: var(--navy-lighter); border-radius: 6px;
}

.ht-task-dragover {
  border-top: 2px solid var(--gold) !important;
  background: rgba(212,175,55,0.06);
}

.ht-task-picker-btn:hover, .ht-task-picker-btn:focus {
  background: rgba(212,175,55,0.1) !important; border-color: var(--gold) !important;
}

.ht-task-queue { max-height: 240px; overflow-y: auto; margin-bottom: 0.5rem; -webkit-overflow-scrolling: touch; }
.ht-wellness-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 999;
  background: linear-gradient(135deg, #22c55e, #16a34a); color: white;
  padding: 1rem 1.25rem; text-align: center; font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3); cursor: pointer;
  animation: ht-pulse 2s ease-in-out infinite;
}
#wellness-banner { animation: ht-pulse 2s ease-in-out infinite; }
@keyframes ht-pulse { 0%,100% { opacity:1; } 50% { opacity:0.88; } }

/* V3.15: End-of-day review table */
.ht-review-row { transition: all 0.15s; }
.ht-review-row:hover { background: rgba(255,255,255,0.04) !important; }
.ht-speed-btn { transition: all 0.15s !important; }
.ht-speed-btn:hover { opacity: 0.85; }

@media (pointer: coarse) {
  .ht-btn { min-height: 56px; }
  .ht-task-item { min-height: 44px; padding: 0.4rem 0.5rem; }
  .ht-task-picker-btn { min-height: 52px !important; }
}

/* =============================================
   TIME TRACKING TAB (source: lines 1160-1261)
   ============================================= */
@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Weekly bar chart */
.tt-bar-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; font-size: 0.78rem; }
.tt-bar-label { width: 40px; color: var(--gray-400); font-weight: 600; text-align: right; flex-shrink: 0; }
.tt-bar-track { flex: 1; height: 22px; background: var(--navy); border-radius: 4px; overflow: hidden; position: relative; }
.tt-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold)); border-radius: 4px; transition: width 0.4s ease; min-width: 0; }
.tt-bar-value { width: 50px; color: var(--champagne); font-size: 0.72rem; font-weight: 600; text-align: left; flex-shrink: 0; }
.tt-bar-today .tt-bar-fill { background: linear-gradient(90deg, rgba(34,197,94,0.4), var(--green)); }

/* Time log entries */
.tt-log-entry { padding: 0.6rem 0; border-bottom: 1px solid var(--navy-lighter); }
.tt-log-entry:last-child { border-bottom: none; }
.tt-log-header { display: flex; justify-content: space-between; align-items: flex-start; }
.tt-log-customer { font-size: 0.88rem; font-weight: 600; color: var(--champagne); }
.tt-log-job { font-size: 0.75rem; color: var(--gray-400); }
.tt-log-time { font-size: 0.72rem; color: var(--gray-500); margin-top: 0.15rem; }
.tt-log-duration { font-size: 0.92rem; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.tt-log-rate { font-size: 0.68rem; color: var(--green); font-weight: 600; }
.tt-log-subtasks { padding-left: 0.75rem; margin-top: 0.25rem; }
.tt-log-subtask { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--gray-400); padding: 0.1rem 0; }
.tt-log-actions { display: flex; gap: 0.3rem; margin-top: 0.25rem; }
.tt-log-actions button { font-size: 0.65rem; padding: 0.15rem 0.4rem; }

/* Timer running state glow on card */
#tt-active-timer-card.tt-running { border-color: var(--green); box-shadow: 0 0 12px rgba(34,197,94,0.15); }
#tt-active-timer-card.tt-paused { border-color: var(--orange); box-shadow: 0 0 12px rgba(245,158,11,0.15); }

/* Header timer indicator */
#header-timer-indicator {
  display: none;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.72rem;
  white-space: nowrap;
  transition: all 0.2s;
}
#header-timer-indicator:hover {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.5);
}
#header-timer-indicator .timer-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  animation: timerPulse 1.5s ease-in-out infinite;
}
#header-timer-time {
  font-weight: 600; color: var(--green);
  font-variant-numeric: tabular-nums;
}
#header-timer-name {
  color: var(--gray-300);
  max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Time tracking summary card on hub */
.time-track-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}
.time-track-stat {
  text-align: center; padding: 0.5rem;
  background: var(--navy); border-radius: var(--radius); border: 1px solid var(--navy-lighter);
}
.time-track-stat .stat-value {
  font-size: 1.3rem; font-weight: 700; color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.time-track-stat .stat-label {
  font-size: 0.68rem; color: var(--gray-400); text-transform: uppercase;
  letter-spacing: 0.3px;
}
.time-track-stat .stat-sub {
  font-size: 0.65rem; color: var(--gray-500); margin-top: 0.1rem;
}

body.day-mode #header-timer-indicator { background: rgba(34,197,94,0.08); }

/* =============================================
   PARTS PICKER AI (source: lines 1619-1657)
   ============================================= */
.pp-msg { max-width: 85%; padding: 0.6rem 0.75rem; border-radius: 12px; font-size: 0.82rem; line-height: 1.45; word-wrap: break-word; }
.pp-msg-user { align-self: flex-end; background: var(--gold); color: var(--navy); border-bottom-right-radius: 4px; }
.pp-msg-ai { align-self: flex-start; background: var(--navy-lighter); color: var(--champagne); border-bottom-left-radius: 4px; }
.pp-msg-ai p { margin: 0 0 0.4rem 0; }
.pp-msg-ai p:last-child { margin-bottom: 0; }
.pp-msg-ai ul, .pp-msg-ai ol { margin: 0.3rem 0; padding-left: 1.2rem; }
.pp-msg-ai li { margin-bottom: 0.2rem; }
.pp-msg-ai strong { color: var(--gold); }
.pp-msg-images { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.pp-msg-images img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 1px solid rgba(255,255,255,0.1); }
.pp-msg-time { font-size: 0.62rem; color: var(--gray-500); margin-top: 0.25rem; }
.pp-msg-user .pp-msg-time { color: rgba(10,25,47,0.5); }
.pp-typing { align-self: flex-start; padding: 0.6rem 0.75rem; background: var(--navy-lighter); border-radius: 12px; border-bottom-left-radius: 4px; font-size: 0.78rem; color: var(--gray-400); }
.pp-typing::after { content: ''; display: inline-block; animation: pp-dots 1.4s steps(4) infinite; }
@keyframes pp-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.pp-part-item { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.45rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.pp-part-item:last-child { border-bottom: none; }
.pp-part-check { min-width: 22px; min-height: 22px; width: 22px; height: 22px; border-radius: 4px; border: 2px solid var(--gray-600); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; margin-top: 2px; transition: all 0.2s; }
.pp-part-check.checked { background: var(--gold); border-color: var(--gold); }
.pp-part-check.checked::after { content: '\2713'; color: var(--navy); font-size: 0.7rem; font-weight: 700; }
.pp-part-got .pp-part-name { text-decoration: line-through; opacity: 0.5; }
.pp-part-name { font-weight: 600; color: var(--champagne); font-size: 0.78rem; }
.pp-part-spec { font-size: 0.68rem; color: var(--gray-400); }
.pp-part-meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.15rem; }
.pp-part-price { font-size: 0.72rem; color: var(--gold); font-weight: 600; }
.pp-part-qty { font-size: 0.68rem; color: var(--gray-400); }
.pp-hd-link { font-size: 0.62rem; color: #F96302; text-decoration: none; font-weight: 600; }
.pp-hd-link:hover { text-decoration: underline; }
.pp-img-thumb { display: inline-block; position: relative; margin-right: 0.35rem; }
.pp-img-thumb img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid var(--glass-border); }
.pp-img-thumb-remove { position: absolute; top: -4px; right: -4px; width: 18px; height: 18px; border-radius: 50%; background: var(--red); color: white; border: none; font-size: 0.55rem; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
@keyframes ppBlink { 0%,80%,100% { opacity: 0; } 40% { opacity: 1; } }
@media (max-width: 768px) {
  #pp-layout { grid-template-columns: 1fr !important; }
  #pp-layout > .card:last-child { order: -1; max-height: 200px; }
  .pp-msg { max-width: 92%; }
  .fb-stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
