/* ============================================================
   Variables & Reset
   ============================================================ */
:root {
  --bg-dark:       #0f172a;
  --sidebar-bg:    #1e293b;
  --sidebar-hover: #2d3f55;
  --sidebar-active:#334155;
  --primary:       #3b82f6;
  --primary-dark:  #2563eb;
  --primary-light: #eff6ff;
  --text-main:     #1e293b;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;
  --text-white:    #f1f5f9;
  --border:        #e2e8f0;
  --card-bg:       #ffffff;
  --user-bubble:   #3b82f6;
  --success:       #10b981;
  --error:         #ef4444;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.14);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* ============================================================
   Auth Page
   ============================================================ */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.auth-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 28px; }

.logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.auth-logo h1 { font-size: 20px; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.auth-logo p  { font-size: 13px; color: var(--text-muted); }

.auth-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--card-bg);
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 13px; font-weight: 600; color: var(--text-main); }

.field-group input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
}

.field-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.btn-primary {
  padding: 11px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.btn-primary:hover    { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--error);
  font-size: 13px;
}

.hidden { display: none !important; }

/* ============================================================
   Dashboard Layout
   ============================================================ */
body.dashboard-page {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: #f8fafc;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 270px;
  min-width: 270px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-title { font-size: 15px; font-weight: 600; color: var(--text-white); }

/* Home nav button */
.home-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px 2px;
  padding: 9px 13px;
  background: rgba(255,255,255,0.05);
  color: var(--text-light);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.home-nav-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-white); }

/* New Chat button */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 12px 4px;
  padding: 9px 13px;
  background: rgba(59,130,246,0.15);
  color: #93c5fd;
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.new-chat-btn:hover { background: rgba(59,130,246,0.28); color: white; }

.chat-list-label {
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
}

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

.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.chat-list-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
}

.chat-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.chat-item:hover  { background: var(--sidebar-hover); }
.chat-item.active { background: var(--sidebar-active); }

.chat-item-title {
  font-size: 13px;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.chat-item-date { font-size: 11px; color: var(--text-light); }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info { display: flex; align-items: center; gap: 8px; min-width: 0; }

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-email {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.logout-btn:hover { color: var(--error); }

/* ── Main area ────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   Home View — Tool Selector
   ============================================================ */
.home-view {
  flex: 1;
  overflow-y: auto;
  padding: 48px 40px;
}

.home-header {
  margin-bottom: 36px;
}

.home-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.home-header p {
  font-size: 15px;
  color: var(--text-muted);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 860px;
}

.tool-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  position: relative;
  transition: all 0.2s;
}

.tool-card.tool-active {
  cursor: pointer;
  border-color: transparent;
  box-shadow: 0 0 0 1.5px var(--primary), var(--shadow);
}

.tool-card.tool-active:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 2px var(--primary), 0 8px 32px rgba(59,130,246,0.15);
}

.tool-card.tool-soon {
  cursor: pointer;
  opacity: 0.65;
  background: #f8fafc;
}

.tool-card.tool-soon:hover { opacity: 0.8; }

.tool-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.tool-badge-active {
  background: #dcfce7;
  color: #15803d;
}

.tool-badge-soon {
  background: #f1f5f9;
  color: var(--text-light);
}

.tool-icon { font-size: 36px; margin-bottom: 14px; }

.tool-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.tool-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.tool-action {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

/* ============================================================
   Chat View
   ============================================================ */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  flex-shrink: 0;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.back-btn:hover { background: #f1f5f9; color: var(--text-main); }

.chat-header-tool {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-icon { font-size: 18px; }

.chat-header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 24px;
  text-align: center;
}

.empty-icon  { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; color: var(--text-main); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; max-width: 360px; line-height: 1.6; }

/* Messages scroll area */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: none;
  flex-direction: column;
  gap: 32px;
}

.messages-container.visible { display: flex; }

.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Message Pair ─────────────────────────────────────────── */
.message-pair { display: flex; flex-direction: column; gap: 16px; }
.message { display: flex; }
.user-message { justify-content: flex-end; }

.user-bubble {
  background: var(--user-bubble);
  color: white;
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  max-width: 70%;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.assistant-message { flex-direction: column; gap: 12px; }

.assistant-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.assistant-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.assistant-header > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  flex: 1;
}

/* Copy button */
.copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: auto;
}

.copy-btn:hover { background: #f1f5f9; color: var(--text-main); border-color: var(--text-light); }
.copy-btn.copied { color: var(--success); border-color: #bbf7d0; background: #f0fdf4; }

/* ── Response Card ────────────────────────────────────────── */
.response-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.reply-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.reply-section:last-child { border-bottom: none; }

.reply-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
  margin-bottom: 8px;
}

.reply-section p, .reply-section > div {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.7;
  white-space: pre-wrap;
}

.closing-section { background: #f8fafc; }
.closing-section div { font-size: 13px; color: var(--text-muted); }

.bullet-item {
  padding: 3px 0 3px 16px;
  border-left: 2px solid #e2e8f0;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.6;
}

.section-line {
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 6px;
  line-height: 1.6;
}

.question-item {
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 6px;
  line-height: 1.6;
}

/* ── Similar Projects ─────────────────────────────────────── */
.similar-projects-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.similar-projects-card h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
  margin-bottom: 14px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  align-items: stretch;
}

/* Fixed min-height so all cards start the same size; expand on "See more" */
.project-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  min-height: 180px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.project-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(59,130,246,0.1);
}

.project-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  flex-shrink: 0;
}

/* 3-line clamp — removed when .expanded is toggled */
.project-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  transition: none;
}

.project-card-desc.expanded {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

/* Footer row: tech + see-more side by side */
.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  flex-shrink: 0;
}

.project-card-tech {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.see-more-btn {
  border: none;
  background: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.see-more-btn:hover { color: var(--primary-dark); }

.project-card-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  margin-top: 8px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.project-card-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}


/* ── Generating indicator ─────────────────────────────────── */
.generating-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
}

.dot-flashing {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: dot-flashing 1s infinite linear alternate;
}

@keyframes dot-flashing {
  0%   { opacity: 0.2; transform: scale(0.8); }
  100% { opacity: 1;   transform: scale(1); }
}

/* ── PDF Upload Row ───────────────────────────────────────── */
.pdf-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.pdf-upload-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}

.pdf-upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.pdf-divider {
  font-size: 12px;
  color: var(--text-light);
}

.pdf-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  color: #15803d;
  font-size: 13px;
  font-weight: 500;
}

.pdf-indicator svg { flex-shrink: 0; }

#pdf-name {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-remove-btn {
  border: none;
  background: none;
  color: #15803d;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.pdf-remove-btn:hover { opacity: 1; }

/* ── Input area ───────────────────────────────────────────── */
.input-area {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-wrapper textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  resize: none;
  outline: none;
  line-height: 1.6;
  transition: border-color 0.2s;
  max-height: 200px;
  overflow-y: auto;
}

.input-wrapper textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}

.send-btn {
  width: 44px;
  height: 44px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.send-btn:hover    { background: var(--primary-dark); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input-hint {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 6px;
  padding-left: 2px;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: opacity 0.3s;
}

.toast.show { display: block; }

/* Responsive */
@media (max-width: 860px) {
  .tools-grid { grid-template-columns: 1fr; }
  .home-view  { padding: 32px 20px; }
}

@media (max-width: 700px) {
  .sidebar { width: 220px; min-width: 220px; }
  .messages-container { padding: 16px; }
}
