/* ===== RESET CƠ BẢN ===== */
/* Xóa margin/padding mặc định của trình duyệt */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background-color: #f0f2f5;
  color: #333;
}

/* ===== TRANG ĐĂNG NHẬP ===== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-box h1 {
  font-size: 32px;
  color: #2c3e50;
  margin-bottom: 4px;
}

.login-box .subtitle {
  color: #888;
  margin-bottom: 30px;
  font-size: 14px;
}

/* ===== FORM ===== */
.form-group {
  margin-bottom: 18px;
  text-align: left;
}

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

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

/* ===== NÚT BẤM ===== */
button[type="submit"] {
  width: 100%;
  padding: 12px;
  background-color: #2c3e50;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background-color 0.2s;
}

button[type="submit"]:hover {
  background-color: #1a252f;
}

/* ===== THÔNG BÁO LỖI ===== */
.error-msg {
  margin-top: 16px;
  padding: 10px;
  background-color: #fee;
  color: #c0392b;
  border-radius: 8px;
  font-size: 14px;
}

/* ===== FOOTER ===== */
.footer-text {
  margin-top: 24px;
  font-size: 11px;
  color: #aaa;
}

/* ===== THANH ĐIỀU HƯỚNG (NAVBAR) ===== */
.navbar {
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #fff;
  padding: 0 20px;
  height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky; top: 0; z-index: 100;
}

.nav-brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.nav-role {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.btn-logout {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
}

/* ===== LAYOUT CHÍNH (SIDEBAR + CONTENT) ===== */
.main-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid #e8ecf1;
  padding: 12px 0;
  box-shadow: 1px 0 4px rgba(0,0,0,0.03);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 2px 8px;
  color: #64748b;
  text-decoration: none;
  font-size: 13px;
  border-radius: 8px;
  transition: all 0.15s;
}

.menu-icon { display: flex; align-items: center; flex-shrink: 0; opacity: 0.7; }
.menu-text { white-space: nowrap; }

.menu-item:hover {
  background: #f1f5f9;
  color: #1e293b;
}
.menu-item:hover .menu-icon { opacity: 1; }

