@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── CSS custom properties ─────────────────────────────────────────────── */
:root {
  --bg:      hsl(22, 30%, 4%);
  --bg2:     hsl(22, 22%, 8%);
  --bg3:     hsl(22, 18%, 12%);
  --border:  hsl(22, 16%, 16%);
  --border2: hsl(22, 16%, 22%);
  --text:    hsl(30, 8%, 97%);
  --text2:   hsl(30, 8%, 60%);
  --text3:   hsl(30, 8%, 40%);
  --accent:  hsl(22, 84.9%, 52%);
  --accent2: hsl(22, 84.9%, 44%);
  --success: #22c55e;
  --warn:    #f59e0b;
  --danger:  #ef4444;
  --radius:  6px;
  --shadow:  0 2px 8px rgba(0,0,0,.4);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); min-height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text); font-size: 14px; line-height: 1.5;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(to bottom, rgba(13, 9, 7, 0) 0%, rgba(13, 9, 7, 1) 420px),
    url('/img/nrt-hero-bg.svg');
  background-size: 100% 420px, cover;
  background-position: top center, top center;
  background-repeat: no-repeat, no-repeat;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ────────────────────────────────────────────────────────────── */
.portal-hdr {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 24px;
  height: 64px;
  background: hsla(22, 25%, 5%, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}

.portal-hdr-left  { display: flex; align-items: center; }
.portal-hdr-right { display: flex; align-items: center; justify-content: flex-end; }

.portal-logo-img { height: 34px; max-height: 34px; width: auto; max-width: 220px; display: block; object-fit: contain; }
.portal-org      { font-size: 12px; color: var(--text2); }

/* ── Nav tabs ──────────────────────────────────────────────────────────── */
.portal-nav { display: flex; gap: 2px; }
.portal-nav-btn {
  padding: 5px 14px; border-radius: var(--radius); border: none;
  background: none; color: var(--text2); cursor: pointer; font-size: 13px;
  font-family: inherit;
  transition: background .12s, color .12s;
}
.portal-nav-btn:hover  { background: var(--bg3); color: var(--text); }
.portal-nav-btn.active { background: var(--bg3); color: var(--text);
                          box-shadow: inset 0 -2px 0 var(--accent); }

/* ── Main ──────────────────────────────────────────────────────────────── */
.portal-main { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }

/* ── Cards / panels ────────────────────────────────────────────────────── */
.panel {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 16px;
}
.panel-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px;
}
.panel-body { padding: 16px; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.portal-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.portal-table th {
  text-align: left; padding: 8px 12px; color: var(--text3);
  font-weight: 500; border-bottom: 1px solid var(--border);
}
.portal-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.portal-table tr:last-child td { border-bottom: none; }
.portal-table tbody tr:hover td { background: var(--bg3); }

/* ── Status badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-open    { background: rgba(212,101,31,.15);  color: hsl(22,84.9%,65%); }
.badge-waiting { background: rgba(245,158,11,.15);  color: #fbbf24; }
.badge-closed  { background: rgba(107,114,128,.15); color: #9ca3af; }
.badge-won     { background: rgba(34,197,94,.15);   color: #4ade80; }
.badge-sent    { background: rgba(212,101,31,.15);  color: hsl(22,84.9%,65%); }
.badge-draft   { background: rgba(107,114,128,.15); color: #9ca3af; }
.badge-decline { background: rgba(239,68,68,.15);   color: #f87171; }

/* ── Loading / empty states ────────────────────────────────────────────── */
.state-empty, .state-loading {
  padding: 48px 24px; text-align: center; color: var(--text3); font-size: 13px;
}
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#portal-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 18px; font-size: 13px; color: var(--text);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 9999;
}
#portal-toast.show { opacity: 1; }

/* ── Error banner ──────────────────────────────────────────────────────── */
.error-banner {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius); padding: 12px 16px;
  color: #f87171; font-size: 13px; margin-bottom: 16px;
}

/* ── Tab views ─────────────────────────────────────────────────────────── */
#view-tickets, #view-projects, #view-quotes, #view-orders { display: none; }
body.tab-tickets  #view-tickets,
body.tab-projects #view-projects,
body.tab-quotes   #view-quotes,
body.tab-orders   #view-orders  { display: block; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .portal-main { padding: 16px 12px; }
  .portal-hdr  { padding: 0 12px; grid-template-columns: auto 1fr auto; }
  .portal-nav  { overflow-x: auto; }
  .portal-table th:nth-child(n+4),
  .portal-table td:nth-child(n+4) { display: none; }
}
