@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");

/* ============================================================
   Bảng màu / kiểu chữ / spacing / bo góc tham khảo theo design
   system "MẮT BÃO WS" — áp dụng token màu sắc, không lấy nội dung.
   ============================================================ */
:root {
  /* ---- Màu (token gốc) ---- */
  --primary: #e3262c;         /* --primary-color */
  --primary-dark: #b71c21;    /* dẫn xuất đậm hơn cho hover/gradient */
  --primary-darker: #8c1518;  /* dẫn xuất đậm nhất cho gradient sidebar */
  --primary-light: #ff4d52;

  --bg-tint: #e8f7ff;         /* color-10 */
  --surface-alt: #eaeaea;     /* color-8 */
  --surface-alt-2: #ededed;   /* color-9 */
  --ink: #333333;             /* color-1 */
  --ink-muted: #9da3a9;       /* color-5 */
  --ink-soft: #b7bcc1;

  --info: #1e5f8d;            /* color-2 */
  --info-soft: #e8f2f8;
  --violet: #5d87ff;          /* color-4 — dùng cho trạng thái "đang xử lý" thay cho vàng cam */
  --violet-soft: #eef1ff;
  --success: #81b441;         /* color-6 */
  --success-soft: #f0f6e8;
  --sky: #49beff;             /* color-7 */
  --sky-soft: #eaf8ff;
  --ink-light: #ffffff;       /* color-11 */

  --accent: #e3262c;          /* dùng chung nhóm đỏ cho hành động nguy hiểm/nộp báo cáo */
  --accent-dark: #b71c21;
  --accent-soft: #fde9ea;

  --status-green: var(--success);
  --status-green-soft: var(--success-soft);
  --status-amber: var(--violet);
  --status-amber-soft: var(--violet-soft);
  --status-gray: var(--ink-muted);
  --status-gray-soft: var(--surface-alt-2);

  --border: #e2e2e2;
  --border-strong: #d4d4d4;
  --surface: #ffffff;
  --bg: #f7f8fa;

  /* ---- Bo góc (chỉ dùng đúng 3 giá trị: 4 / 8 / 50) ---- */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 8px;
  --radius-pill: 50px;

  --sidebar-w: 272px;
  --sidebar-w-collapsed: 76px;

  --font-display: "Roboto", -apple-system, "Segoe UI", sans-serif;
  --font: "Roboto", -apple-system, "Segoe UI", sans-serif;

  /* ---- Đổ bóng (token gốc shadow-sm) ---- */
  --shadow-xs: rgba(17, 17, 26, 0.05) 0px 1px 0px 0px;
  --shadow-sm: rgba(17, 17, 26, 0.05) 0px 1px 0px 0px, rgba(17, 17, 26, 0.1) 0px 0px 8px 0px;
  --shadow-md: rgba(17, 17, 26, 0.06) 0px 2px 0px 0px, rgba(17, 17, 26, 0.14) 0px 0px 16px 0px;
  --shadow-lg: rgba(17, 17, 26, 0.08) 0px 4px 0px 0px, rgba(17, 17, 26, 0.18) 0px 4px 28px 0px;

  /* ---- Motion (token gốc) ---- */
  --ease: cubic-bezier(0.02, 0.01, 0.47, 1);
  --dur-fast: 0.2s;
  --dur-base: 0.3s;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px; /* text-sm */
  line-height: 22.4px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--primary); }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0; }

/* ---------- Layout shell ---------- */

.app-shell { display: flex; min-height: 100vh; }
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 25px; /* space-8 */
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--ink); }

.page-content {
  padding: 25px 35px 48px; /* space-8 / space-9 */
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Sidebar (spec 1.3) ---------- */

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-darker) 0%, var(--primary-dark) 55%, var(--primary) 100%);
  color: var(--ink-light);
  display: flex;
  flex-direction: column;
  transition: width 0.3s var(--ease);
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 15px;
  min-height: 72px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-light);
  overflow: hidden;
}
.sidebar-logo .logo-fallback {
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius);
}

.sidebar-logo img, .login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}
.sidebar-logo .logo-fallback, .login-logo .logo-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.sidebar-titles { overflow: hidden; white-space: nowrap; opacity: 1; transition: opacity 0.2s var(--ease); }
.sidebar.collapsed .sidebar-titles { opacity: 0; width: 0; }
.sidebar-titles .line1 { font-size: 13px; color: rgba(255, 255, 255, 0.75); }
.sidebar-titles .line2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-light);
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 15px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }

.sidebar-section-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
  padding: 12px 12px 5px;
}
.sidebar.collapsed .sidebar-section-label { display: none; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.sidebar-link:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.sidebar-link.active { background: rgba(255, 255, 255, 0.2); color: #fff; font-weight: 700; }
.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -12px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--ink-light);
}

.sidebar-icon { width: 20px; text-align: center; flex-shrink: 0; font-size: 15px; }
.sidebar.collapsed .sidebar-link-label { display: none; }

.sidebar-toggle {
  margin: 10px 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s var(--ease);
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, 0.18); }

.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- Cards ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 15px; }
.card-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 0 0 15px; color: var(--ink); display: flex; align-items: center; gap: 8px; }

