/* ─────────────────────────────────────────────
   BLC Studio — Jarvis Dashboard
   style.css
───────────────────────────────────────────── */

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

:root {
  --cyan:        #03D5E4;
  --cyan-dim:    rgba(3, 213, 228, 0.15);
  --cyan-glow:   rgba(3, 213, 228, 0.08);
  --bg:          #0d0f14;
  --bg-2:        #111520;
  --bg-3:        #161b28;
  --bg-card:     #13172000;
  --border:      rgba(255,255,255,0.07);
  --border-cyan: rgba(3, 213, 228, 0.25);
  --text:        #e8eaf0;
  --text-muted:  #6b7280;
  --text-dim:    #9ca3af;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-w:   260px;
  --radius:      12px;
  --radius-sm:   8px;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
textarea, input, button { font-family: var(--font); }

/* ── Layout ───────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px;
  overflow-y: auto;
}

/* ── Sidebar ──────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.sidebar-logo span {
  background: linear-gradient(135deg, var(--text), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 8px 10px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, border-color 0.15s;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-3);
  border-color: var(--border);
}

.nav-item.active {
  background: var(--cyan-glow);
  border-color: var(--border-cyan);
}

.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.nav-item.active .nav-avatar {
  border-color: var(--border-cyan);
}

.nav-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.nav-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item.active .nav-name { color: var(--cyan); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-user {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--cyan);
  color: #0d0f14;
  border-color: var(--cyan);
}

.btn-primary:hover {
  background: #05e8f8;
  box-shadow: 0 0 20px rgba(3, 213, 228, 0.3);
}

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

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255,255,255,0.15);
  background: var(--bg-3);
}

.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }

.btn-send {
  width: 48px;
  height: 48px;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

/* ── Alerts ───────────────────────────────── */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* ── Login Page ───────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(3, 213, 228, 0.06) 0%, transparent 70%);
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.login-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  text-align: center;
}

.login-app-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.05em;
}

/* ── Forms ────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}

.optional {
  color: var(--text-muted);
  font-weight: 400;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 14px;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--border-cyan);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

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

/* Radio groups */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio-group-wrap {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.825rem;
  color: var(--text-dim);
  transition: all 0.15s;
  background: var(--bg-3);
}

.radio-option:hover {
  border-color: var(--border-cyan);
  color: var(--text);
}

.radio-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--text-muted);
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.15s;
}

.radio-option input[type="radio"]:checked {
  border-color: var(--cyan);
  background: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

.radio-option:has(input:checked) {
  border-color: var(--border-cyan);
  background: var(--cyan-glow);
  color: var(--text);
}

/* ── Dashboard ────────────────────────────── */
.dashboard {
  max-width: 1000px;
}

.dashboard-header {
  margin-bottom: 40px;
}

.dashboard-header h1 {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 0.95rem;
}

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.agent-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.agent-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.agent-card:hover {
  border-color: var(--border-cyan);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(3, 213, 228, 0.08);
}

.agent-card:hover::before { opacity: 1; }

.agent-card-avatar {
  position: relative;
  width: 56px;
}

.agent-card-avatar img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.agent-status {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-2);
}

.agent-status.online { background: var(--cyan); }

.agent-card-body { flex: 1; }

.agent-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.agent-card-role {
  font-size: 0.775rem;
  color: var(--cyan);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}

.agent-card-last {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-card-last.empty {
  color: var(--text-muted);
  font-style: italic;
}

.agent-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.msg-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.arrow {
  color: var(--cyan);
  font-size: 1rem;
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
}

.agent-card:hover .arrow {
  opacity: 1;
  transform: translateX(4px);
}

/* ── Agent Page ───────────────────────────── */
.agent-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  max-width: 860px;
}

.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-shrink: 0;
}

.agent-header-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.agent-avatar-lg {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 1px solid var(--border-cyan);
  object-fit: cover;
}

.agent-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.agent-role-tag {
  font-size: 0.775rem;
  color: var(--cyan);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-top: 2px;
}

/* ── Guided Form ──────────────────────────── */
.guided-form-wrapper {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  max-width: 700px;
}

.form-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.guided-form .btn-primary {
  margin-top: 8px;
}

/* ── Chat ─────────────────────────────────── */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
}

.chat-empty p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 360px;
  line-height: 1.7;
}

.chat-bubble {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble-user {
  flex-direction: row-reverse;
}

.bubble-avatar {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  object-fit: cover;
}

.bubble-content {
  max-width: 72%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.7;
}

.bubble-ai .bubble-content {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-top-left-radius: 2px;
}

.bubble-user .bubble-content {
  background: var(--cyan-dim);
  border: 1px solid var(--border-cyan);
  color: var(--text);
  border-top-right-radius: 2px;
}

/* Typing indicator */
.hidden { display: none !important; }

.typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px !important;
}

.typing span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  animation: bounce 1.2s infinite ease-in-out;
  opacity: 0.6;
}

.typing span:nth-child(1) { animation-delay: 0s; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Chat Form ────────────────────────────── */
.chat-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-form textarea {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 16px;
  font-size: 0.875rem;
  resize: none;
  line-height: 1.5;
  min-height: 48px;
  max-height: 160px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-form textarea:focus {
  outline: none;
  border-color: var(--border-cyan);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

.chat-form textarea::placeholder { color: var(--text-muted); }

/* ── Scrollbar global ─────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ───────────────────────────── */
@media (max-width: 900px) {
  .main-content { padding: 24px 20px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .sidebar { display: none; }
  .agent-page { height: auto; }
  .bubble-content { max-width: 88%; }
  .guided-form-wrapper { padding: 24px 20px; }
}
