/* ============================================================
   Guardian Assistant - Complete Dark Theme Stylesheet
   ============================================================ */

/* ---------- CSS Variables / Design Tokens ---------- */
:root {
  --bg-primary:   #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary:  #334155;
  --bg-hover:     #283548;
  --accent:       #6366f1;
  --accent-hover: #818cf8;
  --accent-dim:   rgba(99,102,241,0.15);
  --text-primary: #e2e8f0;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;
  --border:       #334155;
  --border-light: #475569;
  --success:      #22c55e;
  --success-dim:  rgba(34,197,94,0.15);
  --warning:      #f59e0b;
  --warning-dim:  rgba(245,158,11,0.15);
  --danger:       #ef4444;
  --danger-dim:   rgba(239,68,68,0.15);
  --info:         #3b82f6;
  --info-dim:     rgba(59,130,246,0.15);

  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg:  0 8px 30px rgba(0,0,0,0.4);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.5);

  --nav-height: 60px;
  --sidebar-width: 240px;
  --transition: 200ms ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent-hover);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img, svg { vertical-align: middle; }
ul, ol { list-style: none; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) var(--bg-primary);
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

@keyframes bounceDot {
  0%, 80%, 100% { transform: scale(0); }
  40%           { transform: scale(1); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.panel-fade {
  animation: fadeIn 0.3s ease;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(99,102,241,0.05) 0%, transparent 50%),
    var(--bg-primary);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-xl);
  animation: fadeIn 0.4s ease;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.auth-logo h1 {
  font-size: 1.35rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-form h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}
.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.auth-toggle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 20px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
  font-size: 0.8rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-dim);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-input-sm,
.form-select-sm {
  padding: 7px 10px;
  font-size: 0.88rem;
}
.form-select-sm {
  padding-right: 30px;
}

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

.form-row {
  display: flex;
  gap: 14px;
}
.form-group-half {
  flex: 1;
}

