/* ============================
   Base
============================ */
* { box-sizing:border-box; }
html,body { margin:0; background:var(--bg); color:var(--text); font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial; }

/* Theme tokens */
:root{
  --bg:#f5f6f8;
  --card:#fff;
  --text:#111;
  --muted:#6b7280;
  --line:#e5e7eb;
  --brand:#111;
  --primary:#4f46e5;
  --primary-600:#4338ca;
  --success:#10b981;
  --warning:#f59e0b;
  --danger:#ef4444;
  --chip:#eef2ff;
}

/* Container (mặc định) */
.container{ max-width:1120px; margin:0 auto; padding:24px 16px; }

/* ============================
   Header
============================ */
.site-header{
  background:var(--brand);
  color:#fff;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.site-header a{ color:#fff; text-decoration:none; opacity:.95; }
.site-header a:hover{ opacity:1; }

/* padding riêng cho container trong header để tránh bị ảnh hưởng từ container mặc định */
.site-header .container{ padding:12px 16px; }

.brand{ font-weight:700; }

.header-wrap{
  display:flex;
  align-items:center;              /* cùng trục dọc */
  gap:12px;
  min-height:56px;
}
.header-left{
  display:flex;
  align-items:center;
  gap:18px;
  flex:1 1 auto;                   /* đẩy form sang phải */
}
.main-nav{
  display:flex;
  align-items:center;
  gap:16px;
}

/* Form tìm kiếm trên header */
.header-search{
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
}
.header-search input[type="text"],
.header-search select,
.header-search .button{
  height:36px;                     /* đồng bộ chiều cao */
  line-height:36px;
  border-radius:8px;
}
.header-search input[type="text"]{
  padding:0 12px;
  min-width:260px;
  border:1px solid var(--line);
  background:#fff;
}
.header-search select{
  padding:0 10px;
  border:1px solid var(--line);
  background:#fff;
}

/* Mobile */
@media (max-width: 768px){
  .header-wrap{ flex-wrap:wrap; }
  .header-search{ width:100%; order:2; }
  .header-search input[type="text"]{ flex:1; min-width:0; }
  .main-nav{ gap:12px; }
}

/* ============================
   Footer
============================ */
.site-footer{
  background:#111; color:#fff;
}
.site-footer .container{ padding:16px; }

/* ============================
   Card & Grid
============================ */
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:0 6px 18px rgba(0,0,0,.04);
  padding:16px;
}
.card img{ border-radius:12px; }

.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(280px, 1fr));
  gap:18px;
}

