/* Common Public CSS for Admin Client */

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  color-scheme: dark;
}

/* ============ Dark Theme Tokens ============ */
:root {
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 6px 24px rgba(0, 0, 0, 0.35);

  /* Accent (adjust to your brand) */
  --accent: #10a37f;
  --accent-600: #0e8c6d;
  --accent-700: #0c765d;

  /* Semantic */
  --success: #2ea043;
  --warning: #f4a62a;
  --danger: #ef4444;

  /* Dialog backgrounds */
  --dialog-user-bg: hsl(88, 10%, 12%);
  --dialog-bot-bg: hsl(225, 30%, 11%);

  /* Typography scale */
  --font-sans:
    ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Helvetica, Arial,
    'Apple Color Emoji', 'Segoe UI Emoji';
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
    monospace;

  /* Spacing */
  --gutter: 16px;
}

/* Dark theme */
:root {
  --bg: #0e0f12; /* page background */
  --surface: #16181c; /* cards, panels */
  --surface-2: #1c1f24; /* elevated surfaces */
  --popover: #22262c; /* popovers/menus */
  --border: #2a2f36; /* soft borders */
  --muted: #9aa4b2; /* secondary text */
  --muted-2: #7a8594; /* tertiary text */
  --text: #e6e7eb; /* primary text */
  --link: #7dd6c4; /* link color */
  --link-hover: #a2e7da;
  --code-bg: #0b0c0f;
  --code-border: #23272f;
  --selection: rgba(125, 214, 196, 0.25);
}

/* ============ Base ============ */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection {
  background: var(--selection);
}
a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Page containers */
.app {
  max-width: 980px;
  margin: 0 auto;
  padding: calc(var(--gutter) * 1.25);
  padding-left: 0;
  padding-right: 0;
}

/* ============ Header / Toolbar ============ */
.header .row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

/* ============ Cards & Surfaces ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.card.elevated {
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
}

main h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.33rem;
}

main h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.33rem;
}

/* ============ Buttons ============ */
.button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 0.02s ease,
    background 0.15s ease,
    border-color 0.15s ease;
  user-select: none;
}
.button:hover {
  background: #21252b;
}
.button:active {
  transform: translateY(1px);
}
.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button.primary {
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.button.primary:hover {
  background: var(--accent-600);
}
.button.primary:active {
  background: var(--accent-700);
}

.button.secondary {
  background-color: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.button.secondary:hover {
  background-color: #5a6268;
}

.button.primary:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
}

.button.danger {
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.button.danger:hover {
  background-color: #c82333;
}

/* ============ Inputs ============ */
.input,
.textarea,
.select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}
.textarea {
  min-height: 120px;
  resize: vertical;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ============ Messages (Notifications) ============ */
.messages {
  margin-bottom: 1rem;
}

.message {
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.message.error {
  display: flex;
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid #dc3545;
  color: #dc3545;
}

.message.success {
  background: rgba(40, 167, 69, 0.1);
  border: 1px solid #28a745;
  color: #28a745;
}

.message.warning {
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid #ffc107;
  color: #856404;
}

.message.info {
  background: rgba(23, 162, 184, 0.1);
  border: 1px solid #17a2b8;
  color: #0c5460;
}

/* ============ Chat Layout ============ */
.chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 120px; /* room for composer */
}
.chat .message {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0b0c0f;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
}
.bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  overflow: hidden;
}
.chat .message.user .bubble {
  background: linear-gradient(180deg, #121417, #101215);
  border-color: #242933;
}
.chat .message.assistant .bubble {
  background: linear-gradient(180deg, #171a1f, #15181d);
  border-color: #2a3038;
}

/* ============ Markdown content ============ */
.bubble h1,
.bubble h2,
.bubble h3 {
  line-height: 1.25;
  margin: 14px 0 8px;
}
.bubble h1 {
  font-size: 1.5rem;
}
.bubble h2 {
  font-size: 1.25rem;
}
.bubble h3 {
  font-size: 1.1rem;
  color: var(--muted);
}

.bubble p {
  margin: 0 0 10px;
}
.bubble ul,
.bubble ol {
  margin: 8px 0 8px 20px;
}
.bubble li {
  margin: 4px 0;
}
.bubble blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(16, 163, 127, 0.06);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.bubble a {
  color: var(--link);
}
.bubble a:hover {
  color: var(--link-hover);
}

/* Code & pre */
code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 2px 6px;
  border-radius: 8px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-lg);
  padding: 12px;
  overflow: auto;
}
pre > code {
  border: none;
  background: transparent;
  padding: 0;
}

/* ============ Composer (input at bottom) ============ */
.composer {
  position: sticky;
  bottom: 0;
  z-index: 40;
  padding: 12px 0;
  background: linear-gradient(180deg, transparent, var(--bg) 28%), var(--bg);
}
.composer .bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px;
}
.composer .bar .input {
  background: transparent;
  border: none;
  padding: 10px 12px;
}
.composer .bar .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============ Tables ============ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table thead th {
  color: var(--muted);
  text-align: left;
  font-weight: 600;
  background: #14171b;
}

.table tbody tr:hover {
  background-color: var(--surface-2);
}

/* ============ Popups ============ */

.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup-content {
  background: var(--surface);
  border-radius: 8px;
}

.popup-header {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1em;
}

.popup-body {
  padding: 1rem;
}

.close-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  color: #6c757d;
}

.popup-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  margin-top: 1rem;
}

/* ============ Badges & Pills ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #14171b;
  color: var(--muted);
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ============ Toasts / Popovers ============ */
.toast,
.popover {
  background: var(--popover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-2);
}

/* ============ Focus & Accessibility ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.hidden-visually {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
}

/* ============ Scrollbars (Chromium/Edge) ============ */
*::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: #2b313a;
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: #353c46;
}

/* ============ Utility helpers ============ */
.muted {
  color: var(--muted);
}
.hr {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
  border: none;
}
