/* ===================================================
   style.css — AI Jobs Market Analytics Platform
   =================================================== */

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

:root {
  --bg-main: #0f1117;
  --bg-sidebar: #171923;
  --bg-card: #1e2130;
  --bg-input: #252836;
  --border: #2d3149;
  --accent: #6c63ff;
  --accent-hover: #7d76ff;
  --text-primary: #e8eaf0;
  --text-secondary: #8b90a7;
  --text-muted: #565c78;
  --bubble-user: #2a2d4a;
  --bubble-assistant: #1e2130;
  --status-color: #a78bfa;
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;
  --shadow: 0 2px 12px rgba(0,0,0,.4);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* ===================== Layout ===================== */
.layout {
  display: flex;
  height: 100vh;
}

/* ===================== Sidebar ==================== */
.sidebar {
  width: 280px;
  min-width: 200px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-header button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  border-radius: 6px;
  padding: 2px 8px;
  transition: all .2s;
}
.sidebar-header button:hover { color: var(--accent); border-color: var(--accent); }

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

.empty-hint {
  color: var(--text-muted);
  text-align: center;
  padding: 32px 16px;
  font-size: 13px;
}

.history-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 6px 6px 10px;
  margin-bottom: 8px;
  transition: all .2s;
}
.history-item:hover { border-color: var(--accent); background: #252a3e; }

.history-item-main {
  flex: 1;
  min-width: 0;
  padding: 4px 0;
  cursor: pointer;
}

.history-delete-btn {
  flex-shrink: 0;
  align-self: flex-start;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.history-delete-btn:hover:not(:disabled) {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.08);
}
.history-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.history-item .query-text {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item .meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-type-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(108,99,255,.2);
  color: var(--accent);
  font-weight: 500;
}

.cache-badge {
  font-size: 10px;
  color: var(--text-muted);
}

/* ===================== Chat Area ================== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo { font-size: 28px; }

.chat-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.schema-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all .2s;
}
.schema-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===================== Messages =================== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 880px;
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.bubble {
  background: var(--bubble-assistant);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  line-height: 1.7;
  font-size: 14px;
  max-width: 720px;
}

.message.user .bubble {
  background: var(--bubble-user);
  border-color: rgba(108,99,255,.3);
}

.bubble p { margin-bottom: 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { padding-left: 18px; }
.bubble li { margin-bottom: 4px; font-size: 13px; color: var(--text-secondary); }

/* Status message */
.status-msg {
  color: var(--status-color);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-msg::before { content: "▸"; }

/* Analysis message */
.analysis-msg {
  background: rgba(108,99,255,.08);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* Chart image */
.chart-container {
  margin-top: 12px;
}

.chart-container img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .2s;
}

.chart-container img:hover { transform: scale(1.01); }

.chart-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Error message */
.error-msg {
  color: var(--error);
  font-size: 13px;
  background: rgba(248,113,113,.08);
  border: 1px solid rgba(248,113,113,.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

/* Loading animation */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ===================== Input Area ================= */
.input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg-sidebar);
  flex-shrink: 0;
}

#userInput {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  line-height: 1.5;
  transition: border-color .2s;
}

#userInput:focus {
  outline: none;
  border-color: var(--accent);
}

#userInput::placeholder { color: var(--text-muted); }

#sendBtn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
}

#sendBtn:hover { background: var(--accent-hover); }
#sendBtn:active { transform: scale(.97); }
#sendBtn:disabled { background: var(--text-muted); cursor: not-allowed; }

/* ===================== Modal ====================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal.hidden { display: none; }

.hidden { display: none !important; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color .2s;
}
.modal-header button:hover { color: var(--text-primary); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}

.schema-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.schema-table th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.schema-table td {
  padding: 7px 12px;
  border-bottom: 1px solid rgba(45,49,73,.5);
  color: var(--text-primary);
}

.schema-table tr:last-child td { border-bottom: none; }
.schema-table tr:hover td { background: rgba(255,255,255,.02); }

.schema-meta {
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

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

/* ===================== Image Lightbox ============= */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

/* ===================== Chart Type Bar ============= */
.chart-type-bar {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.chart-bar-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chart-type-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.ct-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}
.ct-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(108,99,255,.08); }
.ct-btn.active { background: rgba(108,99,255,.2); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ===================== Mode Buttons =============== */
.salary-mode-btn {
  background: transparent;
  border: 1px solid var(--warning);
  color: var(--warning);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  flex-shrink: 0;
}
.salary-mode-btn:hover { background: rgba(251,191,36,.12); }

/* ===================== Salary Panel =============== */
.salary-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
  padding: 12px 18px 16px;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 60vh;
}

.salary-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.salary-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--warning);
}

.salary-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all .18s;
}
.salary-action-btn:hover { border-color: var(--accent); color: var(--accent); }

.salary-close-btn {
  background: transparent;
  border: 1px solid rgba(248,113,113,.4);
  color: var(--error);
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}
.salary-close-btn:hover { background: rgba(248,113,113,.12); border-color: var(--error); }

/* ===================== Salary Form ================ */
.salary-form { display: flex; flex-direction: column; gap: 8px; }

.sf-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 130px;
}

.sf-field.sf-wide { flex: 2; min-width: 260px; }
.sf-field.sf-submit { flex: 0; min-width: auto; justify-content: flex-end; }

.sf-field label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sf-field input,
.sf-field select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color .18s;
  width: 100%;
}
.sf-field input:focus,
.sf-field select:focus { outline: none; border-color: var(--accent); }
.sf-field input::placeholder { color: var(--text-muted); }
.sf-field select option { background: var(--bg-card); }

.predict-btn {
  background: var(--warning);
  color: #1a1a1a;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .18s;
  white-space: nowrap;
  margin-top: 14px;
}
.predict-btn:hover { opacity: 0.85; }
.predict-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===================== Salary Result ============== */
.salary-result {
  background: rgba(251,191,36,.06);
  border: 1px solid rgba(251,191,36,.3);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 8px;
}

.salary-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.salary-label {
  font-size: 12px;
  color: var(--text-muted);
}

.salary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--warning);
  letter-spacing: -0.5px;
}

.salary-unit { font-size: 12px; color: var(--text-muted); }

.salary-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.salary-meta strong { color: var(--text-primary); }

.salary-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.salary-breakdown-table th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.salary-breakdown-table td {
  padding: 5px 10px;
  border-bottom: 1px solid rgba(45,49,73,.4);
  color: var(--text-primary);
}

.salary-breakdown-table tr:last-child td { border-bottom: none; }