/* ---------- Stat cards ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px; }
.stat-card .stat-label { font-size: 13px; font-weight: 500; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--ink); }
.stat-card.accent-green .stat-value { color: var(--success); }
.stat-card.accent-amber .stat-value { color: var(--violet); }
.stat-card.accent-primary .stat-value { color: var(--primary); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow-sm); color: #fff; }
.btn-primary:focus-visible { outline-color: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); box-shadow: var(--shadow-sm); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--ink); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt-2); border-color: var(--ink-soft); }
.btn-gray { background: var(--surface-alt-2); color: var(--ink); box-shadow: none; }
.btn-gray:hover:not(:disabled) { background: var(--surface-alt); }
.btn-sm { padding: 5px 13px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-muted); margin-bottom: 5px; }
.field input[type="text"], .field input[type="password"], .field input[type="number"],
.field input[type="date"], .field input[type="datetime-local"], .field select, .field textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field input:disabled { background: var(--surface-alt-2); color: var(--ink-muted); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--bg-tint);
  outline: none;
}

.password-field { position: relative; }
.password-field input { padding-right: 42px !important; }
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.password-toggle:hover { color: var(--primary); background: var(--surface-alt-2); }
.password-toggle svg { width: 19px; height: 19px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--primary); }
.field-hint { font-size: 13px; color: var(--ink-muted); margin-top: 4px; }
.field-warning { font-size: 13px; color: var(--violet); margin-top: 4px; }
.field-validation-error, .text-danger { color: var(--accent); font-size: 13px; margin-top: 4px; display: block; }
.input-validation-error { border-color: var(--accent) !important; }

.form-error, .alert {
  border-radius: var(--radius);
  padding: 12px 15px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 15px;
}
.form-error, .alert-error, .validation-summary-errors {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #f6c6c8;
}
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.alert-success {
  background: var(--success-soft);
  color: #5c7f2f;
  border: 1px solid #cfe3b3;
}

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 15px; }

/* ---------- Status badges (spec 1.2, tông màu MẮT BÃO WS) ---------- */

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 500; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-green { background: var(--status-green-soft); color: var(--status-green); }
.badge-amber { background: var(--status-amber-soft); color: var(--status-amber); }
.badge-gray { background: var(--status-gray-soft); color: var(--status-gray); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Tables ---------- */

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
table.data-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 720px; font-size: 13px; }
table.data-table th, table.data-table td { padding: 10px 13px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
table.data-table thead th {
  background: var(--bg-tint);
  color: var(--info);
  font-weight: 700;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border-strong);
}
table.data-table tbody tr { transition: background 0.2s var(--ease); }
table.data-table tbody tr:hover { background: var(--bg-tint); }
table.data-table td.text-left, table.data-table th.text-left { text-align: left; }

table.data-table th.freeze, table.data-table td.freeze {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 3;
  text-align: left;
  font-weight: 500;
  box-shadow: 2px 0 0 var(--border);
}
table.data-table thead th.freeze { background: var(--bg-tint); z-index: 4; }
table.data-table tbody tr:hover td.freeze { background: var(--bg-tint); }

tr.block-header td { background: var(--surface-alt-2) !important; font-weight: 700; text-align: left; color: var(--ink); }
tr.total-row td { background: #fdeceb !important; font-weight: 700; color: var(--ink); border-top: 2px solid var(--primary); }

/* ---------- Modal (spec 2.2 Popup xác nhận xóa) ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(51, 51, 51, 0.6);
  display: none;
  align-items: center; justify-content: center;
  z-index: 50;
  padding: 15px;
}
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius-lg); padding: 25px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.modal-icon {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; margin-bottom: 13px;
}
.modal-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 0 0 10px; }
.modal-body { font-size: 14px; color: var(--ink-muted); margin-bottom: 20px; line-height: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Login page ---------- */

.login-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 55%, var(--primary-darker) 100%);
  padding: 15px;
}
.login-card { width: 100%; max-width: 392px; background: #fff; border-radius: var(--radius-lg); padding: 35px 25px; box-shadow: var(--shadow-lg); }
.login-logo {
  width: 58px; height: 58px; border-radius: var(--radius-lg);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; margin: 0 auto 15px;
  overflow: hidden;
}
.login-logo .logo-fallback {
  background: var(--bg-tint);
  border: 1.5px solid var(--sky);
  border-radius: var(--radius-lg);
}
.login-title-1 { text-align: center; font-size: 13px; font-weight: 500; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.login-title-2 { text-align: center; font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--primary); margin: 5px 0 25px; }

/* ---------- Misc ---------- */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-muted); font-size: 14px; }

.progress-bar-track { background: var(--surface-alt-2); border-radius: var(--radius-pill); height: 10px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--success); border-radius: var(--radius-pill); transition: width 0.3s var(--ease); }

.section-heading { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--ink); margin: 0 0 5px; }
.section-sub { font-size: 14px; color: var(--ink-muted); margin: 0 0 20px; }

.action-group { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.sidebar-mobile-open-btn { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform 0.3s var(--ease); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-mobile-open-btn { display: inline-flex; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .page-content { padding: 15px; }
  .topbar { padding: 0 15px; }
}
