/* ============================================================
   PR311 Communications Hub — Styles
   All selectors scoped to .pr311-* prefix
   ============================================================ */

/* ── Root & Layout ──────────────────────────────────────────────────────────── */
.pr311-root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f8f9fa;
  min-height: 400px;
  position: relative;
}

.pr311-header {
  padding: 16px 20px 12px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.pr311-page-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
  flex: 1 1 auto;
}

.pr311-lily-subtitle {
  font-size: 12px;
  color: #6b6b8a;
  font-style: italic;
  width: 100%;
  margin-top: 2px;
  padding: 0;
}

/* ── View tabs ──────────────────────────────────────────────────────────────── */
.pr311-view-tabs {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.pr311-view-tab {
  padding: 6px 14px;
  border: 1px solid #d0d0d0;
  background: #f4f4f4;
  color: #444;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.pr311-view-tab:hover {
  background: #e8e8f0;
}

.pr311-view-tab-active {
  background: #1a56db;
  color: #ffffff;
  border-color: #1a56db;
}

/* ── Content wrapper ────────────────────────────────────────────────────────── */
.pr311-content {
  padding: 16px 20px;
}

/* ── Lily bar ───────────────────────────────────────────────────────────────── */
.pr311-lily-bar,
.pr312-lily-bar.pr311-lily-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #f0f0ff;
  border-bottom: 1px solid #d0d0f0;
  font-size: 13px;
  color: #3a3a7a;
}

.pr311-lily-bar-alert {
  background: #fff8e1;
  border-bottom-color: #ffe082;
  color: #7a5a00;
}

.pr311-lily-icon {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #6c63ff;
  color: #fff;
  border-radius: 3px;
  padding: 2px 6px;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.pr311-lily-insight-text {
  flex: 1 1 auto;
}

/* ── Filter bar ─────────────────────────────────────────────────────────────── */
.pr311-filter-bar {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.pr311-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.pr311-type-tab {
  padding: 5px 13px;
  border: 1px solid #d0d0d0;
  background: #f4f4f4;
  color: #444;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.12s, color 0.12s;
}

.pr311-type-tab:hover {
  background: #e8e8f0;
}

.pr311-type-tab-active {
  background: #1a56db;
  color: #ffffff;
  border-color: #1a56db;
  font-weight: 600;
}

.pr311-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pr311-filter-date {
  width: 140px;
}

.pr311-filter-search {
  flex: 1 1 200px;
  min-width: 160px;
}

/* ── Thread toolbar ─────────────────────────────────────────────────────────── */
.pr311-thread-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

/* ── Thread list ────────────────────────────────────────────────────────────── */
.pr311-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pr311-thread-entry {
  background: #ffffff;
  border: 1px solid #e4e4e4;
  border-radius: 6px;
  padding: 12px 16px;
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s;
}

.pr311-thread-entry:hover {
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.08);
  border-color: #a8c4f8;
}

.pr311-entry-expanded {
  border-color: #1a56db;
  box-shadow: 0 2px 12px rgba(26, 86, 219, 0.12);
}

.pr311-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.pr311-entry-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pr311-entry-date {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
}

.pr311-entry-from {
  font-size: 12px;
  color: #555;
  margin-bottom: 3px;
}

.pr311-entry-subject {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.pr311-entry-preview {
  font-size: 12px;
  color: #777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-bottom: 6px;
}

.pr311-entry-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 2px;
}

.pr311-entry-expand-hint {
  font-size: 11px;
  color: #aaa;
  text-align: right;
}

/* ── Type badges ─────────────────────────────────────────────────────────────── */
.pr311-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 2px 7px;
  white-space: nowrap;
}

