/* Night Agent dashboard: hotel-premium look in plum and ivory.
   Fonts are served from /public/fonts (no external requests, so the CSP stays 'self'). */

@font-face { font-family: 'Bellefair'; src: url('/public/fonts/bellefair-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Be Vietnam Pro'; src: url('/public/fonts/be-vietnam-pro-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Be Vietnam Pro'; src: url('/public/fonts/be-vietnam-pro-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Be Vietnam Pro'; src: url('/public/fonts/be-vietnam-pro-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --night: #1B1229;      /* topbar, login background */
  --plum-800: #2A1B45;
  --plum-700: #3D2766;
  --plum-600: #5A3D8F;   /* primary actions */
  --plum-500: #7A5BB5;
  --plum-200: #DCD0F2;
  --plum-100: #EFE9F8;
  --moon: #E9DFFB;
  --ivory: #F7F4EE;      /* page background */
  --paper: #FFFFFF;
  --sand: #EDE7DC;
  --line: #E3DCD0;
  --ink: #1D1726;
  --muted: #6F6879;
  --alert: #B5452F;      /* needs a human */
  --alert-bg: #FBEDE8;
  --closed: #8C8695;
  --serif: 'Bellefair', Georgia, 'Times New Roman', serif;
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 23, 38, 0.04), 0 8px 24px rgba(29, 23, 38, 0.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.55; margin: 0; color: var(--ink); background: var(--ivory); }
a { color: var(--plum-600); text-underline-offset: 3px; }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.02em; line-height: 1.05; margin: 0; }
h1 { font-size: 46px; }
h2 { font-size: 30px; }
.error { color: var(--alert); }
.muted { color: var(--muted); font-size: 14px; }
.intact { color: var(--plum-600); font-size: 13px; font-weight: 500; }
.intact::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--plum-500); margin-right: 8px; vertical-align: middle; }

/* Moon icon */
.moon { width: 30px; height: 30px; flex: none; display: block; color: var(--moon); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; padding: 14px 40px; background: var(--night); color: var(--moon); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-family: var(--serif); font-size: 24px; letter-spacing: -0.01em; }
.topbar nav { display: flex; gap: 32px; }
.topbar nav a { color: rgba(233, 223, 251, 0.72); text-decoration: none; font-size: 13px; letter-spacing: 0.04em; padding: 6px 0; border-bottom: 1px solid transparent; transition: color 0.15s; }
.topbar nav a:hover { color: #fff; }
.topbar nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--plum-200); }
.account { justify-self: end; display: flex; align-items: center; gap: 16px; }
#user-label { color: rgba(233, 223, 251, 0.6); font-size: 12px; }
#logout-btn { background: transparent; color: var(--moon); border-color: rgba(233, 223, 251, 0.3); padding: 7px 16px; font-size: 13px; }
#logout-btn:hover { border-color: var(--moon); background: rgba(233, 223, 251, 0.08); }

/* Page layout */
main { max-width: 1040px; margin: 0 auto; padding: 56px 40px 80px; }
.page-head { margin-bottom: 32px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--plum-600); margin: 0 0 14px; }
.lead { color: var(--muted); max-width: 560px; margin: 14px 0 0; }
.back { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin: 0 0 20px; }
.back:hover { color: var(--plum-600); }

