/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f8f9fa; color: #1a1a2e; }
a { text-decoration: none; color: inherit; }
button, input, textarea, select { font-family: inherit; }

/* ===== APP LAYOUT ===== */
.app-layout {
  display: grid;
  height: 100vh;
  overflow: hidden;
}

/* Hai trạng thái, CÙNG một DOM — chỉ đổi vị trí ô lưới. Nhờ vậy khung chat
   không bị dựng lại khi chuyển, nên giữ nguyên tin nhắn và vị trí cuộn. */
.sidebar     { grid-area: sidebar; }
.jobs-panel  { grid-area: jobs; }
.chat-panel  { grid-area: chat; }

/* Màn hình chào: chỉ sidebar + khung chat ở giữa. */
.app-layout[data-state="welcome"] {
  grid-template-columns: 2fr 10fr;
  grid-template-areas: "sidebar chat";
}

.app-layout[data-state="welcome"] .jobs-panel { display: none; }
.app-layout[data-state="welcome"] .chat-header { display: none; }
.app-layout[data-state="welcome"] .chat-panel { border-right: none; }

/* Nội dung dồn vào giữa theo chiều dọc, và giới hạn bề ngang cho dễ đọc. */
.app-layout[data-state="welcome"] .chat-messages {
  flex: 0 1 auto;
  justify-content: center;
  padding: 0 24px;
}

.app-layout[data-state="welcome"] .chat-panel {
  justify-content: center;
  background: #fbfbfe;
}

