/* ===== Sovra Dashboard — CSS Design System ===== */

:root {
  --color-primary: #F97316;
  --color-primary-dark: #C2590A;
  --color-primary-light: #FED7AA;
  --color-bg: #0A0F1E;
  --color-surface: #111827;
  --color-border: #1E2A45;
  --color-text: #FFFFFF;
  --color-text-muted: #9CA3AF;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --radius: 8px;
  --transition: 0.2s ease;
}

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

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

.hidden { display: none !important; }

/* ===== Auth Screen ===== */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}

.auth-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  width: 360px;
}

.auth-logo {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--color-text-muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.auth-box input {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  margin-bottom: 16px;
  outline: none;
  transition: border var(--transition);
}

.auth-box input:focus {
  border-color: var(--color-primary);
}

.auth-error {
  color: var(--color-danger);
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 20px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { color: var(--color-text); border-color: var(--color-text-muted); }

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

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

/* ===== Top Bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.wordmark {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--color-primary);
}

.topbar-user {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ===== Skin Selector ===== */
.skin-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

.skin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  position: relative;
}

.skin-dot:hover {
  transform: scale(1.25);
}

.skin-dot.active {
  border-color: var(--color-text);
  box-shadow: 0 0 6px rgba(255,255,255,0.3);
}

.skin-dot[title]::after {
  content: attr(title);
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  border: 1px solid var(--color-border);
  z-index: 200;
}

.skin-dot:hover::after {
  opacity: 1;
}

/* ===== Tab Navigation ===== */
.tab-nav {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--color-text); }
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ===== Tab Content ===== */
.tab-content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.panel { display: none; }
.panel.active { display: block; }

/* ===== Grid Layouts ===== */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }

.section-row { display: flex; gap: 20px; margin-bottom: 20px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

/* ===== Stat Cards ===== */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.big-stat {
  text-align: center;
  padding: 24px 0;
}

.big-stat .stat-value { font-size: 3rem; }

/* ===== Forms ===== */
input, textarea, select {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  padding: 8px 12px;
  font-size: 0.9rem;
  outline: none;
  transition: border var(--transition);
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  flex: 1;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.quick-add-form input[type="text"] {
  width: 100%;
  margin-bottom: 12px;
}

.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== Tasks List ===== */
.tasks-list { max-height: 600px; overflow-y: auto; }

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}

.task-row:hover { background: rgba(255,255,255,0.03); }

.task-title { flex: 1; font-weight: 500; }
.task-meta { display: flex; gap: 8px; align-items: center; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-open { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-in-progress { background: rgba(245,158,11,0.15); color: var(--color-warning); }
.badge-complete { background: rgba(16,185,129,0.15); color: var(--color-success); }
.badge-blocked { background: rgba(239,68,68,0.15); color: var(--color-danger); }

.badge-low { background: rgba(156,163,175,0.15); color: var(--color-text-muted); }
.badge-medium { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-high { background: rgba(245,158,11,0.15); color: var(--color-warning); }
.badge-urgent { background: rgba(239,68,68,0.15); color: var(--color-danger); }

.badge-instance {
  background: rgba(249,115,22,0.12);
  color: var(--color-primary);
  font-size: 0.7rem;
}

/* ===== Chat ===== */
.chat-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 500px;
}

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

.chat-msg {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 2px;
}

.chat-msg.streaming { opacity: 0.9; }

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.chat-input-row textarea {
  flex: 1;
  resize: none;
}

/* ===== Agent Console ===== */
.agent-prompt-name {
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: 8px;
}

.agent-prompt-text {
  width: 100%;
  resize: vertical;
  min-height: 120px;
}

.agent-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-var-input {
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-var-input span {
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.agent-var-input input {
  width: 160px;
}

.agent-output {
  margin-top: 16px;
  padding: 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 60px;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.6;
  display: none;
}

.agent-output.visible { display: block; }

#prompt-library {
  max-height: 600px;
  overflow-y: auto;
}

.prompt-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}

.prompt-item:hover { background: rgba(255,255,255,0.03); }
.prompt-item.active { background: rgba(249,115,22,0.1); border-left: 3px solid var(--color-primary); }

.prompt-item-title {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.prompt-item-cat {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ===== Team Grid ===== */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.team-member-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
}

.team-member-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-primary);
}

.team-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.team-stat-row:last-child { border-bottom: none; }

.team-stat-label { color: var(--color-text-muted); }
.team-stat-value { font-weight: 600; }

/* ===== Activity Feed ===== */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-text { color: var(--color-text-muted); flex: 1; }
.activity-text strong { color: var(--color-text); }
.activity-time { color: var(--color-text-muted); font-size: 0.75rem; white-space: nowrap; }

/* ===== Overdue List ===== */
.overdue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.overdue-item:last-child { border-bottom: none; }

.overdue-title { font-size: 0.9rem; }
.overdue-date { color: var(--color-danger); font-size: 0.8rem; font-weight: 600; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover { color: var(--color-text); }

#task-form label { margin-bottom: 12px; }

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

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  min-width: 240px;
}

.toast-info { background: var(--color-primary); color: #fff; }
.toast-success { background: var(--color-success); color: #fff; }
.toast-error { background: var(--color-danger); color: #fff; }

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

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .grid4 { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .section-row { flex-direction: column; }
  .tab-content { padding: 16px; }
}

@media (max-width: 600px) {
  .grid4 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px; }
  .tab-btn { padding: 10px 14px; font-size: 0.8rem; }
}

/* ===== Chart.js Canvas ===== */
canvas { max-height: 300px; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.5;
}
