/* ═══════════════════════════════════════════════════════════════════════════
   ADDITIONS TO portal.css
   Append this entire block to the bottom of your existing portal.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Light Mode Variables ──────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-base:       #f4f5f7;
  --bg-surface:    #ffffff;
  --bg-raised:     #f8f9fb;
  --bg-elevated:   #eef0f4;
  --bg-highlight:  #e4e7ee;

  --border:        rgba(0,0,0,0.08);
  --border-hover:  rgba(0,0,0,0.15);
  --border-focus:  #c49b3c;

  --text-primary:  #111827;
  --text-secondary:#374151;
  --text-muted:    #9ca3af;
  --text-inverse:  #ffffff;

  --accent:        #b8860b;
  --accent-light:  #c49b3c;
  --accent-dark:   #8b6508;
  --accent-glow:   rgba(196,155,60,0.10);

  --success:       #16a34a;
  --success-bg:    rgba(22,163,74,0.08);
  --warning:       #d97706;
  --warning-bg:    rgba(217,119,6,0.08);
  --danger:        #dc2626;
  --danger-bg:     rgba(220,38,38,0.08);
  --info:          #2563eb;
  --info-bg:       rgba(37,99,235,0.08);
  --neutral-bg:    rgba(107,114,128,0.10);

  --sidebar-bg:    #1e2433;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.10);
  --shadow:        0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:     0 12px 40px rgba(0,0,0,0.14);
  --shadow-glow:   0 0 24px rgba(196,155,60,0.12);
}

/* Light mode sidebar stays dark for contrast */
[data-theme="light"] .sidebar {
  background: var(--sidebar-bg);
  border-right-color: rgba(255,255,255,0.07);
}
[data-theme="light"] .sidebar .nav-link { color: rgba(255,255,255,0.6); }
[data-theme="light"] .sidebar .nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
[data-theme="light"] .sidebar .nav-link.active { background: var(--accent-glow); color: var(--accent-light); }
[data-theme="light"] .sidebar .nav-section-label,
[data-theme="light"] .sidebar .user-info-role { color: rgba(255,255,255,0.4); }
[data-theme="light"] .sidebar .user-info-name { color: rgba(255,255,255,0.85); }
[data-theme="light"] .sidebar .user-card:hover { background: rgba(255,255,255,0.06); }
[data-theme="light"] .sidebar .logo-text,
[data-theme="light"] .sidebar .sidebar-logo-text { color: rgba(255,255,255,0.9); }
[data-theme="light"] .sidebar .sidebar-logo-text span { color: rgba(255,255,255,0.45); }

/* Light mode table */
[data-theme="light"] .table thead tr { background: var(--bg-raised); }
[data-theme="light"] .table tbody tr:hover { background: var(--bg-elevated); }

/* Light mode search dropdown */
[data-theme="light"] .search-dropdown { border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .search-result-item:hover { background: var(--bg-elevated); }

/* ── Theme Toggle Button ──────────────────────────────────────────────────── */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all .15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); }

/* ── Modal Scroll Fix ────────────────────────────────────────────────────── */
/* Modals now scroll internally, not the whole page */
.modal-overlay {
  align-items: flex-start;
  padding: 32px 24px;
  overflow-y: auto;
}

.modal {
  max-height: none; /* remove the old 90vh cap */
  margin: auto;
}

.modal-body {
  max-height: 65vh;
  overflow-y: auto;
  overflow-x: hidden;
  /* Custom scrollbar inside modal */
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }

/* Sticky modal header/footer when body scrolls */
.modal-header { position: sticky; top: 0; z-index: 2; background: var(--bg-surface); }
.modal-footer { position: sticky; bottom: 0; z-index: 2; }

/* ── Notification Bell ────────────────────────────────────────────────────── */
.notif-bell {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all .15s;
  flex-shrink: 0;
}
.notif-bell:hover { background: var(--bg-elevated); color: var(--text-primary); }

.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-surface);
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  overflow: hidden;
}

