/* ============================================================
   PR309 Daily Reports — TradeRail Field Portal
   All styles scoped to .pr309-* prefix
   ============================================================ */

/* ── Root container ──────────────────────────────────────────────────────── */
.pr309-root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  background: #f7f8fb;
  min-height: 400px;
  position: relative;
}

/* ── Lily bar ────────────────────────────────────────────────────────────── */
.pr309-lily-bar {
  background: #eef2ff;
  border-left: 4px solid #4f46e5;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #3730a3;
  margin-bottom: 0;
}

.pr309-lily-bar-text {
  flex: 1;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.pr309-header {
  background: #fff;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e5e7eb;
}

.pr309-page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  color: #111827;
}

.pr309-lily-subtitle {
  font-size: 13px;
  color: #4f46e5;
  margin-bottom: 10px;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.pr309-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ── View toggle ─────────────────────────────────────────────────────────── */
.pr309-view-toggle {
  display: flex;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
}

.pr309-view-btn {
  background: #fff;
  border: none;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: #374151;
  transition: background 0.15s;
}

.pr309-view-btn:hover {
  background: #f3f4f6;
}

.pr309-view-btn-active {
  background: #4f46e5;
  color: #fff;
}

.pr309-view-btn-active:hover {
  background: #4338ca;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.pr309-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.pr309-btn:hover {
  background: #f3f4f6;
}

.pr309-btn-primary {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

.pr309-btn-primary:hover {
  background: #4338ca;
  border-color: #4338ca;
}

.pr309-btn-secondary {
  background: #6b7280;
  color: #fff;
  border-color: #6b7280;
}

.pr309-btn-secondary:hover {
  background: #4b5563;
}

.pr309-btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.pr309-btn-ack {
  background: #059669;
  color: #fff;
  border-color: #059669;
}

.pr309-btn-ack:hover {
  background: #047857;
}

.pr309-btn-confirm {
  background: #f59e0b;
  color: #fff;
  border-color: #f59e0b;
}

.pr309-btn-back {
  background: transparent;
  border: none;
  color: #4f46e5;
  padding: 4px 0;
  font-size: 13px;
}

.pr309-btn-back:hover {
  text-decoration: underline;
}

.pr309-btn-lily {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}

.pr309-btn-lily:hover {
  background: #6d28d9;
}

.pr309-btn-remove {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* ── Download button ─────────────────────────────────────────────────────── */
.pr309-dl-btn {
  background: #0369a1;
  color: #fff;
  border-color: #0369a1;
}

.pr309-dl-btn:hover {
  background: #0284c7;
}

/* ── Content area ────────────────────────────────────────────────────────── */
.pr309-content {
  padding: 16px 20px;
}

/* ── Calendar navigation ─────────────────────────────────────────────────── */
.pr309-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pr309-cal-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.pr309-cal-arrow {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  transition: background 0.15s;
}

.pr309-cal-arrow:hover {
  background: #f3f4f6;
}

/* ── Calendar grid ───────────────────────────────────────────────────────── */
.pr309-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
}

.pr309-cal-header-cell {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  padding: 4px 0;
  letter-spacing: 0.04em;
}

.pr309-cal-day {
  min-height: 52px;
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: #f9fafb;
  border: 1px solid transparent;
  position: relative;
}

.pr309-cal-day-num {
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

.pr309-cal-empty {
  background: transparent;
  border-color: transparent;
}

.pr309-cal-today {
  border-color: #4f46e5 !important;
  background: #eef2ff;
}

.pr309-cal-today .pr309-cal-day-num {
  color: #4f46e5;
  font-weight: 700;
}

.pr309-cal-day-clickable {
  cursor: pointer;
}

.pr309-cal-day-clickable:hover {
  background: #f0f4ff;
  border-color: #c7d2fe;
}

/* ── Calendar dots ───────────────────────────────────────────────────────── */
.pr309-cal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
}

.pr309-cal-dot-green {
  background: #059669;
}

.pr309-cal-dot-blue {
  background: #2563eb;
}

.pr309-cal-dot-red {
  background: #dc2626;
}

.pr309-cal-dot-gray {
  background: #d1d5db;
}

/* ── Calendar legend ─────────────────────────────────────────────────────── */
.pr309-cal-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 12px;
  color: #6b7280;
  flex-wrap: wrap;
}

.pr309-cal-legend .pr309-cal-dot {
  margin-top: 0;
  vertical-align: middle;
}

/* ── List view ───────────────────────────────────────────────────────────── */
.pr309-list-filters {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  font-size: 13px;
  flex-wrap: wrap;
}

.pr309-filter-select {
  border: 1px solid #d1d5db;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 13px;
  background: #fff;
  margin-left: 4px;
}

.pr309-missing-alert {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #dc2626;
  cursor: pointer;
}

.pr309-list-table-wrap {
  overflow-x: auto;
}

.pr309-list-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  font-size: 13px;
}

