/* ─── Shared staff CSS (Royal Justice palette) ───────────────────── */

:root {
  --bg: #0a1024;
  --bg-secondary: #0d1429;
  --bg-card: #141d3a;
  --bg-card-hover: #1a2547;
  --bg-input: #1a2547;
  --border: rgba(100, 140, 210, 0.12);
  --border-hover: rgba(100, 140, 210, 0.22);
  --text: #ffffff;
  --text-secondary: rgba(225, 232, 248, 0.55);
  --text-tertiary: rgba(225, 232, 248, 0.32);
  --accent: #2563eb;
  --accent-hover: #3b82f6;
  --accent-deep: #1e3a8a;
  --accent-dim: rgba(37, 99, 235, 0.15);
  --success: #34c759;
  --danger: #ff453a;
  --warning: #ff9f0a;
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.6);
  --glow-blue: 0 8px 24px rgba(37, 99, 235, 0.28);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  --transition: cubic-bezier(0.4, 0, 0.2, 1);
}

.hidden { display: none !important; }

* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

html, body {
  height: 100%;
  height: 100dvh;
  background: radial-gradient(ellipse 120% 70% at 50% -10%, #1a2547 0%, #0a1024 55%, #060b1c 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100, 140, 210, 0.18); border-radius: 4px; }

/* ── Login screen (shared) ────────────────────────────────────────── */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: var(--glow-blue);
}

.login-logo svg { width: 32px; height: 32px; color: #ffffff; }

.login-title {
  font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px; color: var(--text-secondary); text-align: center; margin-bottom: 24px;
}

.form-group { margin-bottom: 14px; }
.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s var(--transition);
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-tertiary); }

label.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--glow-blue);
  transition: transform 0.1s var(--transition), opacity 0.15s;
}
.btn-primary:hover { opacity: 0.92; }
.btn-primary:active { transform: scale(0.98); opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  padding: 10px 14px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: var(--border-hover); }

.btn-danger {
  padding: 8px 12px;
  background: rgba(255, 69, 58, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 69, 58, 0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(255, 69, 58, 0.2); }

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  min-height: 18px;
}

/* ── App shell ────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(20, 29, 58, 0.6);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-title { font-size: 17px; font-weight: 700; }
.app-subtitle { font-size: 12px; color: var(--text-secondary); }

.app-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}

.app-tab {
  flex-shrink: 0;
  padding: 8px 14px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s var(--transition);
}
.app-tab:hover { color: var(--text); }
.app-tab.active {
  background: var(--accent-dim);
  color: var(--accent-hover);
  border-color: var(--accent);
}

.app-body { flex: 1; overflow: hidden; display: flex; }
.app-panel { flex: 1; overflow-y: auto; padding: 16px; display: none; }
.app-panel.active { display: block; }

/* ── Chat list + chat detail (side-by-side on desktop, stacked on mobile) ── */
.chat-layout { display: flex; height: 100%; gap: 0; }
.chat-list-col {
  width: 340px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: rgba(13, 20, 41, 0.5);
}
.chat-detail-col { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.chat-list-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.chat-list-item:hover { background: var(--bg-card-hover); }
.chat-list-item.active { background: var(--accent-dim); border-left: 3px solid var(--accent); }

.chat-item-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.chat-item-preview { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

.chat-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.chat-header-bar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 29, 58, 0.6);
  flex-shrink: 0;
}
.chat-header-name { font-size: 15px; font-weight: 700; }
.chat-header-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-wrap { display: flex; flex-direction: column; max-width: 78%; }
.msg-wrap.from-user { align-self: flex-start; }
.msg-wrap.from-staff { align-self: flex-end; }
.msg-wrap.from-system { align-self: center; max-width: 90%; }

.msg-sender { font-size: 11px; color: var(--text-tertiary); margin-bottom: 3px; padding-left: 12px; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}
.msg-wrap.from-user .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.msg-wrap.from-staff .msg-bubble {
  background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
  color: white;
  border-bottom-right-radius: 5px;
}
.msg-wrap.from-system .msg-bubble {
  background: var(--accent-dim);
  color: var(--accent-hover);
  font-size: 13px;
  text-align: center;
  font-style: italic;
}

.msg-time { font-size: 10px; color: var(--text-tertiary); margin-top: 3px; padding: 0 12px; }
.msg-wrap.from-staff .msg-time { text-align: right; }

.chat-reply-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: rgba(13, 20, 41, 0.7);
  flex-shrink: 0;
}
.chat-reply-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  resize: none;
  min-height: 40px;
  max-height: 100px;
  outline: none;
}
.chat-reply-input:focus { border-color: var(--accent); }
.chat-reply-send {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow-blue);
}
.chat-reply-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Tables / cards / list items ───────────────────────────────────── */
.section-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.section-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

.data-list { display: flex; flex-direction: column; gap: 8px; }
.data-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.data-row .grow { flex: 1; min-width: 0; }
.data-name { font-size: 14px; font-weight: 600; }
.data-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.data-actions { display: flex; gap: 8px; flex-shrink: 0; }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

textarea.form-input { resize: vertical; min-height: 80px; }

.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%; max-width: 420px;
  max-height: 90dvh; overflow-y: auto;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 10px 18px; font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .chat-layout { flex-direction: column; }
  .chat-list-col { width: 100%; height: 40dvh; border-right: none; border-bottom: 1px solid var(--border); }
  .app-tabs { padding: 8px 10px; }
}
