/*
 * portal-ui.css — the new Invenio portal's look (edoardo-hash/invenio-portal, src/app/globals.css +
 * (portal)/layout.tsx), copied for invenio.tools (Edo, 21 Oct 2026: "same UI and UX as the new portal").
 * Copy and adapt, never import: the two repos stay separate. Keep the tokens in step with the portal by hand.
 *
 * Every page loads this file and /portal-shell.js, which draws the header and the side nav.
 * Classes are prefixed `pu-` so they never collide with a page's own CSS.
 */
@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #f1f3f0;
  --surface: #ffffff;
  --raised: #f7f8f6;
  --ink: #14232f;
  --muted: #56616b;
  --line: #d9ded8;
  --accent: #0b6663;
  --accent-ink: #ffffff;
  --accent-soft: #dcedea;
  --warn: #8f4a0c;
  --warn-soft: #f7e8d6;
  --danger: #9e2e29;
  --danger-soft: #f6e0de;
  --ok: #2b6334;
  --ok-soft: #e0eedd;
  --free: #5fa79a;
  --booked: #dce0da;
  --focus: #3b82c4;
  --shadow-pop: 0 12px 32px rgba(10, 20, 30, 0.18);
  --font-sans: "Hanken Grotesk", "Helvetica Neue", Helvetica, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Bridge for the old invenio.tools names, so any rule still using them lands on the new palette. */
  --navy: var(--bg);
  --navy-line: var(--line);
  --gold: var(--accent);
  --gold-dim: var(--line);
  --gold-bg: var(--accent-soft);
  --cream: var(--ink);
  --error: var(--danger);
  --serif: var(--font-sans);
  --sans: var(--font-sans);

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; max-width: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Phones (as in the portal): 16px fields so iOS never zooms; taps never select text. */
@media (max-width: 640px) {
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; }
}
button, label, summary, [role="button"] {
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
input, textarea { -webkit-user-select: text; user-select: text; }

/* ---------- Shell: header, side nav, main ---------- */
.pu-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px;
  border-bottom: 1px solid var(--line); background: var(--surface);
  padding: 14px clamp(16px, 3vw, 40px);
  position: relative; z-index: 40;
}
.pu-brand { display: flex; min-width: 0; flex: 1 1 220px; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.pu-mono {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 700; letter-spacing: 0.04em;
}
.pu-brand-text { display: flex; min-width: 0; flex-direction: column; line-height: 1.2; }
.pu-brand-name { font-size: 16px; font-weight: 700; }
.pu-brand-sub { font-size: 12px; color: var(--muted); }
.pu-env { margin-left: 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); padding: 2px 8px; font-size: 11px; font-weight: 700; }