.pr309-list-table th {
  background: #f3f4f6;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.pr309-list-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: middle;
}

.pr309-list-table tr:last-child td {
  border-bottom: none;
}

.pr309-list-table tr:hover td {
  background: #f9fafb;
}

.pr309-actions-cell {
  white-space: nowrap;
}

.pr309-empty-state {
  text-align: center;
  color: #9ca3af;
  padding: 24px;
  font-size: 14px;
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.pr309-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.pr309-badge-submitted {
  background: #dbeafe;
  color: #1d4ed8;
}

.pr309-badge-acknowledged {
  background: #d1fae5;
  color: #065f46;
}

.pr309-badge-draft {
  background: #f3f4f6;
  color: #6b7280;
}

.pr309-badge-missing {
  background: #fee2e2;
  color: #dc2626;
}

/* ── Flag indicators ─────────────────────────────────────────────────────── */
.pr309-flag-red {
  color: #dc2626;
  font-weight: 600;
}

.pr309-flag-orange {
  color: #d97706;
  font-weight: 600;
}

/* ── Detail view ─────────────────────────────────────────────────────────── */
.pr309-detail {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}

.pr309-detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pr309-detail-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pr309-detail-date {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.pr309-detail-meta {
  font-size: 13px;
  color: #6b7280;
}

/* ── Detail sections ─────────────────────────────────────────────────────── */
.pr309-detail-section {
  border-bottom: 1px solid #f3f4f6;
}

.pr309-detail-section:last-of-type {
  border-bottom: none;
}

.pr309-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  cursor: pointer;
  background: #fafafa;
  user-select: none;
  transition: background 0.12s;
}

.pr309-section-header:hover {
  background: #f3f4f6;
}

.pr309-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.pr309-section-chevron {
  font-size: 12px;
  color: #9ca3af;
}

.pr309-section-body {
  padding: 14px 20px;
}

.pr309-section-collapsed .pr309-section-body {
  display: none;
}

/* ── Crew list ───────────────────────────────────────────────────────────── */
.pr309-crew-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pr309-crew-list li {
  background: #f3f4f6;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pr309-walk-on-tag {
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

/* ── Weather ─────────────────────────────────────────────────────────────── */
.pr309-weather-row {
  font-size: 14px;
  color: #374151;
  line-height: 1.6;
}

.pr309-weather-notes {
  margin-top: 6px;
  font-size: 13px;
  color: #6b7280;
  font-style: italic;
}

/* ── Work performed cards ────────────────────────────────────────────────── */
.pr309-work-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.pr309-work-phase {
  font-size: 13px;
  font-weight: 600;
  color: #1d4ed8;
  margin-bottom: 4px;
}

.pr309-work-desc {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  margin-bottom: 6px;
}

.pr309-work-pct {
  font-size: 12px;
  color: #059669;
  font-weight: 600;
}

/* ── Hours ───────────────────────────────────────────────────────────────── */
.pr309-hours-row {
  font-size: 14px;
  color: #374151;
}

/* ── Inner tables ────────────────────────────────────────────────────────── */
.pr309-inner-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pr309-inner-table th {
  background: #f9fafb;
  padding: 7px 10px;
  text-align: left;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}

.pr309-inner-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.pr309-inner-table tr:last-child td {
  border-bottom: none;
}

/* ── Safety banners ──────────────────────────────────────────────────────── */
.pr309-safety-ok {
  background: #d1fae5;
  color: #065f46;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid #059669;
}

.pr309-safety-incident {
  border-left: 4px solid #dc2626;
  padding-left: 12px;
}

.pr309-incident-card {
  background: #fff1f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.6;
}

/* ── Delay banners ───────────────────────────────────────────────────────── */
.pr309-delay-none {
  background: #d1fae5;
  color: #065f46;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid #059669;
}

.pr309-delay-occurred {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #d97706;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.6;
}

/* ── Photo grid ──────────────────────────────────────────────────────────── */
.pr309-photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 0;
}

.pr309-photo-thumb {
  width: 100px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.pr309-photo-thumb img {
  width: 100%;
  height: 70px;
  object-fit: cover;
  display: block;
}

.pr309-photo-caption {
  padding: 4px 6px;
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  word-break: break-word;
}

.pr309-photo-grid-form .pr309-photo-thumb {
  cursor: pointer;
}

.pr309-photo-note {
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
}

/* ── Detail actions ──────────────────────────────────────────────────────── */
.pr309-detail-actions {
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  background: #fafafa;
}

/* ── Form ────────────────────────────────────────────────────────────────── */
.pr309-form {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
  position: relative;
}

.pr309-form-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.pr309-form-title {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 4px;
}

.pr309-form-date-display {
  font-size: 14px;
  color: #6b7280;
}

/* ── Progress dots ───────────────────────────────────────────────────────── */
.pr309-progress-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
}

.pr309-progress-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  transition: background 0.2s;
}