.form-error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}
.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover {
  background: #16a34a;
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   NAV BAR
   ============================================================ */
.nav-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(15,23,42,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 24px;
  flex: 1;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.nav-tab.active {
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1;
  min-width: 18px;
  text-align: center;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-user-name {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-area {
  margin-top: var(--nav-height);
  padding: 28px 24px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  min-height: calc(100vh - var(--nav-height));
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}
.card-body {
  padding: 16px 20px;
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-greeting {
  margin-bottom: 28px;
}
.dashboard-greeting h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.dashboard-greeting p {
  color: var(--text-muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition);
}
.stat-card:hover {
  border-color: var(--border-light);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon-total    { background: var(--info-dim);    color: var(--info); }
.stat-icon-pending  { background: var(--warning-dim); color: var(--warning); }
.stat-icon-progress { background: var(--accent-dim);  color: var(--accent-hover); }
.stat-icon-done     { background: var(--success-dim); color: var(--success); }
.stat-icon-overdue  { background: var(--danger-dim);  color: var(--danger); }

.stat-value {
  display: block;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dashboard-card .card-body {
  max-height: 340px;
  overflow-y: auto;
}

/* Recent todo rows inside dashboard */
.recent-todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.recent-todo-item:last-child { border-bottom: none; }
.recent-todo-item .todo-title-text {
  flex: 1;
  font-size: 0.92rem;
  color: var(--text-primary);
}

/* System status rows */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.status-row:last-child { border-bottom: none; }
.status-row-label {
  font-size: 0.92rem;
  color: var(--text-muted);
}
.status-row-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
}

/* ============================================================
   STATUS BADGE
   ============================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.status-badge-pending    { background: var(--warning-dim); color: var(--warning); }
.status-badge-in_progress,
.status-badge-in-progress { background: var(--info-dim); color: var(--info); }
.status-badge-done       { background: var(--success-dim); color: var(--success); }
.status-badge-overdue    { background: var(--danger-dim);  color: var(--danger); }

/* ============================================================
   PRIORITY BADGES
   ============================================================ */
.priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.priority-low    { background: rgba(100,116,139,0.2); color: #94a3b8; }
.priority-medium { background: var(--info-dim);       color: var(--info); }
.priority-high   { background: var(--warning-dim);    color: var(--warning); }
.priority-urgent { background: var(--danger-dim);     color: var(--danger); }

/* ============================================================
   TODOS LAYOUT
   ============================================================ */
.todos-layout {
  display: flex;
  gap: 20px;
  height: calc(100vh - var(--nav-height) - 56px);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.project-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.88rem;
  color: var(--text-muted);
}
.project-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.project-item.active {
  background: var(--accent-dim);
  color: var(--accent-hover);
}
.project-count {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.project-item.active .project-count {
  background: var(--accent);
  color: #fff;
}

/* Todos main */
.todos-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input-wrap svg {
  position: absolute;
  left: 10px;
  color: var(--text-dim);
  pointer-events: none;
}
.search-input-wrap .form-input {
  padding-left: 34px;
  width: 200px;
}

/* Todo list */
.todo-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color var(--transition), background var(--transition);
  animation: fadeIn 0.25s ease;
  cursor: pointer;
}
.todo-item:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}
.todo-item.done {
  opacity: 0.55;
}

.todo-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.todo-checkbox:hover {
  border-color: var(--accent);
}
.todo-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}
.todo-checkbox.checked::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.todo-body {
  flex: 1;
  min-width: 0;
}
.todo-title-text {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}
.todo-item.done .todo-title-text {
  text-decoration: line-through;
}
.todo-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.todo-meta-item {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}
.todo-meta-item svg { flex-shrink: 0; }

.todo-due-overdue {
  color: var(--danger) !important;
}

.todo-tag {
  display: inline-flex;
  padding: 1px 7px;
  font-size: 0.72rem;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border-radius: 4px;
}

.todo-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}
.todo-item:hover .todo-actions {
  opacity: 1;
}

/* Expanded todo detail */
.todo-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-muted);
  animation: fadeIn 0.2s ease;
}

/* ============================================================
   CHAT
   ============================================================ */
.chat-layout {
  height: calc(100vh - var(--nav-height) - 56px);
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.chat-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.connected    { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.disconnected { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }
.status-dot.connecting   { background: var(--warning); animation: pulse 1.5s infinite; }

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

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  gap: 14px;
  color: var(--text-muted);
}
.chat-welcome h3 {
  font-size: 1.15rem;
  color: var(--text-primary);
}
.chat-welcome p {
  max-width: 400px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.chat-message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.93rem;
  line-height: 1.65;
  word-break: break-word;
}

.chat-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
  animation: slideInRight 0.25s ease;
}

.chat-assistant {
  align-self: flex-start;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  animation: slideInLeft 0.25s ease;
}

/* Markdown inside chat */
.chat-assistant p        { margin-bottom: 8px; }
.chat-assistant p:last-child { margin-bottom: 0; }
.chat-assistant code {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}
.chat-assistant pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
}
.chat-assistant pre code {
  background: none;
  padding: 0;
}
.chat-assistant ul, .chat-assistant ol {
  margin: 8px 0;
  padding-left: 20px;
}
.chat-assistant ul { list-style: disc; }
.chat-assistant ol { list-style: decimal; }
.chat-assistant li { margin-bottom: 4px; }
.chat-assistant blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-muted);
  margin: 8px 0;
}
.chat-assistant h1, .chat-assistant h2, .chat-assistant h3, .chat-assistant h4 {
  margin: 12px 0 6px;
}
.chat-assistant a {
  color: var(--accent-hover);
}
.chat-assistant table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
}
.chat-assistant th, .chat-assistant td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  font-size: 0.88rem;
}
.chat-assistant th {
  background: var(--bg-tertiary);
}

/* Action results collapsible */
.action-result {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.action-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.action-result-header:hover {
  color: var(--text-primary);
}
.action-result-header .arrow {
  transition: transform var(--transition);
  font-size: 0.7rem;
}
.action-result-header.expanded .arrow {
  transform: rotate(90deg);
}
.action-result-body {
  display: none;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}
.action-result-body.show {
  display: block;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.typing-dots {
  display: flex;
  gap: 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: bounceDot 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

/* Chat input */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 150px;
  transition: border-color var(--transition);
  line-height: 1.5;
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-input::placeholder {
  color: var(--text-dim);
}
.chat-send-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--radius-md);
}

/* Mic button (voice dictation) */
.chat-mic-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-mic-btn.recording {
  color: #fff;
  background: #e0245e;
  border-color: #e0245e;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
.chat-mic-btn.processing {
  opacity: 0.6;
  pointer-events: none;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 36, 94, 0.6); }
  50%      { box-shadow: 0 0 0 8px rgba(224, 36, 94, 0); }
}