.menu-item.active {
  background: linear-gradient(135deg, #eff6ff, #f0f0ff);
  color: #2563eb;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #2563eb;
}
.menu-item.active .menu-icon { opacity: 1; color: #2563eb; }

.content {
  flex: 1;
  padding: 24px 32px;
}

.content h2 {
  margin-bottom: 24px;
  color: #2c3e50;
}

/* ===== Ô THỐNG KÊ ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #fff;
  padding: 20px 24px;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  text-align: center;
  border: 1px solid #f0f0f0;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.stat-card:nth-child(1) { border-top: 3px solid #3b82f6; }
.stat-card:nth-child(2) { border-top: 3px solid #8b5cf6; }
.stat-card:nth-child(3) { border-top: 3px solid #10b981; }
.stat-card:nth-child(4) { border-top: 3px solid #f59e0b; }

.stat-number {
  font-size: 32px;
  font-weight: 800;
  color: #1e293b;
}

.stat-label {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
  font-weight: 500;
}

/* ===== THÔNG TIN CÔNG TY ===== */
.info-card {
  background: #fff;
  padding: 24px;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.info-card h3 {
  margin-bottom: 16px;
  color: #2c3e50;
}

.info-card p {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== PAGE HEADER (tiêu đề + nút) ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h2 {
  margin-bottom: 0;
}

/* ===== NÚT BẤM CHUNG ===== */
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(37,99,235,0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #4338ca);
  box-shadow: 0 4px 8px rgba(37,99,235,0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-edit {
  background: none;
  border: 1px solid #3b82f6;
  color: #3b82f6;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

.btn-edit:hover {
  background: #3b82f6;
  color: #fff;
}

.btn-delete {
  background: none;
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

.btn-delete:hover {
  background: #ef4444;
  color: #fff;
}

/* ===== THANH TÌM KIẾM ===== */
.search-bar {
  margin-bottom: 16px;
}

.search-bar input {
  width: 100%;
  max-width: 400px;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}

.search-bar input:focus {
  outline: none;
  border-color: #3498db;
}

/* ===== BẢNG DỮ LIỆU ===== */
.table-container {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background-color: #f8f9fa;
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  color: #666;
  font-weight: 600;
  border-bottom: 2px solid #e0e0e0;
}

td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
}

tr:hover {
  background-color: #fafafa;
}

/* ===== BADGE TRẠNG THÁI ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-active {
  background: #dcfce7;
  color: #166534;
}
.badge-active::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; }

.badge-inactive {
  background: #fee2e2;
  color: #991b1b;
}
.badge-inactive::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #ef4444; }

.badge-warning {
  background-color: #fff3e0;
  color: #e65100;
}

/* ===== MODAL (POPUP) ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  color: #2c3e50;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
}

.modal-content form {
  padding: 24px;
}

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 0;
}

.form-row .form-group {
  flex: 1;
}

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

/* ===== SELECT DROPDOWN ===== */
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  background-color: #fff;
}

/* ===== BỘ LỌC ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-bar input {
  flex: 1;
  max-width: 400px;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}

.filter-bar input:focus {
  outline: none;
  border-color: #3498db;
}

.filter-bar select {
  width: 200px;
  padding: 10px 14px;
  font-size: 14px;
}

/* ===== FOOTER BẢNG ===== */
.table-footer {
  margin-top: 12px;
  font-size: 13px;
  color: #888;
}

/* ===== SƠ ĐỒ CÂY PHÒNG BAN ===== */
.org-root {
  font-size: 16px;
  padding: 8px 0;
  color: #2c3e50;
}

.org-list {
  list-style: none;
  padding-left: 28px;
  border-left: 2px solid #e0e0e0;
  margin: 4px 0;
}

.org-item {
  padding: 6px 0;
  font-size: 14px;
  position: relative;
}

.org-item::before {
  content: '';
  position: absolute;
  left: -28px;
  top: 14px;
  width: 20px;
  border-top: 2px solid #e0e0e0;
}

/* ===== TABS DANH MỤC ===== */
.catalog-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  cursor: pointer;
  color: #888;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-weight: 500;
}

.tab-btn:hover {
  color: #2c3e50;
}

.tab-btn.active {
  color: #2c3e50;
  font-weight: 600;
  border-bottom-color: #2c3e50;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-content h3 {
  color: #2c3e50;
  margin-bottom: 0;
}

/* ===== CHECKBOX ROW ===== */
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
}

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

/* ===== CONTEXT MENU (3 chấm) ===== */
.ctx-menu-wrap {
  position: relative;
  display: inline-block;
}

.ctx-menu-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 8px;
  color: #666;
}

.ctx-menu-btn:hover {
  background: #f0f0f0;
}

.ctx-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 160px;
  z-index: 100;
}

.ctx-menu.show {
  display: block;
}

.ctx-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.ctx-item:hover {
  background: #f5f5f5;
}

.ctx-item.ctx-danger {
  color: #e74c3c;
}

.ctx-item.ctx-danger:hover {
  background: #fef5f5;
}

/* ===== VIEW TOGGLE (Bảng / Cây) ===== */
.view-toggle {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.view-btn {
  padding: 6px 14px;
  background: white;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #666;
}

.view-btn.active {
  background: #2c3e50;
  color: white;
}

.view-btn:hover:not(.active) {
  background: #f5f5f5;
}

/* ===== SƠ ĐỒ CÂY TỔ CHỨC ===== */
/* ===== ORG CHART (CSS-only tree lines) ===== */
.oc-tree { overflow-x: auto; padding: 20px 12px; }
.oc-tree ul { display: flex; justify-content: center; padding-top: 20px; position: relative; list-style: none; margin: 0; padding-left: 0; }
.oc-tree li { display: flex; flex-direction: column; align-items: center; position: relative; padding: 20px 6px 0; }

/* vertical line down from parent to horizontal bar */
.oc-tree li::before {
  content: ''; position: absolute; top: 0; left: 50%;
  border-left: 2px solid #bbb; height: 20px;
}

/* horizontal bar connecting siblings */
.oc-tree li::after {
  content: ''; position: absolute; top: 0;
  border-top: 2px solid #bbb;
  width: 100%; left: 0;
}
/* first child: bar only right half */
.oc-tree li:first-child::after { width: 50%; left: 50%; }
/* last child: bar only left half */
.oc-tree li:last-child::after { width: 50%; left: 0; }
/* only child: no horizontal bar */
.oc-tree li:only-child::after { display: none; }

/* remove all lines from root node */
.oc-tree > ul > li::before,
.oc-tree > ul > li::after { display: none; }

/* vertical line from node down to its children */
.oc-tree li > ul::before {
  content: ''; position: absolute; top: 0; left: 50%;
  border-left: 2px solid #bbb; height: 20px;
}

/* ===== CARDS ===== */
.oc-card {
  background: #fff; border: 2px solid #d0d5dd; border-radius: 8px;
  padding: 8px 12px; min-width: 120px; max-width: 180px;
  text-align: center; cursor: pointer; transition: box-shadow 0.2s, transform 0.15s;
  position: relative; z-index: 1; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.oc-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.15); transform: translateY(-2px); }

.oc-name { font-weight: 700; font-size: 11px; color: #1a202c; line-height: 1.3; margin-bottom: 2px; text-transform: uppercase; }
.oc-code { font-size: 9px; color: #aaa; margin-bottom: 3px; letter-spacing: 0.5px; }
.oc-leader { font-size: 10px; color: #2e7d32; margin-top: 3px; padding-top: 3px; border-top: 1px solid #eee; }
.oc-leader::before { content: '\1F464 '; }
.oc-count { display: inline-block; background: #e8f5e9; color: #2e7d32; font-size: 9px; padding: 1px 6px; border-radius: 10px; margin-top: 3px; }

/* Color by level */
.oc-root { border-color: #c0392b; background: linear-gradient(135deg, #fff5f5, #fff); }
.oc-root .oc-name { color: #c0392b; font-size: 12px; }
.oc-khoi { border-color: #2980b9; background: linear-gradient(135deg, #f0f7fd, #fff); }
.oc-khoi .oc-name { color: #2980b9; font-size: 11px; }
.oc-phong { border-color: #2c3e50; background: #fff; }
.oc-bp { border-color: #95a5a6; background: #fafbfc; }
.oc-bp .oc-name { font-size: 10px; text-transform: none; }
.oc-to { border-color: #bdc3c7; background: #fdfdfd; border-style: dashed; }
.oc-to .oc-name { font-weight: 600; font-size: 10px; text-transform: none; }

/* ===== NHẬT KÝ HOẠT ĐỘNG ===== */
.log-item {
  padding: 12px 16px;
  border-left: 3px solid #e0e0e0;
  margin-bottom: 2px;
  background: #fafafa;
}

.log-item.log-create { border-left-color: #27ae60; background: #f0faf4; }
.log-item.log-edit { border-left-color: #f39c12; background: #fffbf0; }
.log-item.log-delete { border-left-color: #e74c3c; background: #fef5f5; }
.log-item.log-login { border-left-color: #3498db; background: #f0f7fd; }

.log-time {
  font-size: 12px;
  color: #999;
  margin-bottom: 4px;
}

.log-content {
  font-size: 14px;
}

.log-action {
  color: #555;
}

.log-details {
  color: #888;
  font-size: 13px;
}

/* ===== APP LAUNCHER ===== */
.app-launcher-btn {
  background: none; border: none; color: white; cursor: pointer;
  padding: 6px; border-radius: 6px; display: flex; align-items: center;
  margin-right: 8px; transition: background 0.2s;
}
.app-launcher-btn:hover { background: rgba(255,255,255,0.15); }

.app-launcher-popup {
  display: none; position: fixed; top: 52px; left: 8px; z-index: 9999;
  background: white; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  width: 420px; max-height: 85vh; overflow: hidden;
}
.app-launcher-popup.show { display: flex; flex-direction: column; }

.alp-header { padding: 16px 20px 12px; border-bottom: 1px solid #f0f0f0; flex-shrink: 0; }
.alp-header h3 { font-size: 15px; color: #1a202c; margin: 0 0 10px; font-weight: 700; }
.alp-search {
  width: 100%; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 13px; outline: none; transition: border-color 0.2s;
}
.alp-search:focus { border-color: #3b82f6; }

.alp-body { overflow-y: auto; padding: 8px 0 12px; flex: 1; }

.alp-group { padding: 0 16px; }
.alp-group-title {
  font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 10px 4px 6px; margin-top: 4px;
}

.alp-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
}
.alp-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 4px; border-radius: 10px; cursor: pointer;
  transition: background 0.15s; text-align: center;
}
.alp-item:hover { background: #f1f5f9; }
.alp-disabled { opacity: 0.35; cursor: default; }
.alp-disabled:hover { background: transparent; }

.alp-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white; margin-bottom: 5px; box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.alp-name { font-size: 11px; font-weight: 600; color: #334155; line-height: 1.2; }

/* ===== COMPANY PAGE ===== */
.company-header {
  display: flex; align-items: center; gap: 20px;
  background: linear-gradient(135deg, #eef2ff, #f0f7fd); border: 1px solid #d0d5dd;
  border-radius: 12px; padding: 24px; margin-bottom: 20px;
}
.company-logo {
  width: 80px; height: 80px; border-radius: 12px;
  background: #2c3e50; color: white; font-size: 28px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.company-header-info { flex: 1; }
.company-name { font-size: 18px; color: #1a202c; margin: 0 0 10px; }
.company-badges { display: flex; gap: 12px; flex-wrap: wrap; }
.co-badge {
  background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 20px;
  padding: 4px 14px; font-size: 13px; color: #555;
}
.co-badge-green { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }

.company-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 900px) { .company-grid { grid-template-columns: 1fr; } }

.company-section {
  background: #fff; border: 1px solid #e8e8e8; border-radius: 10px; padding: 20px;
}
.company-section.full-width { margin-bottom: 20px; }
.company-section h3 {
  font-size: 15px; color: #2c3e50; margin: 0 0 16px;
  padding-bottom: 8px; border-bottom: 2px solid #eef2ff;
}

.co-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.co-field { margin-bottom: 14px; }
.co-field label {
  display: block; font-size: 12px; color: #888; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.3px;
}
.co-value { font-size: 14px; color: #1a202c; font-weight: 500; }

.form-input {
  width: 100%; padding: 9px 12px; border: 1px solid #d0d5dd; border-radius: 8px;
  font-size: 14px; color: #1a202c; transition: border-color 0.2s;
}
.form-input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
