/* Admin styles — Prompt System */

:root {
  --turquoise: #40E0D0;
  --royal-blue: #2565AE;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --nav-bg: #1e293b;
  --nav-text: #f8fafc;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --row-hover: #f1f5f9;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --nav-bg: #020617;
  --nav-text: #f8fafc;
  --input-bg: #1e293b;
  --input-border: #475569;
  --row-hover: #334155;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Login bar */
#login-bar {
  background: var(--nav-bg);
  padding: 0.5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.login-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-bar-inner input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  width: 200px;
}

.login-bar-inner button {
  background: var(--royal-blue);
  color: #fff;
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.login-bar-inner button:hover { opacity: 0.85; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
}

.user-email {
  color: var(--nav-text);
  font-size: 0.85rem;
  opacity: 0.9;
}

.login-divider {
  color: var(--nav-text);
  opacity: 0.5;
  font-size: 0.8rem;
  margin: 0 0.25rem;
}

#sign-out-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--nav-text);
}

#theme-toggle {
  background: transparent;
  color: var(--nav-text);
  font-size: 1.1rem;
  margin-left: auto;
}

/* Main container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.back-link {
  color: var(--royal-blue);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover { text-decoration: underline; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

.btn-primary { background: var(--royal-blue); color: #fff; }
.btn-success { background: #10b981; color: #fff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-muted { background: var(--border); color: var(--text); }
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Filters */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters select {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.status-tabs {
  display: flex;
  gap: 0.25rem;
}

.status-tabs button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.status-tabs button.active {
  background: var(--royal-blue);
  color: #fff;
  border-color: var(--royal-blue);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  text-transform: capitalize;
}

/* Table */
.prompt-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.prompt-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.prompt-table td {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.prompt-table .prompt-row {
  cursor: pointer;
}

.prompt-table .prompt-row:hover {
  background: var(--row-hover);
}

.title-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Form */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group select,
.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.form-group textarea {
  min-height: 200px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  resize: vertical;
}

/* Chat / Thread */
.thread-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.thread-header h2 { font-size: 1.2rem; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.msg {
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  word-wrap: break-word;
}

.msg-human {
  align-self: flex-start;
  background: #dbeafe;
  color: #1e3a5f;
}

[data-theme="dark"] .msg-human {
  background: #1e3a5f;
  color: #dbeafe;
}

.msg-claude {
  align-self: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
}

.msg-system {
  align-self: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.msg-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.msg-body {
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.msg-claude .msg-body {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.85rem;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.8rem;
  margin: 0.5rem 0;
}

[data-theme="light"] .code-block {
  background: #1e293b;
  color: #e2e8f0;
}

/* Action bar */
.action-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.action-bar textarea {
  flex: 1;
  min-width: 200px;
  min-height: 60px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  resize: vertical;
}

.action-bar .btn { white-space: nowrap; }

.waiting-indicator {
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
}

.completed-display {
  color: var(--turquoise);
  font-weight: 600;
}

.error-display {
  color: #ef4444;
  font-weight: 500;
}

/* Clients table */
.clients-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.clients-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.clients-table td {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.key-display {
  font-family: monospace;
  background: var(--bg);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .msg { max-width: 90%; }
  .prompt-table { font-size: 0.8rem; }
  .prompt-table th, .prompt-table td { padding: 0.5rem; }
  .filters { flex-direction: column; }
  .action-bar { flex-direction: column; }
  .action-bar textarea { min-width: 100%; }
  .thread-header { flex-direction: column; align-items: flex-start; }
}
