/* Thiết lập gốc & Tối ưu Mobile-First */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary);
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Thanh điều hướng */
.site-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 4rem;
  padding: 0.5rem 1rem;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

/* Nút to Sổ tay Kết cấu ở giữa Header */
.btn-handbook-large {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.35rem;
  background: linear-gradient(135deg, #f0fdf4 0%, #e6f7ef 100%);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-full);
  color: #065f46;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-handbook-large:hover {
  background: var(--primary);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-handbook-large:hover .badge-handbook-free {
  background: #ffffff;
  color: var(--primary);
}

.badge-handbook-free {
  background: var(--primary);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Menu người dùng: bấm vào mũi tên để mở */
.user-menu {
  position: relative;
}

.user-menu-toggle {
  list-style: none !important;
  list-style-type: none !important;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background: #ffffff;
  transition: border-color 0.15s ease;
}

.user-menu-toggle::-webkit-details-marker,
summary::-webkit-details-marker {
  display: none !important;
}

.user-menu-toggle::marker,
summary::marker {
  display: none !important;
  content: "" !important;
}

.user-menu-toggle::after {
  content: none !important;
}

.user-menu-toggle.btn-login-arrow {
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: 8px !important;
  list-style: none !important;
}

.user-menu-toggle.btn-login-arrow svg {
  display: block;
}

.user-menu-toggle:hover,
.user-menu[open] .user-menu-toggle {
  border-color: var(--primary);
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 210px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
  z-index: 60;
}

.user-menu-panel a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
}

.user-menu-panel a:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
}

.user-menu-org {
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.25rem;
}

/* Bàn làm việc: lưới ô tiện ích 3 cột */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  max-width: 960px;
  margin: 3rem auto;
}

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 110px;
  padding: 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.tile:nth-child(odd) {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

.tile:hover {
  border-color: var(--primary);
  color: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.empty-note {
  max-width: 520px;
  margin: 4rem auto;
  text-align: center;
  color: var(--text-secondary);
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-text {
  display: inline;
  letter-spacing: -0.02em;
}

.brand-cons {
  color: var(--primary);
}

.brand-badge {
  margin-left: 0.5rem;
  background: var(--primary);
  color: #ffffff;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  list-style: none;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.35rem;
  transition: color 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
}

/* Nút bấm chuẩn Mobile: Tối thiểu 44px dễ chạm */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-surface);
  border-color: #cbd5e1;
}

.btn-sm {
  min-height: 38px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

/* Thẻ chứa (Cards) */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Biểu mẫu (Forms) */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* Bảng dữ liệu: Tối ưu cuộn ngang mượt cho Mobile */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 600px;
}

.table th,
.table td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.table th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

.table tr:hover td {
  background: #f8fafc;
}

/* Huy hiệu (Badges) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.badge-primary,
.badge-success {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: #15803d;
}

.badge-light {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* Thông báo (Alerts) */
.alert {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.alert-success {
  background: #f0fdf4;
  border-color: var(--primary-border);
  color: #15803d;
}

/* Biểu tượng mũi tên Đăng nhập ở Header */
.btn-login-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border-color, #e2e8f0);
  color: var(--text-secondary, #475569);
  transition: all 0.2s ease;
}

.btn-login-arrow:hover {
  background: #f0fdf4;
  border-color: var(--primary, #2e7d32);
  color: var(--primary, #2e7d32);
  transform: translateX(1px);
}

/* Widget Trợ lý AI (Trao đổi nghề nghiệp & Góp ý) */
.ai-chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
}

.ai-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  background: var(--primary, #2e7d32);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(46, 125, 50, 0.3);
  transition: all 0.2s ease;
}

.ai-chat-toggle:hover {
  background: #1b5e20;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(46, 125, 50, 0.38);
}

.ai-chat-panel {
  position: absolute;
  bottom: 3.5rem;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 2rem);
  height: 480px;
  max-height: calc(100vh - 6rem);
  background: #ffffff;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat-header {
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-chat-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #111827;
}

.ai-chat-sub {
  font-size: 0.75rem;
  color: #64748b;
}

.ai-chat-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.ai-chat-close:hover {
  color: #111827;
}

.ai-chat-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-msg {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.5;
}

.ai-msg-bot {
  background: #f1f5f9;
  color: #1e293b;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

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

.ai-chat-input-wrap {
  padding: 0.65rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 0.5rem;
  background: #ffffff;
}

.ai-chat-input-wrap input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.86rem;
  outline: none;
}

.ai-chat-input-wrap input:focus {
  border-color: var(--primary, #2e7d32);
}

.ai-chat-input-wrap button {
  background: var(--primary, #2e7d32);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 0 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 480px) {
  .ai-chat-panel {
    width: calc(100vw - 2rem);
    right: 0;
  }
}

.alert-error {
  background: #f8fafc;
  border-color: #64748b;
  color: #0f172a;
}