/* Buttons and fields */
button { font: inherit; font-size: 14px; font-weight: 500; padding: 9px 20px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s; }
button:hover { border-color: var(--plum-500); }
button[type="submit"] { background: var(--plum-600); color: #fff; border-color: var(--plum-600); }
button[type="submit"]:hover { background: var(--plum-700); border-color: var(--plum-700); }
button.danger { color: var(--alert); }
button.danger:hover { border-color: var(--alert); background: var(--alert-bg); }
button[data-confirm="yes"] { background: var(--alert); color: #fff; border-color: var(--alert); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--plum-500); outline-offset: 2px; }
input, textarea { font: inherit; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; width: 100%; background: var(--paper); color: var(--ink); }
input:focus, textarea:focus { border-color: var(--plum-500); outline: none; box-shadow: 0 0 0 3px var(--plum-100); }
textarea { min-height: 96px; resize: vertical; }

/* Login */
.login-page { background: radial-gradient(1200px 600px at 75% -10%, #4A2F7A 0%, transparent 60%), radial-gradient(900px 500px at 0% 110%, #2E1D4F 0%, transparent 60%), var(--night); color: var(--moon); min-height: 100vh; }
.login-page .topbar { background: transparent; position: static; }
.login { max-width: 1040px; min-height: calc(100vh - 140px); display: grid; grid-template-columns: 1.1fr 1fr; gap: 64px; align-items: center; }
.login-hero h1 { color: #fff; font-size: 64px; }
.login-hero .eyebrow { color: var(--plum-200); }
.login-hero p { color: rgba(233, 223, 251, 0.72); max-width: 420px; margin: 20px 0 0; }
.login-hero .moon { width: 56px; height: 56px; margin-bottom: 32px; }
#login-form { display: grid; gap: 18px; padding: 36px; border-radius: 20px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(233, 223, 251, 0.14); backdrop-filter: blur(12px); }
#login-form h2 { color: #fff; margin-bottom: 4px; }
#login-form label { display: grid; gap: 6px; font-size: 13px; color: rgba(233, 223, 251, 0.8); }
#login-form input { background: rgba(255, 255, 255, 0.95); border-color: transparent; }
#login-form button[type="submit"] { background: var(--moon); color: var(--night); border-color: var(--moon); padding: 12px 20px; margin-top: 6px; }
#login-form button[type="submit"]:hover { background: #fff; }
#login-form .error { color: #FFB4A3; margin: 0; font-size: 14px; }

/* Filters (segmented control) */
.filters { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 24px; background: var(--sand); border-radius: 999px; flex-wrap: wrap; }
.filters button { border-color: transparent; background: transparent; color: var(--muted); padding: 7px 16px; font-size: 13px; }
.filters button:hover { color: var(--ink); border-color: transparent; }
.filters button.active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(29, 23, 38, 0.1); }

/* Conversation list */
#conversation-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.conversation a { display: block; padding: 18px 22px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.conversation a:hover { border-color: var(--plum-200); box-shadow: var(--shadow); transform: translateY(-1px); }
.conversation.status-needs_human a { border-color: #EBC7BC; background: linear-gradient(90deg, var(--alert-bg), var(--paper) 40%); }
.conversation.status-closed a { opacity: 0.72; }
.conversation-top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.conversation-top .time { margin-left: auto; color: var(--muted); font-size: 13px; }
.number { font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.preview { margin: 10px 0 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status badge and channel */
.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; padding: 4px 11px 4px 9px; border-radius: 999px; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-ai .badge, .badge.status-ai { color: var(--plum-600); background: var(--plum-100); }
.status-needs_human .badge, .badge.status-needs_human { color: var(--alert); background: #F7DCD3; }
.status-closed .badge, .badge.status-closed { color: var(--closed); background: var(--sand); }
.channel { font-size: 12px; color: var(--muted); padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; }

/* One conversation */
#conversation-meta { margin: 16px 0 24px; }
#messages { display: grid; gap: 12px; margin: 0 0 20px; padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); max-height: 520px; overflow-y: auto; }
.message { max-width: 72%; padding: 12px 16px; border-radius: 16px 16px 16px 4px; background: var(--ivory); border: 1px solid var(--line); }
.message.out { justify-self: end; border-radius: 16px 16px 4px 16px; background: var(--plum-100); border-color: var(--plum-200); }
.message.author-staff { background: var(--plum-700); border-color: var(--plum-700); color: #fff; }
.message.author-staff .message-author, .message.author-staff .message-meta { color: var(--plum-200); }
.message-author { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--plum-600); margin-bottom: 4px; }
.message.in .message-author { color: var(--muted); }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.message-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.actions { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.actions #delete { margin-left: auto; }
#reply-form { display: grid; gap: 10px; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
#reply-form textarea { border-color: transparent; background: var(--ivory); }
#reply-form button { justify-self: end; }

/* Hotel knowledge */
#hotel-info-list { display: grid; gap: 14px; }
.info-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: grid; gap: 12px; }
.info-header strong { font-family: var(--serif); font-weight: 400; font-size: 22px; text-transform: capitalize; }
.info-header, .info-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.info-header .error { font-size: 13px; font-weight: 500; }
.info-header .error::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--alert); margin-right: 8px; vertical-align: middle; }
.info-card textarea { background: var(--ivory); border-color: transparent; }

/* Empty states */
.empty { padding: 48px; text-align: center; background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); }
#conversation-empty { padding: 48px; text-align: center; }

/* Small screens */
@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; padding: 14px 20px; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; gap: 20px; }
  #user-label { display: none; }
  main { padding: 36px 20px 60px; }
  h1 { font-size: 38px; }
  .login { grid-template-columns: 1fr; gap: 40px; }
  .login-hero h1 { font-size: 46px; }
  .message { max-width: 88%; }
}
