/* Portal dashboard styles. Layered on top of the shared styles.css tokens. */

.portal-body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}

.portal-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.portal-nav-inner {
  max-width: 96rem;
  margin: 0 auto;
  padding: 0.8rem var(--space-md);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-md);
  align-items: center;
}
.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: 600;
}
.portal-brand:hover { text-decoration: none; }
.portal-brand img { height: 26px; width: auto; }
.portal-brand-sep { color: var(--color-muted); }
.portal-brand-product { font-size: var(--text-base); }

.portal-nav-links {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
}
.portal-nav-links > a,
.portal-nav-group {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.35rem 0.25rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  outline: none;
}
.portal-nav-group > .portal-nav-group-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}
.portal-nav-group > .portal-nav-group-label::after {
  content: '';
  width: 0.7em;
  height: 0.7em;
  background-color: currentColor;
  opacity: 0.75;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M2 4 L6 8 L10 4' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center / contain;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M2 4 L6 8 L10 4' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center / contain;
  transition: transform 120ms ease;
}
.portal-nav-group:hover > .portal-nav-group-label::after,
.portal-nav-group:focus-within > .portal-nav-group-label::after {
  transform: rotate(-180deg);
  opacity: 1;
}
.portal-nav-links > a:hover,
.portal-nav-group:hover,
.portal-nav-group:focus-within { color: var(--color-text); text-decoration: none; }
.portal-nav-links > a.active,
.portal-nav-group.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

/* Hover/focus-within dropdown. No click required. Focus-within keeps
   keyboard + touch (tap focuses, panel appears) working. */
.portal-nav-group { position: relative; }
.portal-nav-group-panel {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.4rem 0;
  min-width: 11rem;
  flex-direction: column;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 20;
  display: none;
}
/* Pad the top a touch so the cursor can travel from label to panel without
   crossing a gap that would close the menu. */
.portal-nav-group-panel::before {
  content: '';
  position: absolute;
  top: -0.5rem; left: 0; right: 0; height: 0.5rem;
}
.portal-nav-group:hover .portal-nav-group-panel,
.portal-nav-group:focus-within .portal-nav-group-panel {
  display: flex;
}
.portal-nav-group-panel a {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.45rem 1rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.portal-nav-group-panel a:hover {
  color: var(--color-text);
  background: var(--color-bg);
  text-decoration: none;
}
.portal-nav-group-panel a.active {
  color: var(--color-accent);
  background: rgba(255, 179, 71, 0.08);
  border-left: 2px solid var(--color-accent);
  padding-left: calc(1rem - 2px);
}
.portal-nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: var(--text-sm);
}
.portal-link-muted {
  color: var(--color-muted);
  font-weight: 600;
}

.portal-main { padding: var(--space-lg) 0; }
.portal-container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.portal-loading { color: var(--color-muted); }

/* Skeleton loader. Generic shape: page title bar + lead bar + one card with rows. */
@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton-bar {
  background: linear-gradient(
    90deg,
    var(--color-surface) 0%,
    var(--color-border) 50%,
    var(--color-surface) 100%
  );
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
  height: 1rem;
}
.skeleton-h1   { height: 2rem;    width: 40%; margin: 0 0 var(--space-md); }
.skeleton-lead { height: 1.1rem;  width: 70%; margin: 0 0 var(--space-lg); }
.skeleton-row  { height: 1rem;    width: 100%; margin: 0.5rem 0; }
.skeleton-row.short { width: 60%; }
.skeleton-row.medium { width: 80%; }

.portal-h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  margin: 0 0 var(--space-md);
}
.portal-h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin: var(--space-md) 0 var(--space-sm);
}
.portal-lead { font-size: var(--text-lg); color: var(--color-muted); margin-bottom: var(--space-lg); }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
}
.card-row:last-child { border-bottom: none; }
.card-row-title { font-weight: 600; }
.card-row-meta { color: var(--color-muted); font-size: var(--text-sm); }

