/* Recent panel backdrop — catches clicks over iframes */
.recent-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 199;
  background: transparent;
}

/* Recent panel — popover anchored to sidebar */
.recent-panel {
  position: fixed;
  left: var(--portal-sidebar-width, 200px);
  bottom: 80px;
  width: 420px;
  height: 480px;
  background: var(--mdb-color-bg);
  border: 1px solid var(--mdb-color-border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--mdb-font-sans);
  min-width: 220px;
  max-width: 600px;
}
.recent-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--mdb-color-border);
  flex-shrink: 0;
  position: relative;
}
.recent-panel-title {
  font-size: 13px;
  font-weight: 500;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--mdb-color-text);
  flex-shrink: 0;
}
.recent-tab-switcher {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 13px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--mdb-color-text-muted);
  flex-shrink: 0;
}
.recent-tab-switcher span { margin: 0 3px; }
.recent-tab {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--mdb-color-text-muted);
  cursor: pointer;
  font-weight: 500;
}
.recent-tab.active {
  color: var(--mdb-color-accent, #6c63ff);
  text-decoration: none;
}
.recent-tab:hover:not(.active) { color: var(--mdb-color-text); }

.msg-badge {
  display: inline-block;
  background: var(--mdb-color-accent, #6c63ff);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 1px 4px;
  border-radius: 8px;
  margin-left: 3px;
  vertical-align: text-top;
}

.msg-item { gap: 8px; }
.msg-item-icon .material-symbols-outlined { font-size: 18px; }
.msg-item-icon.severity-alert .material-symbols-outlined { color: #e53e3e; }
.msg-item-icon.severity-notify .material-symbols-outlined { color: var(--mdb-color-accent, #6c63ff); }
.msg-item.unread .recent-item-label { font-weight: 600; }
.msg-item .msg-mark-read {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--mdb-color-text-muted);
  padding: 2px;
  display: flex;
  align-items: center;
  border-radius: 3px;
  flex-shrink: 0;
}
.msg-item .msg-mark-read:hover { color: var(--mdb-color-text); background: var(--mdb-color-bg-secondary); }
.msg-item .msg-mark-read .material-symbols-outlined { font-size: 14px; }
.msg-mark-all-read {
  font-size: 11px;
  color: var(--mdb-color-accent, #6c63ff);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0 4px 0;
  display: block;
  width: 100%;
  text-align: right;
}
.msg-mark-all-read:hover { text-decoration: underline; }

.recent-expand-btn {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--mdb-color-text-muted);
  display: flex;
  align-items: center;
  border-radius: 4px;
  flex-shrink: 0;
}
.recent-expand-btn:hover { color: var(--mdb-color-text); background: var(--mdb-color-bg-secondary); }
.recent-expand-btn .material-symbols-outlined { font-size: 18px; }

.recent-panel-search {
  width: 150px;
  flex-shrink: 0;
  margin-left: auto;
  background: var(--mdb-color-bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--mdb-radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--mdb-color-text);
  outline: none;
  min-width: 0;
}
.recent-panel-search::placeholder { color: var(--mdb-color-text-muted); }
.recent-panel-search:focus { border-color: var(--mdb-color-primary); }

/* Resize handle — bottom-right corner */
.recent-panel-resize {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.recent-panel:hover .recent-panel-resize { opacity: 1; }
.recent-panel-resize::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-bottom: 2px solid var(--mdb-color-text-muted);
  border-right: 2px solid var(--mdb-color-text-muted);
  border-radius: 1px;
}

.recent-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--mdb-color-border) transparent;
}
.recent-panel-body::-webkit-scrollbar { width: 6px; }
.recent-panel-body::-webkit-scrollbar-track { background: transparent; }
.recent-panel-body::-webkit-scrollbar-thumb { background: var(--mdb-color-border); border-radius: 3px; }
.recent-panel-body::-webkit-scrollbar-thumb:hover { background: var(--mdb-color-text-muted); }

.recent-panel-empty {
  text-align: center;
  font-size: 13px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--mdb-color-text-muted);
  padding: 20px;
}
.recent-group-label {
  font-size: 11px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mdb-color-text-muted);
  padding: 8px 14px 4px;
}
.recent-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 6px 14px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--mdb-color-text);
  font-size: 13px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: background 0.1s;
}
.recent-item:hover { background: var(--mdb-color-bg-secondary); }
.recent-item-icon { padding-top: 1px; }
.recent-item-icon .material-symbols-outlined { font-size: 18px; color: var(--mdb-color-text-muted); }
.recent-item-info { flex: 1; overflow: hidden; font-family: var(--mdb-font-sans); }
.recent-item-label { font-size: 13px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item-meta { font-size: 11px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; color: var(--mdb-color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: none; }
.recent-panel.expanded .recent-item-meta { display: block; }
.recent-item-desc { font-size: 11px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; color: var(--mdb-color-text); overflow: hidden; display: none; }
.recent-panel.expanded .recent-item-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.recent-panel.expanded .recent-item-label { font-weight: 500; }