.pr309-progress-dot.pr309-progress-dot-done {
  background: #059669;
}

.pr309-progress-dot.pr309-progress-dot-active {
  background: #4f46e5;
}

/* ── Form sections ───────────────────────────────────────────────────────── */
.pr309-form-section {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}

.pr309-fs-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 12px;
}

.pr309-field {
  margin-bottom: 12px;
}

.pr309-field label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

.pr309-field-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pr309-field-row .pr309-field {
  flex: 1;
  min-width: 140px;
}

.pr309-field-sm {
  max-width: 120px;
}

.pr309-required {
  color: #dc2626;
}

/* ── Form inputs ─────────────────────────────────────────────────────────── */
.pr309-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #1a1a2e;
  background: #fff;
  box-sizing: border-box;
  min-height: 38px;
  transition: border-color 0.15s;
}

.pr309-input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px #eef2ff;
}

.pr309-input-sm {
  width: 80px;
  min-width: 80px;
}

.pr309-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #1a1a2e;
  background: #fff;
  box-sizing: border-box;
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.pr309-textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px #eef2ff;
}

/* ── Crew rows ───────────────────────────────────────────────────────────── */
.pr309-crew-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  color: #374151;
}

.pr309-crew-name {
  flex: 1;
}

.pr309-crew-check {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.pr309-walkon-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* ── Toggle buttons (safety / delay) ────────────────────────────────────── */
.pr309-toggle-row {
  display: flex;
  gap: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
  width: fit-content;
  margin-bottom: 10px;
}

.pr309-toggle-btn {
  background: #fff;
  border: none;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: #374151;
  transition: background 0.15s, color 0.15s;
}

.pr309-toggle-btn:not(:last-child) {
  border-right: 1px solid #d1d5db;
}

.pr309-toggle-active {
  background: #4f46e5;
  color: #fff;
}

/* ── Incident form ───────────────────────────────────────────────────────── */
.pr309-incident-form {
  border-left: 4px solid #d97706;
  padding-left: 14px;
  margin-top: 8px;
  background: #fffbeb;
  border-radius: 0 6px 6px 0;
  padding: 12px 14px;
}

.pr309-incident-block {
  background: #fff;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
}

/* ── Delay form ──────────────────────────────────────────────────────────── */
.pr309-delay-form {
  border-left: 4px solid #d97706;
  padding: 12px 14px;
  margin-top: 8px;
  background: #fffbeb;
  border-radius: 0 6px 6px 0;
}

.pr309-delay-block {
  background: #fff;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
}

/* ── Inline errors ───────────────────────────────────────────────────────── */
.pr309-inline-error {
  color: #dc2626;
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
  padding: 4px 8px;
  background: #fef2f2;
  border-radius: 4px;
  border-left: 3px solid #dc2626;
}

/* ── Work blocks ─────────────────────────────────────────────────────────── */
.pr309-work-block {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  padding: 12px;
  margin-bottom: 10px;
}

/* ── Equipment rows ──────────────────────────────────────────────────────── */
.pr309-equip-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* ── Auto-save indicator ─────────────────────────────────────────────────── */
.pr309-autosave {
  position: absolute;
  top: 10px;
  right: 16px;
  background: #d1fae5;
  color: #065f46;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  z-index: 10;
  animation: pr309FadeIn 0.3s ease;
}

@keyframes pr309FadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Lily draft advisory bar ─────────────────────────────────────────────── */
.pr309-lily-draft-bar {
  background: #f5f3ff;
  border-left: 4px solid #7c3aed;
  padding: 10px 16px;
  font-size: 13px;
  color: #5b21b6;
  font-style: italic;
}

/* ── Form actions ────────────────────────────────────────────────────────── */
.pr309-form-actions {
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: #fafafa;
}

/* ── Error state ─────────────────────────────────────────────────────────── */
.pr309-error {
  color: #dc2626;
  padding: 14px 20px;
  font-size: 14px;
}

/* ── Responsive: mobile < 768px ──────────────────────────────────────────── */
@media (max-width: 767px) {
  .pr309-content {
    padding: 10px 12px;
  }

  .pr309-cal-grid {
    gap: 2px;
    padding: 4px;
  }

  .pr309-cal-day {
    min-height: 38px;
    padding: 2px 3px;
  }

  .pr309-cal-day-num {
    font-size: 11px;
  }

  /* On mobile, calendar collapses to list view automatically */
  .pr309-cal-grid {
    display: none;
  }

  .pr309-cal-grid.pr309-cal-mobile-visible {
    display: grid;
  }

  .pr309-list-table th,
  .pr309-list-table td {
    padding: 6px 8px;
    font-size: 12px;
  }

  .pr309-detail-header {
    padding: 12px 14px;
  }

  .pr309-section-header {
    padding: 10px 14px;
  }

  .pr309-section-body {
    padding: 10px 14px;
  }

  .pr309-form-section {
    padding: 12px 14px;
  }

  .pr309-form-actions {
    padding: 10px 14px;
  }

  .pr309-field-row {
    flex-direction: column;
  }

  .pr309-field-row .pr309-field {
    min-width: 0;
  }

  .pr309-toggle-btn {
    padding: 8px 14px;
    font-size: 14px;
  }

  .pr309-toolbar {
    gap: 6px;
  }

  .pr309-detail-actions {
    padding: 10px 14px;
  }
}

/* ── Print overrides ─────────────────────────────────────────────────────── */
@media print {
  .pr309-toolbar,
  .pr309-detail-actions,
  .pr309-form-actions,
  .pr309-lily-bar,
  .pr309-cal-nav,
  .pr309-btn {
    display: none !important;
  }
}