.pr311-type-email {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.pr311-type-sms {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.pr311-type-meeting {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

.pr311-type-note {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* ── Status badges ──────────────────────────────────────────────────────────── */
.pr311-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  padding: 2px 7px;
  white-space: nowrap;
}

.pr311-badge-draft {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.pr311-badge-sent {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.pr311-badge-received {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.pr311-badge-logged {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.pr311-badge-unrouted {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.pr311-badge-awaiting {
  background: #fef9c3;
  color: #a16207;
  border: 1px solid #fde047;
}

.pr311-badge-action-items {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  cursor: default;
}

.pr311-badge-pinned {
  background: #fefce8;
  color: #854d0e;
  border: 1px solid #fde68a;
}

/* ── RFI badge ──────────────────────────────────────────────────────────────── */
.pr311-rfi-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  background: #1e3a5f;
  color: #ffffff;
  border-radius: 20px;
  padding: 2px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}

.pr311-rfi-badge:hover {
  background: #1a56db;
}

/* ── Communication detail ───────────────────────────────────────────────────── */
.pr311-comm-detail {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
}

.pr311-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.pr311-detail-title {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pr311-detail-meta {
  font-size: 12px;
  color: #777;
  margin-bottom: 14px;
}

.pr311-detail-email,
.pr311-detail-sms,
.pr311-detail-meeting,
.pr311-detail-note {
  margin-bottom: 16px;
}

.pr311-detail-body {
  background: #f8f9fa;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 13px;
  color: #333;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 8px;
  margin-bottom: 8px;
  min-height: 60px;
}

.pr311-attachments-list {
  margin: 8px 0;
  font-size: 12px;
  color: #555;
}

.pr311-attachments-list ul {
  margin: 4px 0 0 16px;
  padding: 0;
}

.pr311-linked-rfis {
  margin: 10px 0;
  font-size: 13px;
}

.pr311-detail-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
}

/* ── Action items list ──────────────────────────────────────────────────────── */
.pr311-action-items {
  margin: 12px 0;
  font-size: 13px;
}

.pr311-action-items ul {
  margin: 8px 0 0 0;
  padding: 0;
  list-style: none;
}

.pr311-action-item-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  margin-bottom: 6px;
  background: #fafafa;
  font-size: 12px;
}

.pr311-ai-done {
  opacity: 0.55;
  text-decoration: line-through;
  background: #f1f5f9;
}

.pr311-ai-desc {
  font-weight: 600;
  color: #1a1a1a;
  flex: 1 1 auto;
}

.pr311-ai-status {
  font-size: 11px;
  font-weight: 600;
  color: #555;
}

/* Action items table view */
.pr311-action-items-view {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px 20px;
}

.pr311-action-items-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.pr311-ai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pr311-ai-table th {
  text-align: left;
  padding: 8px 12px;
  background: #f4f6f8;
  border-bottom: 2px solid #e0e0e0;
  font-weight: 600;
  color: #555;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pr311-ai-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
  vertical-align: top;
}

.pr311-ai-table tr:last-child td {
  border-bottom: none;
}

.pr311-ai-table tr:hover td {
  background: #f8f9fa;
}

/* ── Action items compose ────────────────────────────────────────────────────── */
.pr311-action-items-compose {
  margin: 14px 0;
  padding: 12px;
  background: #f8f9fa;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
}

.pr311-ai-compose-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}

/* ── Compose panel ──────────────────────────────────────────────────────────── */
.pr311-compose,
.pr311-compose-form,
.pr311-compose-type-select {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  max-width: 700px;
}

.pr311-compose-title {
  font-size: 17px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 16px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
}

/* Type select grid */
.pr311-type-select-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.pr311-type-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  font-size: 15px;
  font-weight: 600;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #f8f9fa;
  color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.pr311-type-card:hover {
  border-color: #1a56db;
  background: #eff6ff;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.1);
}

.pr311-type-card-active {
  border-color: #1a56db;
  background: #dbeafe;
  color: #1d4ed8;
}

.pr311-compose-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
}

/* ── Lily draft bar ─────────────────────────────────────────────────────────── */
.pr311-lily-draft-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f3f0ff;
  border: 1px solid #d8d0ff;
  border-radius: 4px;
  padding: 8px 12px;
  margin: 10px 0;
  flex-wrap: wrap;
}

.pr311-lily-advisory {
  font-size: 11px;
  color: #5b40c2;
  font-style: italic;
  flex: 1 1 200px;
}

/* ── Form fields ─────────────────────────────────────────────────────────────── */
.pr311-frow {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pr311-flbl {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pr311-input {
  padding: 7px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 13px;
  color: #1a1a1a;
  background: #ffffff;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.pr311-input:focus {
  outline: none;
  border-color: #1a56db;
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.12);
}

.pr311-select {
  padding: 7px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 13px;
  color: #1a1a1a;
  background: #ffffff;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color 0.12s;
}

.pr311-select:focus {
  outline: none;
  border-color: #1a56db;
}

.pr311-textarea {
  padding: 8px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 13px;
  color: #1a1a1a;
  background: #ffffff;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.pr311-textarea:focus {
  outline: none;
  border-color: #1a56db;
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.12);
}

.pr311-mtg-attendee-freeform {
  margin-top: 6px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.pr311-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #f4f4f4;
  color: #333;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.pr311-btn:hover {
  background: #e8e8e8;
}

.pr311-btn-primary {
  background: #1a56db;
  color: #ffffff;
  border-color: #1a56db;
}

.pr311-btn-primary:hover {
  background: #1547c0;
  border-color: #1547c0;
}

.pr311-btn-secondary {
  background: #ffffff;
  border-color: #1a56db;
  color: #1a56db;
}

.pr311-btn-secondary:hover {
  background: #eff6ff;
}

.pr311-btn-lily {
  background: #6c63ff;
  color: #ffffff;
  border-color: #5a54e0;
  font-size: 12px;
  padding: 5px 12px;
}

.pr311-btn-lily:hover {
  background: #5a54e0;
}

.pr311-btn-link {
  background: transparent;
  border-color: transparent;
  color: #1a56db;
  padding: 7px 8px;
}

.pr311-btn-link:hover {
  text-decoration: underline;
  background: transparent;
}

.pr311-btn-sm {
  font-size: 11px;
  padding: 3px 9px;
}

.pr311-back-btn {
  flex: 0 0 auto;
}

.pr311-link {
  color: #1a56db;
  cursor: pointer;
  text-decoration: underline;
  font-size: 13px;
}

.pr311-link:hover {
  color: #1547c0;
}

/* ── Download button ─────────────────────────────────────────────────────────── */
.pr311-dl-btn {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.pr311-dl-btn:hover {
  background: #dcfce7;
}

/* ── SMS char counter ────────────────────────────────────────────────────────── */
.pr311-char-counter {
  font-size: 12px;
  color: #777;
  margin: 4px 0 8px;
  text-align: right;
}

.pr311-char-warning {
  color: #c2410c;
  font-weight: 600;
}

/* ── SMS error ───────────────────────────────────────────────────────────────── */
.pr311-sms-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  color: #dc2626;
  font-size: 12px;
  padding: 8px 12px;
  margin: 6px 0;
}

.pr311-hidden {
  display: none !important;
}

/* ── Attach note ─────────────────────────────────────────────────────────────── */
.pr311-attach-note {
  font-size: 11px;
  color: #888;
  font-style: italic;
  padding: 6px 0;
}

/* ── Pinned note ─────────────────────────────────────────────────────────────── */
.pr311-pinned-note {
  background: #fffbeb;
  border-color: #fde68a;
}

/* ── Internal note restricted ────────────────────────────────────────────────── */
.pr311-note-restricted {
  background: #f8f8f8;
  font-style: italic;
}

.pr311-note-restricted-label {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  font-style: italic;
  letter-spacing: 0.02em;
}

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.pr311-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a1a;
  color: #ffffff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 360px;
}

.pr311-toast-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.pr311-empty-state {
  text-align: center;
  color: #aaa;
  padding: 32px 16px;
  font-size: 14px;
  font-style: italic;
}

/* ── Responsive < 768px ──────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .pr311-header {
    padding: 12px 14px 10px;
    flex-direction: column;
    align-items: flex-start;
  }

  .pr311-view-tabs {
    width: 100%;
  }

  .pr311-content {
    padding: 12px 12px;
  }

  .pr311-filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  .pr311-filter-date,
  .pr311-filter-search {
    width: 100%;
  }

  .pr311-type-tabs {
    flex-wrap: wrap;
  }

  .pr311-thread-entry {
    padding: 10px 12px;
  }

  .pr311-entry-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .pr311-entry-preview {
    white-space: normal;
    max-height: 36px;
    overflow: hidden;
  }

  .pr311-type-select-grid {
    grid-template-columns: 1fr;
  }

  .pr311-compose,
  .pr311-compose-form,
  .pr311-compose-type-select {
    padding: 14px 12px;
  }

  .pr311-comm-detail {
    padding: 14px 12px;
  }

  .pr311-ai-table {
    font-size: 12px;
  }

  .pr311-ai-table th,
  .pr311-ai-table td {
    padding: 6px 8px;
  }

  .pr311-compose-actions {
    flex-direction: column;
  }

  .pr311-btn {
    width: 100%;
    justify-content: center;
  }

  .pr311-detail-actions {
    flex-direction: column;
  }

  .pr311-lily-draft-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .pr311-toast {
    left: 12px;
    right: 12px;
    bottom: 16px;
    max-width: none;
  }

  .pr311-action-items-toolbar {
    flex-direction: column;
  }
}