/* ============================
   Text helpers
============================ */
.meta{ color:var(--muted); font-size:13px; }
a{ color:#1d4ed8; text-decoration:none; }
a:hover{ text-decoration:underline; }

/* ============================
   Buttons
============================ */
.button,
button,
input[type=submit]{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height:36px;                    /* đồng bộ cao với header */
  padding:0 14px;
  border-radius:8px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  text-decoration:none;
  font-weight:600;
  font-size:14px;
  cursor:pointer;
  transition:.18s ease-in-out;
  box-shadow:0 1px 0 rgba(0,0,0,.02);
}
.button:hover,
button:hover,
input[type=submit]:hover{
  transform:translateY(-1px);
  box-shadow:0 6px 14px rgba(0,0,0,.06);
}

/* variants */
.button.primary{ background:var(--primary); color:#fff; border-color:transparent; }
.button.primary:hover{ background:var(--primary-600); }
.button.success{ background:var(--success); color:#fff; border-color:transparent; }
.button.warning{ background:var(--warning); color:#fff; border-color:transparent; }
.button.danger{ background:var(--danger); color:#fff; border-color:transparent; }

/* tag nhỏ trên card */
.card .button.tag{
  height:26px; padding:0 10px; border-radius:7px;
  background:#f2f4f7; color:#111; border-color:#e5e7eb; font-size:12px;
}

/* chips danh mục (trên index) */
.categories{ display:flex; gap:8px; flex-wrap:wrap; }
.categories .button{
  height:30px;
  padding:0 10px;
  border-radius:999px;
  background:var(--chip);
  border:1px solid #dbeafe;
  color:#1e3a8a;
  font-weight:600;
}
.categories .button:hover{ filter:brightness(0.98); }

/* ============================
   Forms
============================ */
label{ display:block; margin:12px 0 6px; font-weight:600; }
input[type=text],
input[type=password],
textarea,
select{
  width:100%;
  border:1px solid var(--line);
  background:#fff;
  padding:10px 12px;
  border-radius:10px;
  outline:none;
  font-size:14px;
  transition:border .15s ease;
}
input:focus,
textarea:focus,
select:focus{ border-color:#c7d2fe; box-shadow:0 0 0 3px rgba(99,102,241,.15); }
textarea{ min-height:160px; }
.checkbox{ display:flex; align-items:center; gap:8px; }

/* ============================
   Table (admin)
============================ */
.table{
  width:100%;
  border-collapse:separate; border-spacing:0;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
}
.table th,.table td{
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  font-size:14px;
}
.table th{ background:#fafafa; text-align:left; color:#374151; font-weight:700; }
.table tr:last-child td{ border-bottom:none; }

.badge{
  display:inline-flex; align-items:center; height:24px; padding:0 8px;
  border-radius:999px; font-size:12px; font-weight:700;
}
.badge.green{ background:#dcfce7; color:#065f46; }
.badge.gray{ background:#f3f4f6; color:#374151; }

/* ============================
   Pagination
============================ */
.pagination{ display:flex; gap:6px; flex-wrap:wrap; }
.pagination .button{
  height:32px; padding:0 10px;
}
.pagination span.button{
  background:#111; color:#fff; border-color:#111;
}
/* --- Fix: input ở header không bị co trong flex --- */
.header-search input[type="text"],
.header-search select{
  width:auto;                 /* bỏ width:100% của toàn cục trong header */
}

/* --- Mobile: cho input chiếm hết hàng, select + nút gọn bên phải --- */
@media (max-width: 768px){
  .header-search{
    width:100%;
    order:2;
    display:grid;                             /* đổi từ flex -> grid */
    grid-template-columns: 1fr auto auto;     /* input rộng, select + button vừa */
    gap:8px;
  }
  .header-search input[type="text"]{
    min-width:0; width:100%; height:40px;     /* làm ô cao hơn chút cho dễ bấm */
  }
  .header-search select,
  .header-search .button{ height:40px; }      /* đồng bộ chiều cao */
}
/* ====== Responsive video embeds ====== */
.video-embed{
  position: relative;
  width: 100%;
  /* có thể đặt --max trên inline style để đổi max-width theo từng video */
  max-width: var(--max,100%);   /* mặc định 800px như bạn mong muốn */
  margin: 16px 0;
}
.video-embed::before{
  content: "";
  display: block;
  /* tỉ lệ khung hình = height/width * 100%.
     600/800 = 75% => đúng 4:3; mặc định mình để 75%. */
  padding-top: var(--ratio, 60%);
}
.video-embed iframe{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
/* Ngăn iOS Safari tự zoom khi focus input/select (font-size >= 16px) */
html { -webkit-text-size-adjust: 100%; }

.header-search input[type="text"],
.header-search select {
  font-size: 16px;        /* QUAN TRỌNG: >= 16px để iOS không zoom */
  height: 44px;           /* tap target thân thiện ngón tay */
  line-height: 44px;
}

/* Nếu muốn chỉ áp dụng trên mobile */
@media (max-width: 768px){
  .header-search input[type="text"],
  .header-search select {
    font-size: 16px;
    height: 44px;
    line-height: 44px;
  }
}
/* Ảnh trong nội dung bài viết luôn co giãn theo khung */
.post .content img,
.post .content .img-fluid {
  max-width: 100%;
  height: auto;
  display: block;
}