.token-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: var(--text-sm);
  word-break: break-all;
  color: var(--color-accent);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--color-border);
}
.badge-active { color: #8fe78f; border-color: #2e5d2e; background: rgba(143,231,143,0.08); }
.badge-shared { color: var(--color-accent); border-color: var(--color-accent); background: rgba(255,179,71,0.08); }

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--color-accent); color: var(--color-accent); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.toggle input[type="checkbox"] { accent-color: var(--color-accent); transform: scale(1.2); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
table.data th, table.data td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
table.data th { color: var(--color-muted); font-weight: 600; }

.form-inline {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  margin-bottom: var(--space-md);
}
.form-inline input,
.form-inline select {
  padding: 0.6rem 0.8rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
}
.form-inline select { cursor: pointer; }
@media (max-width: 640px) {
  .form-inline { grid-template-columns: 1fr; }
}

/* Inline role-change dropdowns inside data tables. Compact, match badges. */
.role-select,
.admin-role-select {
  padding: 0.3rem 0.5rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.role-select:hover,
.admin-role-select:hover { border-color: var(--color-accent); }

.error-banner {
  background: rgba(255,140,140,0.08);
  border: 1px solid #5d2e2e;
  color: #ff8c8c;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
}
/* Form-error banner — sits above a form without replacing it. */
.form-error-banner {
  background: rgba(255,140,140,0.08);
  border: 1px solid #5d2e2e;
  color: #ff8c8c;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin: 0 0 0.85rem;
  font-size: var(--text-sm);
}

/* ---------- Toasts (corner-anchored, auto-dismiss) ---------- */
.portal-toast-root {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  pointer-events: none;
}
.portal-toast {
  pointer-events: auto;
  min-width: 14rem;
  max-width: 22rem;
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toast-in 140ms ease-out;
}
.portal-toast.leaving { animation: toast-out 160ms ease-in forwards; }
.portal-toast.success { border-color: #2e5d2e; }
.portal-toast.success::before {
  content: '';
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: #8fe78f; flex: 0 0 auto;
}
.portal-toast.error { border-color: #5d2e2e; color: #ff8c8c; }
.portal-toast.error::before {
  content: '';
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: #ff8c8c; flex: 0 0 auto;
}
.portal-toast.info::before {
  content: '';
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--color-accent); flex: 0 0 auto;
}
.portal-toast-message { flex: 1 1 auto; }
.portal-toast-action {
  background: transparent;
  color: var(--color-accent);
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
}
.portal-toast-action:hover { text-decoration: underline; }
@keyframes toast-in  { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to   { transform: translateY(6px); opacity: 0; } }

/* ---------- Modal / confirm dialog ---------- */
.portal-modal-root { position: fixed; inset: 0; z-index: 900; display: none; }
.portal-modal-root.open { display: block; }
.portal-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  animation: fade-in 120ms ease-out;
}
.portal-modal-card {
  position: relative;
  max-width: 28rem;
  margin: 12vh auto 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  animation: modal-in 140ms ease-out;
}
.portal-modal-card.danger { border-color: #5d2e2e; }
.portal-modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin: 0 0 0.5rem;
}
.portal-modal-body { color: var(--color-muted); margin: 0 0 1rem; font-size: var(--text-sm); line-height: 1.45; }
.portal-modal-body code { color: var(--color-text); }
.portal-modal-confirm-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
  margin: 0 0 1rem;
}
.portal-modal-actions {
  display: flex; gap: 0.5rem; justify-content: flex-end;
}
.btn-danger {
  background: #5d2e2e;
  color: #ff8c8c;
  border: 1px solid #5d2e2e;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
}
.btn-danger:hover { background: #6d3636; color: #ffb0b0; }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Kebab row action menu ---------- */
.kebab {
  position: relative;
  display: inline-block;
}
.kebab-trigger {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kebab-trigger:hover { color: var(--color-text); border-color: var(--color-accent); }
.kebab-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.3rem 0;
  min-width: 9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  display: none;
  z-index: 50;
}
.kebab.open .kebab-menu { display: block; }
.kebab-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0.5rem 0.9rem;
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}
.kebab-menu button:hover { background: var(--color-bg); }
.kebab-menu button.danger { color: #ff8c8c; }

.notice-card {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
}
.notice-card h2 { margin-bottom: var(--space-sm); }
.notice-card p { color: var(--color-muted); margin-bottom: var(--space-md); }

/* Editor views (resource + workflow) */

.editor-view .field { display: grid; gap: 0.35rem; margin-bottom: var(--space-sm); }
.editor-view .field label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.editor-view .field input[type="text"],
.editor-view .field input[type="email"],
.editor-view .field input[type="url"],
.editor-view .field textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: var(--text-base);
}

/* Workflow argument rows */
.arg-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr auto auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.arg-row input[type="text"] {
  padding: 0.5rem 0.7rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-body);
}
@media (max-width: 720px) {
  .arg-row { grid-template-columns: 1fr; }
}

/* EasyMDE overrides — match the dark palette. */
.EasyMDEContainer { background: var(--color-bg); }
.EasyMDEContainer .CodeMirror,
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}
.EasyMDEContainer .CodeMirror-cursor { border-left-color: var(--color-accent); }
.EasyMDEContainer .editor-toolbar {
  background: var(--color-surface);
  border-color: var(--color-border);
}
.EasyMDEContainer .editor-toolbar button {
  color: var(--color-text) !important;
}
.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-accent) !important;
}
.EasyMDEContainer .editor-statusbar { color: var(--color-muted); }
.EasyMDEContainer .editor-preview pre,
.EasyMDEContainer .editor-preview-side pre,
.EasyMDEContainer .editor-preview code,
.EasyMDEContainer .editor-preview-side code {
  background: var(--color-surface);
  color: var(--color-accent);
}