.app-layout[data-state="welcome"] .chat-messages,
.app-layout[data-state="welcome"] .chat-input-area {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.app-layout[data-state="welcome"] .chat-input-area { border-top: none; }

/* Có kết quả: kết quả chiếm chỗ giữa, khung chat dạt sang phải. */
/* Chia theo lưới 12 cột: sidebar 2 · kết quả 6 · chat 4.
   Dùng fr thay vì px cố định để tỉ lệ giữ nguyên ở mọi bề ngang màn hình. */
.app-layout[data-state="results"] {
  grid-template-columns: 2fr 6fr 4fr;
  grid-template-areas: "sidebar jobs chat";
}

.app-layout[data-state="results"] .chat-panel {
  border-right: none;
  border-left: 1px solid #e8e8f0;
}

/* Màn hình hẹp: xếp chồng thay vì bóp ba cột thành không đọc nổi. */
@media (max-width: 1100px) {
  .app-layout[data-state="results"] {
    grid-template-columns: 220px 1fr;
    grid-template-areas: "sidebar jobs" "sidebar chat";
    grid-template-rows: 1fr 45vh;
  }
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: #fafafa;
  color: #000;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #fafafa;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid #fafafa;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: #000;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-new-chat:hover { background: #2f4ac7; }

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

.history-label {
  font-size: 11px;
  color: #666;
  padding: 4px 8px 8px;
  letter-spacing: 0.5px;
}

.history-item {
  display: flex;
  align-items: center;
  border-radius: 6px;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.history-item:hover, .history-item.active {
  background: #e2e2e2;
}

.history-link {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
  color: #000;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-delete {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.15s;
}

.history-item:hover .history-delete { opacity: 1; }
.history-delete:hover { color: #ff4757; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #e8e8f0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: #3b5bdb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #000; }
.user-plan { font-size: 11px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-signout {
  width: 100%;
  margin-top: 8px;
  padding: 7px;
  background: #f5f5f5;
  color: #555;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-signout:hover { background: #ffe0e0; color: #c0392b; border-color: #f5c6c6; }

.auth-links {
  display: flex;
  gap: 8px;
}

.btn-signin {
  flex: 1;
  display: block;
  padding: 9px;
  background: #3b5bdb;
  color: white;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: background 0.2s;
}
.btn-signin:hover { background: #2f4ac7; }

.btn-signup {
  flex: 1;
  display: block;
  padding: 9px;
  background: white;
  color: #3b5bdb;
  border: 1px solid #3b5bdb;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
}
.btn-signup:hover { background: #f0f4ff; }

/* ===== DEVISE EXTRA STYLES ===== */
.devise-subtitle {
  font-size: 14px;
  color: #888;
  margin-bottom: 24px;
  margin-top: -4px;
}

.devise-logo {
  text-align: center;
  margin-bottom: 20px;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #555;
}

.field-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.field-hint {
  font-size: 12px;
  color: #888;
  margin-left: 4px;
}

.devise-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 13px;
}

.devise-links a {
  color: #3b5bdb;
  transition: color 0.15s;
}
.devise-links a:hover { color: #2f4ac7; text-decoration: underline; }

.btn-signout {
  font-size: 12px;
  color: #888;
  cursor: pointer;
}
.btn-signout:hover { color: #ff4757; }

.btn-signin {
  display: block;
  padding: 8px 16px;
  background: #3b5bdb;
  color: white;
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
}

/* ===== CHAT PANEL ===== */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e8e8f0;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border-bottom: 1px solid #f0f0f8;
  font-size: 14px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #2ed573;
  border-radius: 50%;
}

.status-badge {
  background: #e8fff0;
  color: #2ed573;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

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

.welcome-message {
  background: #f0f4ff;
  border-radius: 12px 12px 12px 4px;
  padding: 16px 20px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.6;
  color: #444;
}

.message { display: flex; }

.message-user { justify-content: flex-end; }
.message-assistant { justify-content: flex-start; }

.message-user .message-bubble {
  background: #3b5bdb;
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 18px;
  max-width: 75%;
  font-size: 14px;
  line-height: 1.5;
}

.message-assistant .message-bubble {
  background: #f5f5f8;
  color: #333;
  border-radius: 4px 18px 18px 18px;
  padding: 12px 18px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.5;
}

.chat-input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid #f0f0f8;
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #f8f9ff;
  border: 1px solid #e0e0f0;
  border-radius: 12px;
  padding: 10px 14px;
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 2.5;
  color: #333;
  max-height: 120px;
}

.chat-input::placeholder { color: #aaa; }

.chat-submit {
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-submit:hover { background: #2f4ac7; }

/* ===== JOBS PANEL ===== */
.jobs-panel {
  background: #fafafa;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.jobs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8e8f0;
  background: white;
}

.jobs-header h2 { font-size: 16px; font-weight: 700; }

.jobs-count {
  background: #3b5bdb;
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.jobs-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  /* Hai cột khi kết quả nằm ở giữa. auto-fit + minmax để cột tự co về 1 khi
     hẹp, thay vì bóp card đến mức không đọc được. */
  /* 270px chứ không phải 320px: cột kết quả giờ chỉ chiếm 6/12 màn hình, để
     ngưỡng cao thì màn 1280px sẽ rớt về 1 cột — trái với thiết kế 2 cột. */
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 12px;
  align-content: start;
}

/* Ô "chưa có kết quả" trải hết chiều ngang lưới, không nằm gọn trong 1 cột. */
.jobs-empty { grid-column: 1 / -1; }

.jobs-empty {
  text-align: center;
  color: #999;
  padding: 40px 20px;
  font-size: 14px;
}

/* ===== JOB CARD ===== */
.job-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #ebebf5;
  transition: box-shadow 0.2s, transform 0.2s;
}

.job-card:hover {
  box-shadow: 0 4px 16px rgba(59, 91, 219, 0.12);
  transform: translateY(-1px);
}

.job-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.company-logo {
  width: 40px;
  height: 40px;
  background: #f0f4ff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #999;
  flex-shrink: 0;
  border: 1px solid #e0e8ff;
}

.job-info { flex: 1; min-width: 0; }

.job-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 4px;
  line-height: 1.3;
}

.job-title:hover { color: #3b5bdb; }

.job-meta {
  font-size: 12px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.separator { color: #ccc; }

.job-salary {
  font-size: 14px;
  font-weight: 700;
  color: #2ed573;
  white-space: nowrap;
}

.job-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.tag-skill {
  background: #eef2ff;
  color: #3b5bdb;
}

.job-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #888;
}

.job-type {
  display: flex;
  align-items: center;
  gap: 4px;
}

.job-type::before {
  content: "⏱";
  font-size: 11px;
}

/* ===== FLASH MESSAGES ===== */
.flash {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  animation: slideIn 0.3s ease;
}

.flash-notice { background: #e8fff0; color: #2ed573; border: 1px solid #b3f0cc; }
.flash-alert  { background: #fff0f0; color: #ff4757; border: 1px solid #ffc0c0; }

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

/* ===== DEVISE FORMS ===== */
.devise-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f4ff;
}

.devise-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  width: 400px;
  box-shadow: 0 8px 40px rgba(59, 91, 219, 0.12);
}

.devise-card h2 {
  text-align: center;
  margin-bottom: 28px;
  font-size: 24px;
  color: #1a1a2e;
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #555; }
.field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dde1ef;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus { border-color: #3b5bdb; }

.devise-actions {
  margin-top: 20px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
}

.btn-primary:hover { background: #2f4ac7; }

.devise-links {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: #888;
}

.devise-links a { color: #3b5bdb; }
.devise-links a:hover { text-decoration: underline; }

.error-messages {
  background: #fff0f0;
  border: 1px solid #ffd0d0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #cc0000;
}

/* ===== SIDEBAR USER PROFILE LINK ===== */
.user-avatar { cursor: pointer; transition: opacity 0.15s; }
.user-avatar:hover { opacity: 0.85; }
.user-profile-link { color: inherit; }
.user-profile-link:hover { color: #3b5bdb; }

/* ===== PROFILE PAGE ===== */
.profile-layout {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 24px 60px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  background: white;
  border-radius: 16px;
  padding: 28px 32px;
  border: 1px solid #e8e8f0;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  background: #3b5bdb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.profile-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-username {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
}

.profile-email {
  font-size: 14px;
  color: #666;
}

.profile-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  width: fit-content;
}

.profile-status--active { background: #e8f5e9; color: #2e7d32; }
.profile-status--inactive { background: #f5f5f5; color: #888; }
.profile-status--banned { background: #ffebee; color: #c62828; }

.btn-back {
  padding: 8px 16px;
  background: #f0f4ff;
  color: #3b5bdb;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-back:hover { background: #dce4ff; }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border: 1px solid #e8e8f0;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-number {
  font-size: 26px;
  font-weight: 700;
  color: #3b5bdb;
}

.stat-label {
  font-size: 12px;
  color: #888;
}

.profile-section {
  background: white;
  border-radius: 16px;
  border: 1px solid #e8e8f0;
  padding: 28px 32px;
}

.profile-section-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f5;
}

.profile-empty {
  text-align: center;
  padding: 40px 0;
  color: #888;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.applications-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.application-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid #f0f0f5;
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.application-card:hover {
  border-color: #c5cae9;
  box-shadow: 0 2px 8px rgba(59,91,219,0.06);
}

.application-job-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.application-company-logo {
  width: 44px;
  height: 44px;
  background: #f0f4ff;
  color: #3b5bdb;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.application-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.application-job-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.application-job-title a { color: inherit; }
.application-job-title a:hover { color: #3b5bdb; }

.application-meta {
  font-size: 12px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
}

.application-salary { color: #2e7d32; font-weight: 500; }

.sep { color: #ddd; }

.application-skills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.application-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.application-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.application-status--delivered { background: #e3f2fd; color: #1565c0; }
.application-status--approved  { background: #e8f5e9; color: #2e7d32; }
.application-status--rejected  { background: #ffebee; color: #c62828; }
.application-status--failed    { background: #fff3e0; color: #e65100; }

.application-date {
  font-size: 11px;
  color: #aaa;
}

/* ===== JOB DETAIL PAGE ===== */
.job-detail-layout {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}

.job-detail-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  border: 1px solid #e8e8f0;
}

/* ===== APPLY BUTTON & BADGE ===== */
.btn-apply {
  margin-left: auto;
  padding: 6px 14px;
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-apply:hover { background: #2f4ac7; }

.applied-badge {
  margin-left: auto;
  padding: 4px 10px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* ===== APPLY MODAL ===== */
.apply-modal-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

.apply-modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.apply-modal-content {
  padding: 28px 32px 32px;
}

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

.apply-modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: #888;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.modal-close-btn:hover { background: #f0f0f0; color: #333; }

.apply-form .form-group {
  margin-bottom: 18px;
}

.apply-form .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.apply-form .form-group input[type="text"],
.apply-form .form-group input[type="email"],
.apply-form .form-group input[type="tel"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dde1ef;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #fafbff;
}
.apply-form .form-group input:focus { border-color: #3b5bdb; background: white; }

.required { color: #e53e3e; margin-left: 2px; }

.file-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  border: 2px dashed #c5cae9;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fafbff;
  text-align: center;
}
.file-upload-area:hover { border-color: #3b5bdb; background: #f0f4ff; }

.file-input-hidden {
  display: none;
}

.upload-icon {
  color: #7986cb;
  width: 28px;
  height: 28px;
}

.file-label-text {
  font-size: 13px;
  color: #666;
}

.file-label-error {
  color: #e53e3e !important;
}

.apply-form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: flex-end;
}

.btn-modal-cancel {
  padding: 10px 20px;
  background: #f0f0f5;
  color: #555;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-modal-cancel:hover { background: #e2e2ea; }

.btn-modal-submit {
  padding: 10px 24px;
  background: #3b5bdb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-modal-submit:hover { background: #2f4ac7; }

/* ===== PHASE 2: PHẢN HỒI TỨC THÌ ===== */

/* Ô "đang trả lời" do client vẽ ngay khi bấm gửi. Một lượt mất ~4 giây; không
   có nó thì màn hình đứng yên hoàn toàn và người dùng tưởng app treo. */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
}

.typing-label {
  font-size: 13px;
  color: #888;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b0b0c0;
  animation: typing-bounce 1.25s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 0.16s; }
.typing-dots i:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing-bounce {
  0%, 70%, 100% { transform: translateY(0);   opacity: 0.45; }
  35%           { transform: translateY(-4px); opacity: 1; }
}

/* Người dùng bật "giảm chuyển động" thì bỏ animation, giữ lại chấm tĩnh. */
@media (prefers-reduced-motion: reduce) {
  .typing-dots i { animation: none; opacity: 0.7; }
}

.message-error {
  background: #fff2f0 !important;
  color: #b42318 !important;
  border: 1px solid #ffd7d1;
  border-radius: 4px 18px 18px 18px;
  padding: 12px 18px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.5;
}

.welcome-examples {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #667;
  font-size: 13px;
  line-height: 1.9;
}

.welcome-examples li { list-style: "› "; padding-left: 4px; }

/* ===== CHIP ĐIỀU KIỆN ===== */
/* Cho người dùng thấy hệ thống hiểu gì từ câu của họ, và sửa được ngay khi
   hiểu sai — thay vì phải đoán tại sao kết quả lại ra như vậy. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  background: white;
  border-bottom: 1px solid #e8e8f0;
}

.chips-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #99a;
  margin-right: 2px;
}

/* button_to sinh ra <form>; bỏ layout mặc định để chip nằm gọn trong hàng. */
.chips form { display: inline; margin: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  border: 1px solid #dcdce8;
  border-radius: 14px;
  background: #f6f7fb;
  color: #333;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.chip:hover { background: #ecefff; border-color: #b9c4f0; }

.chip-remove {
  font-size: 14px;
  line-height: 1;
  color: #99a;
  font-weight: 600;
}

.chip:hover .chip-remove { color: #b42318; }

/* Màu theo loại điều kiện: nhìn lướt là biết đang lọc theo chiều nào. */
.chip-skill     { background: #eef2ff; border-color: #c9d4f5; }
.chip-location  { background: #f0fdf4; border-color: #bbe7c8; }
.chip-salary    { background: #fffbeb; border-color: #f3e0a8; }
.chip-exclude   { background: #fef2f2; border-color: #f5c9c9; color: #a13232; }
.chip-sort      { background: #f5f3ff; border-color: #d8cdf5; }

/* ===== POPUP CHI TIẾT JOB ===== */
.job-modal-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(680px, 92vw);
  max-height: 88vh;
  box-shadow: 0 20px 60px rgba(20, 20, 50, 0.28);

  /* Trình duyệt căn giữa <dialog> ở chế độ modal bằng `inset: 0; margin: auto`
     trong UA stylesheet. Nhưng reset toàn cục ở đầu file đặt `* { margin: 0 }`,
     và style của tác giả thắng UA stylesheet — nên modal dính góc trên trái.
     Trả lại `margin: auto` là đủ.

     Cố ý KHÔNG dùng `top/left: 50%` + `transform: translate(-50%, -50%)` như
     .apply-modal-dialog: cách đó cắt mất phần đầu và không cuộn tới được khi
     nội dung cao hơn màn hình. Mô tả job thì dài, nên phải tránh. */
  inset: 0;
  margin: auto;
}

.job-modal-dialog::backdrop { background: rgba(15, 15, 35, 0.45); }

.job-modal-content {
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}

.job-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid #eeeef4;
}

.job-modal-header h3 { font-size: 18px; font-weight: 700; line-height: 1.35; }

.job-modal-company {
  margin-top: 4px;
  font-size: 13px;
  color: #778;
}

/* Chỉ phần thân cuộn — tiêu đề và nút ứng tuyển luôn nhìn thấy được. */
.job-modal-facts,
.job-modal-section { padding: 16px 22px; }

.job-modal-section { border-top: 1px solid #f2f2f8; overflow-y: auto; }

.job-modal-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  background: #fafaff;
}

.job-fact { display: flex; flex-direction: column; gap: 3px; }

.job-fact-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #99a;
}

.job-fact-value { font-size: 14px; font-weight: 600; color: #1a1a2e; }
.job-fact-muted { color: #aab; font-weight: 400; font-style: italic; }

.job-modal-section h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #99a;
  margin-bottom: 10px;
}

.job-modal-description {
  font-size: 14px;
  line-height: 1.7;
  color: #444;
  max-height: 34vh;
  overflow-y: auto;
}

.job-modal-description p { margin-bottom: 10px; }

.tag-expertise { background: #f0fdf4; border: 1px solid #bbe7c8; }

.job-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 22px;
  border-top: 1px solid #eeeef4;
  background: #fafafa;
  border-radius: 0 0 14px 14px;
}

/* ===== MÀN HÌNH CHÀO ===== */
.welcome-hero {
  text-align: center;
  padding: 8px 0 4px;
}

.welcome-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #1a1a2e;
  margin-bottom: 10px;
}

.welcome-lead {
  font-size: 15px;
  color: #667;
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto 28px;
}

/* Bốn nhóm việc hệ thống làm được. Cố ý nêu ví dụ cụ thể thay vì mô tả trừu
   tượng — "lương từ 1500$ hoặc 30 triệu" dạy được nhiều hơn "hỗ trợ lọc lương". */
.welcome-guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  text-align: left;
  margin-bottom: 28px;
}

.guide-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: white;
  border: 1px solid #ebebf5;
  border-radius: 10px;
}

.guide-label {
  font-size: 12px;
  font-weight: 700;
  color: #3b5bdb;
}

.guide-hint {
  font-size: 12.5px;
  color: #8890a5;
  line-height: 1.5;
}

.welcome-try {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #99a;
  margin-bottom: 10px;
}

.welcome-samples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

/* Bấm là gửi luôn. Rào cản lớn nhất của giao diện chat là không biết gõ gì
   trước — cho sẵn câu thật, bấm được, tốt hơn mọi đoạn hướng dẫn. */
.sample-chip {
  text-align: left;
  padding: 11px 14px;
  border: 1px solid #dcdcec;
  border-radius: 10px;
  background: white;
  color: #444;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}

.sample-chip:hover {
  border-color: #3b5bdb;
  background: #f5f7ff;
  color: #1a1a2e;
}

.sample-chip:active { transform: translateY(1px); }

/* Card việc làm khi ở lưới 2 cột: cao bằng nhau cho hàng đều nhau. */
.app-layout[data-state="results"] .job-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.app-layout[data-state="results"] .job-footer { margin-top: auto; }