.pu-user { position: relative; }
.pu-user > summary {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; cursor: pointer; list-style: none;
  border: 1px solid var(--line); background: var(--raised); font-size: 14px; font-weight: 700;
}
.pu-user > summary::-webkit-details-marker { display: none; }
.pu-user-pop {
  position: absolute; right: 0; top: 100%; margin-top: 8px; width: 260px; z-index: 50;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; box-shadow: var(--shadow-pop);
}
.pu-user-email { font-weight: 600; word-break: break-all; }
.pu-user-pop p { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.pu-user-pop p a { color: inherit; text-decoration: underline; }
.pu-user-pop .pu-btn { width: 100%; margin-top: 12px; }

.pu-body { display: flex; flex-direction: column; }
.pu-nav {
  display: flex; flex-direction: row; gap: 4px; overflow-x: auto;
  border-bottom: 1px solid var(--line); background: var(--surface); padding: 8px 12px;
  scrollbar-width: none;
}
.pu-nav::-webkit-scrollbar { display: none; }
.pu-nav-group { display: flex; flex-direction: row; gap: 4px; }
.pu-nav-head { display: none; padding: 16px 12px 6px; font-size: 13px; color: var(--muted); }
.pu-nav a {
  display: flex; align-items: center; min-height: 44px; white-space: nowrap; border-radius: 10px;
  padding: 0 12px; font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: none;
}
.pu-nav a:hover { background: var(--raised); }
.pu-nav a[aria-current="page"] { background: var(--accent-soft); font-weight: 700; }
.pu-nav a[hidden] { display: none; }

.pu-main {
  min-width: 0; flex: 1; overflow-x: clip;
  padding: 28px clamp(16px, 3vw, 40px) 144px;
}

@media (min-width: 1024px) {
  .pu-body { flex-direction: row; align-items: stretch; min-height: calc(100vh - 69px); }
  .pu-nav {
    width: 210px; flex: none; flex-direction: column; gap: 2px; overflow: visible;
    border-bottom: 0; border-right: 1px solid var(--line); padding: 24px 14px;
  }
  .pu-nav-group { flex-direction: column; gap: 2px; }
  .pu-nav-head { display: block; }
}

/* Full-height pages (WhatsApp inbox, AI agent) fill the main area without the bottom padding. */
body.pu-fill .pu-main { padding-bottom: 0; display: flex; flex-direction: column; }
@media (min-width: 1024px) {
  body.pu-fill .pu-body { height: calc(100vh - 69px); min-height: 0; }
  body.pu-fill .pu-main { overflow: hidden; }
}

/* ---------- Page heading ---------- */
.pu-title { margin: 0; font-size: clamp(26px, 3vw, 34px); font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.pu-intro { margin: 8px 0 0; max-width: 70ch; color: var(--muted); }
.pu-pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }

/* ---------- Components ---------- */
.pu-card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 20px; }
.pu-card-tight { padding: 16px; }
.pu-muted { color: var(--muted); }
.pu-small { font-size: 13px; }

.pu-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; cursor: pointer;
  font: 600 14px/1 var(--font-sans); text-decoration: none; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.pu-btn:hover { background: var(--raised); }
.pu-btn-primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.pu-btn-primary:hover { background: #095755; }
.pu-btn-sm { min-height: 40px; padding: 0 14px; font-size: 13px; }
.pu-btn-xs { min-height: 34px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.pu-btn:disabled, .pu-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.pu-chip {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 500 14px/1 var(--font-sans);
}
.pu-chip[aria-pressed="true"], .pu-chip.is-on { border-color: var(--ink); background: var(--ink); color: var(--bg); font-weight: 600; }

.pu-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700; background: var(--raised); color: var(--ink); }
.pu-badge-ok { background: var(--ok-soft); color: var(--ok); }
.pu-badge-warn { background: var(--warn-soft); color: var(--warn); }
.pu-badge-danger { background: var(--danger-soft); color: var(--danger); }
.pu-badge-accent { background: var(--accent-soft); color: var(--accent); }

.pu-note { margin: 0; border-radius: 12px; padding: 12px 16px; font-size: 14px; font-weight: 600; }
.pu-note-ok { background: var(--ok-soft); color: var(--ok); }
.pu-note-warn { background: var(--warn-soft); color: var(--warn); }
.pu-note-danger { background: var(--danger-soft); color: var(--danger); }

.pu-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.pu-input, .pu-select, .pu-textarea {
  min-height: 44px; width: 100%; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 400 15px/1.3 var(--font-sans);
}
.pu-textarea { padding: 10px 12px; min-height: 96px; }
.pu-select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2356616b' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.pu-input::placeholder, .pu-textarea::placeholder { color: var(--muted); }
.pu-check { width: 16px; height: 16px; accent-color: var(--accent); }

.pu-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.pu-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pu-table th { white-space: nowrap; border-bottom: 1px solid var(--line); padding: 12px 16px; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); }
.pu-table td { border-bottom: 1px solid var(--line); padding: 12px 16px; vertical-align: middle; }
.pu-table tr:last-child td { border-bottom: 0; }

.pu-link { font-weight: 600; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }

.pu-empty { display: grid; place-items: center; min-height: 200px; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); padding: 24px; text-align: center; font-size: 14px; color: var(--muted); }

.pu-pop { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-pop); }
.pu-scrim { background: rgba(20, 35, 47, 0.45); }
