/* ═══════════════════════════════════════════
   Brand colors — match logo #0099CC
═══════════════════════════════════════════ */
:root {
  --brand:        #0099CC;
  --brand-dark:   #007AA3;
  --brand-light:  #33b5e5;
  --brand-pale:   #e6f6fb;

  --md-primary-fg-color:        var(--brand);
  --md-primary-fg-color--light: var(--brand-light);
  --md-primary-fg-color--dark:  var(--brand-dark);
  --md-accent-fg-color:         var(--brand);
}

/* ═══════════════════════════════════════════
   Header — nền trắng, logo nổi bật
═══════════════════════════════════════════ */
.md-header {
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0,153,204,0.10);
  border-bottom: 1px solid #e8f4f9;
}
.md-header__title { color: #1a2a3a !important; font-weight: 700; letter-spacing: -.3px; }
.md-header__button { color: #1a2a3a !important; }
.md-header__button.md-logo img {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: contain;
  transition: transform .3s ease;
}
.md-header__button.md-logo:hover img { transform: rotate(10deg) scale(1.08); }

/* ═══════════════════════════════════════════
   Tabs — xanh đậm brand
═══════════════════════════════════════════ */
.md-tabs { background: var(--brand-dark); }
.md-tabs__link { color: rgba(255,255,255,.78) !important; font-weight: 500; letter-spacing: .3px; transition: color .2s; }
.md-tabs__link--active, .md-tabs__link:hover { color: #fff !important; }
.md-tabs__indicator { background: #fff; height: 3px; border-radius: 2px; }

/* ═══════════════════════════════════════════
   Sidebar
═══════════════════════════════════════════ */
.md-nav__title { color: var(--brand-dark); font-weight: 700; font-size: .72rem; letter-spacing: .8px; text-transform: uppercase; }
.md-nav__link--active { color: var(--brand) !important; font-weight: 600; border-left: 3px solid var(--brand); padding-left: 8px; }
.md-nav__link:hover { color: var(--brand-dark) !important; }

/* ═══════════════════════════════════════════
   Content area — typography
═══════════════════════════════════════════ */
.md-content__inner { padding-top: 2rem; }
.md-typeset h1 {
  font-size: 2rem; font-weight: 800; letter-spacing: -.5px;
  color: #1a2a3a;
  border-bottom: 3px solid var(--brand);
  padding-bottom: .4rem;
  animation: fadeSlideDown .5s ease both;
}
.md-typeset h2 {
  font-size: 1.3rem; font-weight: 700; color: #1a2a3a;
  margin-top: 2.4rem;
  animation: fadeSlideDown .5s ease .1s both;
}
.md-typeset h3 { font-size: 1.05rem; font-weight: 600; color: var(--brand-dark); }

/* ═══════════════════════════════════════════
   Tables — full border, card style
═══════════════════════════════════════════ */
.md-typeset table:not([class]) {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 3px 16px rgba(0,153,204,0.13);
  font-size: .875rem;
  margin: 1rem 0 1.8rem;
  border: 1px solid #cde8f5;
}
.md-typeset table:not([class]) thead tr { background: var(--brand-dark); }
.md-typeset table:not([class]) th {
  background: var(--brand-dark) !important;
  color: #fff !important;
  font-weight: 600;
  padding: .7rem 1.1rem;
  text-align: left;
  border-right: 1px solid rgba(255,255,255,.15);
  white-space: nowrap;
}
.md-typeset table:not([class]) th:last-child { border-right: none; }
.md-typeset table:not([class]) td {
  padding: .6rem 1.1rem;
  border-bottom: 1px solid #daeef7;
  border-right: 1px solid #e8f4f9;
  vertical-align: top;
  line-height: 1.55;
}
.md-typeset table:not([class]) td:last-child { border-right: none; }
.md-typeset table:not([class]) tr:last-child td { border-bottom: none; }
.md-typeset table:not([class]) tbody tr:nth-child(even) td { background: #f5fbfe; }
.md-typeset table:not([class]) tbody tr:hover td {
  background: #ddf0fa !important;
  transition: background .15s;
}
/* Badge kiểu dữ liệu trong bảng */
.md-typeset table:not([class]) td:nth-child(2) { font-family: var(--md-code-font); font-size: .82rem; color: #0077aa; }

/* ═══════════════════════════════════════════
   DB group card — bao quanh mỗi nhóm bảng
═══════════════════════════════════════════ */
.db-group {
  border: 1px solid #cde8f5;
  border-radius: 14px;
  padding: 1.4rem 1.6rem 1rem;
  margin-bottom: 2rem;
  background: #fafdff;
  box-shadow: 0 2px 12px rgba(0,153,204,.07);
}
.db-group-title {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--brand-dark);
  background: var(--brand-pale);
  display: inline-block;
  padding: .25rem .75rem;
  border-radius: 20px;
  margin-bottom: 1rem;
}
.db-table-name {
  font-size: 1rem; font-weight: 700;
  color: #1a2a3a;
  margin: 1.2rem 0 .3rem;
  display: flex; align-items: center; gap: .5rem;
}
.db-table-name::before { content: ''; display: inline-block; width: 10px; height: 10px; background: var(--brand); border-radius: 2px; }
.db-desc { font-size: .85rem; color: #6b7e8c; margin: 0 0 .6rem; }

/* ═══════════════════════════════════════════
   Code blocks
═══════════════════════════════════════════ */
.md-typeset pre {
  border-radius: 10px;
  border-left: 4px solid var(--brand);
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.md-typeset code { border-radius: 4px; font-size: .85em; }

/* ═══════════════════════════════════════════
   Admonitions
═══════════════════════════════════════════ */
.md-typeset .admonition {
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
}

/* ═══════════════════════════════════════════
   ── HOME PAGE HERO ──
═══════════════════════════════════════════ */
.hero {
  text-align: center;
  padding: 3.5rem 2rem 2.5rem;
  background: linear-gradient(135deg, #f0faff 0%, #e6f6fb 50%, #f8fdff 100%);
  border-radius: 16px;
  margin-bottom: 2.5rem;
  position: relative;
  overflow: hidden;
  animation: fadeSlideDown .6s ease both;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 30%, rgba(0,153,204,.12) 0%, transparent 60%),
              radial-gradient(circle at 20% 80%, rgba(0,122,163,.08) 0%, transparent 50%);
}
.hero-logo {
  width: 90px; height: 90px;
  border-radius: 50%;
  box-shadow: 0 6px 30px rgba(0,153,204,.3);
  margin-bottom: 1.2rem;
  animation: popIn .6s cubic-bezier(.34,1.56,.64,1) .1s both;
  transition: transform .3s ease, box-shadow .3s ease;
}
.hero-logo:hover { transform: scale(1.07) rotate(5deg); box-shadow: 0 12px 40px rgba(0,153,204,.4); }
.hero h1 {
  font-size: 2.2rem !important; font-weight: 800;
  color: #1a2a3a !important;
  border: none !important;
  margin: 0 0 .5rem !important;
  padding: 0 !important;
  animation: fadeSlideDown .5s ease .2s both;
}
.hero p {
  color: #5a6e7e;
  font-size: 1.05rem;
  margin: 0 auto 1.5rem;
  max-width: 500px;
  animation: fadeSlideDown .5s ease .3s both;
}
.hero-badge {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-size: .75rem; font-weight: 600;
  padding: .25rem .75rem;
  border-radius: 20px;
  letter-spacing: .5px;
  animation: fadeIn .5s ease .4s both;
}

/* ═══════════════════════════════════════════
   Project cards
═══════════════════════════════════════════ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.project-card {
  background: #fff;
  border: 1px solid #e0eff6;
  border-radius: 14px;
  padding: 1.8rem 1.6rem;
  text-decoration: none !important;
  color: inherit !important;
  display: block;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  box-shadow: 0 2px 10px rgba(0,153,204,.07);
  animation: fadeSlideUp .5s ease both;
  position: relative;
  overflow: hidden;
}
.project-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  border-radius: 14px 14px 0 0;
}
.project-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(0,153,204,.18);
  border-color: var(--brand-light);
}
.project-card:nth-child(2) { animation-delay: .1s; }
.project-card:nth-child(3) { animation-delay: .2s; }
.card-icon { font-size: 2.2rem; margin-bottom: .8rem; display: block; }
.card-title {
  font-size: 1.15rem; font-weight: 700;
  color: #1a2a3a;
  margin-bottom: .5rem;
}
.card-desc { font-size: .88rem; color: #6b7e8c; line-height: 1.6; margin-bottom: 1rem; }
.card-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.card-tag {
  font-size: .72rem; font-weight: 600;
  background: var(--brand-pale);
  color: var(--brand-dark);
  padding: .2rem .6rem;
  border-radius: 10px;
}
.card-link {
  display: inline-flex; align-items: center; gap: .3rem;
  margin-top: 1rem;
  font-size: .82rem; font-weight: 600;
  color: var(--brand) !important;
  transition: gap .2s;
}
.card-link:hover { gap: .6rem; }

/* ═══════════════════════════════════════════
   Feature / stat boxes
═══════════════════════════════════════════ */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2.5rem;
}
.feature-box {
  background: var(--brand-pale);
  border-radius: 12px;
  padding: 1.2rem 1rem;
  text-align: center;
  animation: fadeSlideUp .4s ease both;
  transition: transform .2s, background .2s;
}
.feature-box:hover { transform: translateY(-3px); background: #d0eef8; }
.feature-box:nth-child(2) { animation-delay: .05s; }
.feature-box:nth-child(3) { animation-delay: .10s; }
.feature-box:nth-child(4) { animation-delay: .15s; }
.feature-icon { font-size: 1.8rem; display: block; margin-bottom: .4rem; }
.feature-label { font-size: .82rem; font-weight: 600; color: var(--brand-dark); }

/* ═══════════════════════════════════════════
   DB HTML tables — cột đều, hover tooltip
═══════════════════════════════════════════ */
.db-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 10px;
  /* KHÔNG dùng overflow:hidden — nó sẽ cắt cụt tooltip của .db-field.
     Bo góc bằng cách bo trực tiếp các ô ở 4 góc (xem rule bên dưới). */
  border: 1px solid #cde8f5;
  box-shadow: 0 3px 14px rgba(0,153,204,.11);
  margin: .6rem 0 1.6rem;
  font-size: .875rem;
  table-layout: fixed;
}
/* Bo 4 góc bằng ô góc, thay cho overflow:hidden (để tooltip không bị clip) */
.db-table thead tr:first-child th:first-child { border-top-left-radius: 10px; }
.db-table thead tr:first-child th:last-child  { border-top-right-radius: 10px; }
.db-table tbody tr:last-child td:first-child   { border-bottom-left-radius: 10px; }
.db-table tbody tr:last-child td:last-child    { border-bottom-right-radius: 10px; }
.db-table thead tr { background: var(--brand-dark); }
.db-table th {
  color: #fff;
  font-weight: 600;
  padding: .65rem 1rem;
  text-align: left;
  border-right: 1px solid rgba(255,255,255,.15);
}
.db-table th:last-child { border-right: none; }
.db-table th:nth-child(1) { width: 28%; }
.db-table th:nth-child(2) { width: 22%; }
.db-table th:nth-child(3) { width: 50%; }
/* 2-col variant */
.db-table.db-col2 th:nth-child(1) { width: 30%; }
.db-table.db-col2 th:nth-child(2) { width: 70%; }

.db-table td {
  padding: .55rem 1rem;
  border-bottom: 1px solid #daeef7;
  border-right: 1px solid #e8f4f9;
  vertical-align: middle;
  /* KHÔNG overflow:hidden ở đây — sẽ cắt cụt tooltip của .db-field.
     Chữ dài tự xuống dòng (word-wrap) thay vì cắt ellipsis. */
  word-break: break-word;
}
.db-table td:last-child { border-right: none; }
.db-table tbody tr:last-child td { border-bottom: none; }
.db-table tbody tr:nth-child(even) td { background: #f5fbfe; }
.db-table tbody tr:hover td { background: #d8eef8 !important; transition: background .15s; }
/* Nâng hàng đang hover lên lớp positioned để tooltip .db-field vẽ ĐÈ LÊN các
   hàng phía dưới (table cells vẽ theo thứ tự DOM nên hàng sau che positioned của
   hàng trước nếu không nâng z-index ở cấp hàng). */
.db-table tbody tr:hover { position: relative; z-index: 5; }

/* field name — monospace + tooltip trigger */
.db-field {
  font-family: var(--md-code-font);
  font-size: .82rem;
  color: #005f8a;
  font-weight: 600;
  position: relative;
  cursor: default;
  display: inline-block;
  white-space: nowrap;
}
.db-field::after {
  content: attr(data-tip);
  position: absolute;
  left: 0; top: calc(100% + 6px);
  background: #1a2a3a;
  color: #fff;
  font-family: var(--md-text-font);
  font-size: .78rem;
  font-weight: 400;
  white-space: nowrap;
  padding: .3rem .7rem;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.db-field::before {
  content: '';
  position: absolute;
  left: 10px; top: calc(100% + 1px);
  border: 5px solid transparent;
  border-bottom-color: #1a2a3a;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease;
  z-index: 101;
}
.db-field:hover::after,
.db-field:hover::before { opacity: 1; transform: translateY(0); }

/* type badges */
.db-type {
  display: inline-block;
  font-family: var(--md-code-font);
  font-size: .75rem;
  padding: .15rem .55rem;
  border-radius: 5px;
  font-weight: 600;
  white-space: nowrap;
}
.db-type.pk  { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.db-type.fk  { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.db-type.str { background: #e2eeff; color: #1a4a8a; border: 1px solid #b8d0f0; }
.db-type.int { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.db-type.bool{ background: #fce4ec; color: #880e4f; border: 1px solid #f48fb1; }
.db-type.date{ background: #f3e5f5; color: #4a148c; border: 1px solid #ce93d8; }
.db-type.text{ background: #fff8e1; color: #e65100; border: 1px solid #ffcc02; }
.db-type.enum{ background: #ede7f6; color: #311b92; border: 1px solid #b39ddb; }
.db-type.dec { background: #e0f7fa; color: #006064; border: 1px solid #80deea; }

/* ═══════════════════════════════════════════
   DB overview bar
═══════════════════════════════════════════ */
.db-overview {
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  color: #fff;
  border-radius: 10px;
  padding: .7rem 1.2rem;
  font-size: .9rem;
  margin-bottom: 1.5rem;
}

/* ═══════════════════════════════════════════
   Scroll-reveal — applied via JS
═══════════════════════════════════════════ */
/* Dùng [data-reveal] thay cho class .reveal — xem ghi chú trong extra.js:
   thêm class vào <table> sẽ phá selector .md-typeset table:not([class]). */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .5s ease, transform .5s ease;
}
[data-reveal="in"] { opacity: 1; transform: translateY(0); }

/* ═══════════════════════════════════════════
   Keyframes
═══════════════════════════════════════════ */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════════════
   Dark mode
═══════════════════════════════════════════ */
[data-md-color-scheme="slate"] {
  --brand-pale: rgba(0,153,204,.12);
}
[data-md-color-scheme="slate"] .md-header {
  background: #1a1f2e;
  border-bottom-color: #2a3a4a;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
[data-md-color-scheme="slate"] .md-header__title,
[data-md-color-scheme="slate"] .md-header__button { color: #e8f4f9 !important; }
[data-md-color-scheme="slate"] .md-tabs { background: #141825; }
[data-md-color-scheme="slate"] .hero {
  background: linear-gradient(135deg, #1a2535 0%, #1e2d3d 50%, #182030 100%);
}
[data-md-color-scheme="slate"] .hero h1 { color: #e8f4f9 !important; }
[data-md-color-scheme="slate"] .hero p { color: #8baabb; }
[data-md-color-scheme="slate"] .project-card {
  background: #1e2a38;
  border-color: #2a3a4a;
}
[data-md-color-scheme="slate"] .card-title { color: #e8f4f9; }
[data-md-color-scheme="slate"] .card-desc { color: #8baabb; }
[data-md-color-scheme="slate"] .feature-box { background: rgba(0,153,204,.1); }
[data-md-color-scheme="slate"] .md-typeset h1,
[data-md-color-scheme="slate"] .md-typeset h2 { color: #e8f4f9; }
[data-md-color-scheme="slate"] .md-typeset table:not([class]) { border-color: #2a3a4a; }
[data-md-color-scheme="slate"] .md-typeset table:not([class]) td { border-bottom-color: #2a3a4a; border-right-color: #2a3a4a; }
[data-md-color-scheme="slate"] .md-typeset table:not([class]) tbody tr:nth-child(even) td { background: rgba(255,255,255,.03); }
[data-md-color-scheme="slate"] .md-typeset table:not([class]) tbody tr:hover td { background: rgba(0,153,204,.1) !important; }
[data-md-color-scheme="slate"] .db-group { background: #1a2535; border-color: #2a3a4a; }
[data-md-color-scheme="slate"] .db-table-name { color: #e8f4f9; }
[data-md-color-scheme="slate"] .db-desc { color: #7a9aab; }
[data-md-color-scheme="slate"] .db-overview { opacity: .9; }