.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.notif-dropdown-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.notif-list {
  max-height: 400px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  text-decoration: none;
}
.notif-item:hover { background: var(--bg-raised); }
.notif-item.unread { background: rgba(196,155,60,0.04); }
.notif-item:last-child { border-bottom: none; }

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.notif-content { flex: 1; min-width: 0; }
.notif-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-body {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-time { font-size: 10px; color: var(--text-muted); margin-top: 3px; font-family: var(--font-mono); }
.notif-unread-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 5px;
}

.notif-dropdown-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.notif-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Saved Search Sidebar Pills ──────────────────────────────────────────── */
.saved-search-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all .15s;
  margin-bottom: 1px;
  cursor: pointer;
}
.saved-search-pill:hover { background: var(--bg-raised); color: var(--text-primary); }
.saved-search-pill.active { background: var(--accent-glow); color: var(--accent-light); }
.saved-search-pill .pin-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Save Search Modal Button (inline in filter bar) ─────────────────────── */
.save-search-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Document Viewer ─────────────────────────────────────────────────────── */
.doc-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9,11,18,0.9);
  backdrop-filter: blur(6px);
  z-index: 600;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.doc-viewer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.doc-viewer-bar {
  height: 54px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
.doc-viewer-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-viewer-frame {
  flex: 1;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.doc-viewer-frame iframe,
.doc-viewer-frame img {
  width: 100%;
  height: 100%;
  border: none;
  object-fit: contain;
}
.doc-viewer-unsupported {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}
.doc-viewer-unsupported svg { margin-bottom: 12px; opacity: .3; }

/* ── Bulk Upload Drop Zone ───────────────────────────────────────────────── */
.bulk-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--bg-raised);
  position: relative;
}
.bulk-drop-zone:hover,
.bulk-drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.bulk-drop-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-queue { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.upload-queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.upload-queue-item .name { flex: 1; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-queue-item .size { color: var(--text-muted); flex-shrink: 0; }
.upload-progress-bar {
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 4px;
}
.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .3s ease;
}
.upload-status-icon { flex-shrink: 0; font-size: 14px; }

/* ── Analytics / Reports ─────────────────────────────────────────────────── */
.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.metric-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}
.metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.metric-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.metric-trend {
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}
.metric-trend.up   { color: var(--success); }
.metric-trend.down { color: var(--danger); }

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.chart-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.chart-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.chart-wrap { position: relative; height: 260px; }

/* ── RFX badges ──────────────────────────────────────────────────────────── */
.badge-rfp { background: rgba(79,163,227,0.12); color: #4fa3e3; }
.badge-rfi { background: rgba(245,166,35,0.12); color: #f5a623; }
.badge-rfq { background: rgba(196,155,60,0.15); color: var(--accent-light); }

/* ── Score matrix ─────────────────────────────────────────────────────────── */
.score-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.score-matrix th {
  padding: 8px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}
.score-matrix td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
.score-matrix tbody tr:hover { background: var(--bg-raised); }
.score-cell { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }

.score-bar-wrap { margin-top: 4px; }
.score-bar-track { height: 4px; background: var(--bg-elevated); border-radius: 99px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s ease; }

/* ── Concentration risk bar ──────────────────────────────────────────────── */
.concentration-bar {
  display: flex;
  height: 28px;
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
}
.concentration-segment {
  height: 100%;
  transition: width .5s ease;
  position: relative;
}
.concentration-segment:hover::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-primary);
  white-space: nowrap;
  z-index: 10;
}

/* ── Print styles for report PDF ─────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .modal-overlay { display: none !important; }
  .main { margin-left: 0 !important; }
  body { background: white !important; color: black !important; }
  .card { border: 1px solid #ddd !important; break-inside: avoid; }
  .metric-value { color: black !important; }
}

/* ── Contact items ──────────────────────────────────────────────────────────── */
.contact-item {
  transition: background .12s;
}
.contact-item:last-child {
  border-bottom: none !important;
}
.contact-item:hover {
  background: var(--bg-raised);
}

