/* TradeRailPR231 — Permits Bridge Styles
   Tenant-neutral. No hardcoded colors except permit-status palette.
   All layout hooks match the class names emitted by pr231_permits.js.
*/

/* ── Permit badge chip on job card ─────────────────────────────────────── */

.p231-badge-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

/* Full chip: PM / Admin / Owner / Foreman */
.p231-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: default;
}

/* Dot-only: field workers */
.p231-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Status color palette */
.p231-status-active    { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.p231-status-pending   { background: #fef9c3; color: #854d0e; border-color: #fef08a; }
.p231-status-inspection{ background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.p231-status-expired   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.p231-status-cancelled { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }
.p231-status-finaled   { background: #f3f4f6; color: #374151; border-color: #d1d5db; }
.p231-status-unknown   { background: #f8fafc; color: #94a3b8; border-color: #e2e8f0; }

/* Dot versions (field workers — same palette, dot only) */
.p231-dot.p231-status-active    { background: #22c55e; }
.p231-dot.p231-status-pending   { background: #eab308; }
.p231-dot.p231-status-inspection{ background: #3b82f6; }
.p231-dot.p231-status-expired   { background: #ef4444; }
.p231-dot.p231-status-cancelled { background: #94a3b8; }
.p231-dot.p231-status-finaled   { background: #9ca3af; }
.p231-dot.p231-status-unknown   { background: #cbd5e1; }

/* Overflow indicator (+N more) */
.p231-chip-more {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  cursor: default;
}

/* ── Day-view inspection badge ─────────────────────────────────────────── */

.p231-insp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-top: 4px;
  line-height: 16px;
}

.p231-insp-today {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.p231-insp-tomorrow {
  background: #fefce8;
  color: #a16207;
  border: 1px solid #fef08a;
}

/* ── Job popover permit section ────────────────────────────────────────── */

.p231-pop-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
}

.p231-pop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.p231-pop-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
}

.p231-pop-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  background: #1d4ed8;
  color: #fff;
  border: none;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.15s;
}

.p231-pop-add-btn:hover { background: #1e40af; }

/* Permit row in popover */
.p231-permit-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  margin-bottom: 6px;
  cursor: default;
  transition: background 0.12s;
}

.p231-permit-row:last-child { margin-bottom: 0; }

.p231-permit-row:hover { background: #f3f4f6; }

.p231-permit-row-left {
  flex: 1;
  min-width: 0;
}

.p231-permit-type {
  font-size: 12px;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p231-permit-number {
  font-size: 11px;
  color: #6b7280;
  margin-top: 1px;
  font-family: monospace;
}

.p231-permit-meta {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 3px;
}

.p231-permit-detail {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* Empty state in popover */
.p231-pop-empty {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  padding: 12px 0 6px;
  font-style: normal;
}

/* Field-only read view */
.p231-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  margin-bottom: 5px;
  font-size: 12px;
}

.p231-field-row:last-child { margin-bottom: 0; }

.p231-field-type { font-weight: 600; color: #374151; }

/* ── Expiration warning banner inside popover ──────────────────────────── */

.p231-exp-warn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  border: 1px solid transparent;
}

.p231-exp-warn-high {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.p231-exp-warn-normal {
  background: #fffbeb;
  color: #b45309;
  border-color: #fcd34d;
}

/* ── Add Permit fallback modal ─────────────────────────────────────────── */

.p231-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.p231-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.p231-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.p231-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.p231-modal-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

.p231-modal-close:hover { background: #f3f4f6; }

.p231-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.p231-field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.p231-field-group label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.p231-field-group input,
.p231-field-group select,
.p231-field-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 13px;
  color: #111827;
  background: #fff;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
  font-family: inherit;
}

.p231-field-group input:focus,
.p231-field-group select:focus,
.p231-field-group textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.p231-field-group textarea {
  resize: vertical;
  min-height: 72px;
}

.p231-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.p231-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.p231-btn-cancel {
  padding: 7px 16px;
  border-radius: 7px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}

.p231-btn-cancel:hover { background: #f9fafb; }

.p231-btn-save {
  padding: 7px 18px;
  border-radius: 7px;
  border: none;
  background: #1d4ed8;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.p231-btn-save:hover { background: #1e40af; }

/* ── Inspection schedule section inside modal ──────────────────────────── */

.p231-insp-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  padding-bottom: 6px;
  border-bottom: 1px solid #f3f4f6;
  margin-bottom: 2px;
}

/* ── Lily inbox alert card ─────────────────────────────────────────────── */

.p231-lily-alert {
  border-left: 3px solid #3b82f6;
  background: #eff6ff;
  border-radius: 0 7px 7px 0;
  padding: 8px 12px;
  font-size: 12px;
  color: #1e40af;
  margin-bottom: 6px;
}

.p231-lily-alert.p231-high {
  border-left-color: #ef4444;
  background: #fef2f2;
  color: #b91c1c;
}

/* ── Responsive: hide non-essential permit meta on narrow cards ─────────── */

@media (max-width: 767px) {
  /* Sidebar is hidden below 768px — these styles cover mobile card widths */
  .p231-chip {
    font-size: 9px;
    padding: 1px 5px;
  }

  .p231-permit-meta {
    display: none;
  }

  .p231-modal {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    max-height: 85vh;
  }

  .p231-row-2 {
    grid-template-columns: 1fr;
  }
}
