/* Màu và chữ theo nhận diện Gonta: xanh #0052B4 (lấy từ logo) là màu chính,
   đỏ #D50000 chỉ dùng làm điểm nhấn nhỏ (chấm mail chưa đọc). */
:root {
  --brand: #0052b4;
  --brand-deep: #163b83;
  --brand-hover: #00449a;
  --brand-tint: #e7eefa;
  --accent: #d50000;
  --text: #10264d;
  --text-muted: #5e6b80;
  --surface: #ffffff;
  --surface-soft: #f1f4f9;
  --border: #d5dfee;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --ok-text: #1b6b3a;
  --ok-soft: #e8f5ed;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(16, 38, 77, 0.06), 0 4px 16px rgba(16, 38, 77, 0.06);
  --focus: 0 0 0 3px rgba(0, 82, 180, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-soft);
  color: var(--text);
  font: 15px/1.5 Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; font-weight: 700; margin: 0 0 16px; }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 12px; }

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Thanh trên cùng ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { height: 26px; width: auto; display: block; }
.brand span {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  font-weight: 500;
  font-size: 15px;
  color: var(--text-muted);
}
.topbar nav { display: flex; gap: 20px; align-items: center; margin-left: auto; font-size: 14px; font-weight: 500; }
.topbar nav form { margin: 0; }
.topbar .me {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}

main { max-width: 980px; margin: 0 auto; padding: 28px 16px 56px; }
main.wide { max-width: 1200px; }
.narrow { max-width: 480px; }

/* ---------- Form ---------- */

input, select, textarea, button { font: inherit; color: inherit; }

input[type=email], input[type=password], input[type=text], input[type=search], input:not([type]), select, textarea {
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input::placeholder { color: #8a96a8; }

label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); }
label input, label textarea { margin-top: 6px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-weight: 400; font-size: 14px; }
label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }

button {
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { background: var(--brand-tint); border-color: var(--brand-tint); }
/* Nút chính: gradient xanh đậm sang xanh thương hiệu */
button.primary {
  border: 0;
  background: linear-gradient(90deg, var(--brand-deep), var(--brand));
  color: #fff;
  font-weight: 700;
}
button.primary:hover { background: linear-gradient(90deg, #102d66, var(--brand-hover)); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button.link { height: auto; border: 0; background: none; padding: 0; color: var(--brand); font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }

.stack { display: grid; gap: 16px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: end; }
.grid .span2 { grid-column: span 2; }

.notice { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok-text); }

/* ---------- Đăng nhập ---------- */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 56px;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #fff;
}
/* Đường cong gợi quỹ đạo bóng golf */
.login-hero::before,
.login-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
}
.login-hero::before { width: 640px; height: 640px; right: -260px; top: -220px; }
.login-hero::after { width: 420px; height: 420px; right: -120px; top: -90px; border-color: rgba(255, 255, 255, 0.1); }
.login-hero h2 { font-size: 34px; line-height: 1.2; margin: 0 0 12px; font-weight: 700; }
.login-hero p { margin: 0; max-width: 380px; font-size: 16px; color: rgba(255, 255, 255, 0.85); }

.login-side { display: grid; place-items: center; max-width: none; margin: 0; padding: 32px 16px; background: var(--surface); }
.login { width: 100%; max-width: 360px; }
.login img { height: 40px; width: auto; display: block; margin-bottom: 32px; }
.login h1 { font-size: 24px; margin-bottom: 4px; }
.login > p { margin: 0 0 28px; }
.login button.primary { width: 100%; height: 44px; margin-top: 4px; }

/* ---------- Hộp thư ---------- */

.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar h1 { margin: 0; display: flex; align-items: center; gap: 10px; }
.search { display: flex; gap: 8px; margin-left: auto; flex: 1; max-width: 560px; }
.search select { width: auto; max-width: 210px; }
.search input { flex: 1; min-width: 0; }

.badge {
  font-size: 12px;
  font-weight: 500;
  background: var(--brand-tint);
  color: var(--brand);
  padding: 3px 10px;
  border-radius: 999px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.list li + li { border-top: 1px solid var(--border); }
.list a {
  display: grid;
  grid-template-columns: 210px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  color: var(--text-muted);
  transition: background 0.15s;
}
.list a:hover { background: var(--brand-tint); text-decoration: none; }
.list .from { display: flex; align-items: center; gap: 8px; }
.list .from, .list .subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .subject { color: var(--text); }
.list .snippet { color: var(--text-muted); }
.list .meta { font-size: 13px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.list .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.list li.unread .dot { background: var(--accent); }
.list li.unread .from, .list li.unread .subject { color: var(--text); font-weight: 700; }
.list li.unread .meta { color: var(--brand); font-weight: 500; }

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.pager { display: flex; justify-content: space-between; margin: 18px 0; font-weight: 500; }

/* ---------- Xem mail ---------- */

.back { display: inline-block; margin-bottom: 16px; font-weight: 500; }

.message {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}
.message h1 { font-size: 21px; }
.headers {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 6px 12px;
  margin: 0 0 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.headers dt { color: var(--text-muted); }
.headers dd { margin: 0; word-break: break-word; }

.attachments {
  list-style: none;
  padding: 12px 14px;
  margin: 0 0 18px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 14px;
}

iframe.body {
  width: 100%;
  height: 70vh;
  border: 0;
  background: #fff;
}

/* ---------- Quản trị ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 20px;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-weight: 500; font-size: 13px; background: var(--surface-soft); }
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }
.tag { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); }
.tag.off { background: var(--danger-soft); color: var(--danger); }

.danger-zone { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); display: grid; gap: 12px; justify-items: start; }

/* ---------- Màn hình nhỏ ---------- */

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 180px; padding: 28px 24px; }
  .login-hero h2 { font-size: 24px; }
  .login-hero p { font-size: 14px; }
  .login-side { align-items: start; padding-top: 40px; }
}

@media (max-width: 720px) {
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; gap: 10px 16px; }
  .brand img { height: 22px; }
  .topbar nav { gap: 16px; }
  .topbar .me { width: 100%; order: 3; }
  .search { max-width: none; flex-basis: 100%; flex-wrap: wrap; }
  .search select { flex-basis: 100%; max-width: none; }
  .list a { grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; }
  .list .from { grid-column: 1; }
  .list .meta { grid-column: 2; grid-row: 1; }
  .list .subject { grid-column: 1 / -1; padding-left: 16px; }
  .grid { grid-template-columns: 1fr; }
  .grid .span2 { grid-column: auto; }
  .message { padding: 16px; }
  iframe.body { height: 75vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