/* ── Comment styles ─────────────────────────────────────────────────────────── */
.comment-item {
  transition: background .12s;
}
.comment-item:last-child {
  border-bottom: none !important;
}
.comment-mention {
  color: var(--accent-light);
  background: var(--accent-glow);
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 500;
}
.comment-body del {
  background: rgba(220, 38, 38, 0.08);
  text-decoration: line-through;
  color: #c00;
}
.comment-body ins {
  background: rgba(22, 163, 74, 0.08);
  text-decoration: none;
  color: #080;
}

/* ── Spin animation (AI loading) ────────────────────────────────────────────── */
@keyframes spin {
  from { transform: rotate(0deg);   }
  to   { transform: rotate(360deg); }
}
.spin { animation: spin 1.2s linear infinite; display: inline-block; }

/* ── DocuSign envelope timeline ─────────────────────────────────────────────── */
.envelope-timeline {
  position: relative;
  padding-left: 28px;
}
.envelope-timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}
.envelope-event {
  position: relative;
  margin-bottom: 16px;
}
.envelope-event::before {
  content: '';
  position: absolute;
  left: -23px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
}
.envelope-event.completed::before { background: var(--success); border-color: var(--success); }
.envelope-event.sent::before      { background: var(--info);    border-color: var(--info);    }
.envelope-event.delivered::before { background: var(--warning); border-color: var(--warning); }
.envelope-event.declined::before  { background: var(--danger);  border-color: var(--danger);  }
.envelope-event.voided::before    { background: var(--danger);  border-color: var(--danger);  }

/* ── AI summary styles ───────────────────────────────────────────────────────── */
.summary-content p { margin-bottom: 10px; line-height: 1.8; }
.summary-content strong { color: var(--text-primary); }

/* ── Comparison diff styles ──────────────────────────────────────────────────── */
.diff-added   { background: rgba(22,163,74,.08); color: var(--success); padding: 2px 4px; border-radius: 3px; }
.diff-removed { background: rgba(220,38,38,.08); color: var(--danger);  padding: 2px 4px; border-radius: 3px; text-decoration: line-through; }

/* ── Apryse WebViewer overlay ─────────────────────────────────────────────── */
#apryseOverlay {
  flex-direction: column;
}
#apryseViewer {
  width: 100%;
  height: 100%;
}
/* Ensure WebViewer iframe fills container */
#apryseViewer iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
}

/* ── Documents grid ─────────────────────────────────────────────────────────── */
#docsGridView {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.doc-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  border-color: var(--accent) !important;
}
.doc-thumb:hover .doc-hover-overlay {
  opacity: 1 !important;
  background: rgba(0,0,0,.35) !important;
}

/* ── Topbar reorganisation ─────────────────────────────────────────────────── */

/* Three-zone topbar: left | centre | right */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.topbar-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.topbar-centre {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.topbar-centre .global-search-wrap {
  width: 100%;
  max-width: 480px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.topbar-page-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}

/* Unified icon button for topbar utility actions */
.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  transition: background .15s, color .15s;
  text-decoration: none;
  position: relative;
  flex-shrink: 0;
}

.topbar-icon-btn:hover,
.topbar-icon-btn.active {
  background: var(--bg-raised);
  color: var(--text-primary);
}

/* Notification badge on the bell */
.topbar-icon-btn .notif-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.topbar-icon-wrap {
  position: relative;
}

/* Hide the old sidebar toggle on desktop (still shows on mobile) */
@media (min-width: 769px) {
  #sidebarToggle {
    display: flex !important;
    opacity: .55;
  }
  #sidebarToggle:hover {
    opacity: 1;
  }
}

/* On mobile, collapse centre search below a breakpoint */
@media (max-width: 600px) {
  .topbar-centre {
    display: none;
  }
  .topbar-breadcrumb {
    max-width: 140px;
  }
}