/* Chat messages */
.chat-msg {
  display: flex;
  margin: 8px 0;
}
.chat-msg-user { justify-content: flex-end; }
.chat-msg-assistant { justify-content: flex-start; }
.chat-msg-actions { justify-content: flex-start; }

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-msg-user .chat-bubble {
  background: var(--accent, #6366f1);
  color: #fff;
}
.chat-msg-assistant .chat-bubble {
  background: var(--bg-secondary, #192734);
  color: var(--text-primary, #e1e8ed);
  border: 1px solid var(--border, #2a3540);
}

.chat-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim, #8899a6);
  padding: 4px 14px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.chat-action { opacity: 0.85; }

/* ============================================================
   ADMIN — User management table
   ============================================================ */
.users-table-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.users-table thead th {
  text-align: left;
  padding: 12px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}
.users-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.users-table tbody tr:last-child td {
  border-bottom: none;
}
.users-table tbody tr:hover {
  background: var(--bg-hover);
}
.users-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.users-row-actions .btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   PROFILE
   ============================================================ */
.profile-panel {
  display: grid;
  gap: 18px;
  max-width: 560px;
}
.profile-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}
.profile-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}
.profile-card .form-input[disabled] { opacity: 0.6; }

/* ============================================================
   KILL SWITCH (Admin)
   ============================================================ */
.killswitch-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success, #17bf63);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.killswitch-card.disabled {
  border-left-color: var(--danger, #e0245e);
  background: rgba(224, 36, 94, 0.06);
}
.killswitch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.killswitch-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.killswitch-state {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--success, #17bf63);
}
.killswitch-card.disabled .killswitch-state {
  color: var(--danger, #e0245e);
}
.killswitch-meta {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.killswitch-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.killswitch-form .form-input { flex: 1; }

/* ============================================================
   APPROVALS
   ============================================================ */
.approvals-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.approvals-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.approvals-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.approval-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  animation: fadeIn 0.3s ease;
  transition: border-color var(--transition);
}
.approval-card:hover {
  border-color: var(--border-light);
}

.approval-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.approval-action-type {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
}
.approval-action-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent-hover);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tier-badge {
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
}
.tier-badge-1 { background: var(--success-dim); color: var(--success); }
.tier-badge-2 { background: var(--warning-dim); color: var(--warning); }
.tier-badge-3 { background: var(--danger-dim);  color: var(--danger); }

.approval-params {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
}
.approval-param-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.88rem;
}
.approval-param-key {
  color: var(--text-dim);
  min-width: 100px;
  flex-shrink: 0;
  font-weight: 600;
}
.approval-param-value {
  color: var(--text-primary);
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.approval-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.approval-actions {
  display: flex;
  gap: 10px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
/* The HTML5 `hidden` attribute must always win over display:flex above,
   otherwise an "invisible" modal still intercepts every click on the page. */
[hidden] { display: none !important; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  animation: slideDown 0.25s ease;
}
.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}
.modal-close {
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 8px !important;
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 10px;
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
  gap: 14px;
}
.empty-state p {
  font-size: 0.95rem;
}

.empty-state-sm {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  min-width: 280px;
  max-width: 420px;
  animation: toastIn 0.3s ease;
}
.toast.removing {
  animation: toastOut 0.3s ease forwards;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--info); }

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .dashboard-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  .nav-bar-inner {
    padding: 0 12px;
    gap: 8px;
  }
  .nav-brand span { display: none; }
  .nav-tabs { margin-left: 8px; }
  .nav-tab span { display: none; }
  .nav-tab { padding: 8px 12px; }
  .nav-user-name { display: none; }

  .content-area {
    padding: 16px 12px;
  }

  .todos-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--nav-height) - 32px);
  }
  .sidebar {
    width: 100%;
    max-height: 180px;
  }
  .todos-main {
    min-height: 400px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    flex-wrap: wrap;
  }
  .search-input-wrap .form-input {
    width: 100%;
  }

  .chat-message {
    max-width: 90%;
  }
  .chat-layout {
    height: calc(100vh - var(--nav-height) - 32px);
  }

  .auth-container {
    padding: 28px 20px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }
  .stat-card {
    padding: 14px;
  }

  .approval-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}
