/* ===== APP LAYOUT (Gutenberg + Spectra) - Optimized ===== */

/* ================== 1) RESET & GLOBAL ================== */
html, body { height:100%; min-height:100%; margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f8f9fa;
    color: #333;
}

/* Swup fade */
html.is-animating .transition-fade { opacity: 0; transition: opacity 0.35s ease; }
.transition-fade { opacity: 1; transition: opacity 0.35s ease; }

/* ================== 2) TOP BAR ================== */
/* scope bằng .app-layout để không ảnh hưởng trang khác */
.app-layout .top-bar,
.app-layout .app-top-bar {
    position: fixed;      /* cố định để không bị block full-width đè */
    top: 0;
    left: 0;
    right: 0;
    height: 64px;         /* nếu muốn nhỏ hơn: 56px, nhớ chỉnh padding-top */
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 0 12px;
    z-index: 10000;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.app-layout .top-bar .logo { font-weight: bold; color: #0073aa; text-decoration: none; font-size: 16px; }
.app-layout .top-bar .logo img { height: 32px; display: block; }
.app-layout .search-form { flex: 1; margin: 0 12px; }
.app-layout .search-form .search-field {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}
.app-layout .top-right a { font-size: 18px; text-decoration: none; }

/* Ruột top bar nằm ngang */
.app-layout .app-top-bar .top-bar-inner {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  width:100%;
}
/* Ba cột trái – giữa – phải */
.app-layout .app-top-bar .top-left,
.app-layout .app-top-bar .top-center,
.app-layout .app-top-bar .top-right{
  display:flex;
  align-items:center;
}
/* Ô giữa co giãn + canh giữa */
.app-layout .app-top-bar .top-center{
  flex:1;
  justify-content:center;
}
/* Ô tìm kiếm gọn gàng */
.app-layout .app-top-bar .search-form{
  width:100%;
  max-width:280px;
  margin:0 12px;
}

/* ================== 3) CONTENT (APP-CONTENT) ================== */
/* chú ý: padding-top phải >= top-bar height + 8px để không bị che */
.app-layout #app-content {
    padding: 18px;
    padding-top: 72px;    /* bù cho top-bar (64px) + 8px khoảng cách */
    padding-bottom: 84px; /* bù cho bottom bar */
    min-height: calc(100vh - 148px);
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Nội dung card */
.app-layout .app-inner {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    max-width: 100%;
}

/* ================== 4) BOTTOM BAR ================== */
.app-layout .bottom-bar,
.app-layout .app-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #fff;
    border-top: 1px solid #eee;
    padding: 6px 0;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.05);
    z-index: 9999;
}

/* Anchor item */
/* === BOTTOM BAR - ICON TOP, LABEL BOTTOM (wrap allowed) === */
.app-layout .app-bottom-bar a,
.app-layout .bottom-bar a {
    flex: 1;
    display: flex;               /* make icon + label flex children */
    flex-direction: column;      /* icon trên, chữ dưới */
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #555;
    font-size: 12px;             /* base label size */
    padding: 6px 0;              /* hơi lớn hơn để tránh bị cắt */
    gap: 6px;                    /* khoảng cách icon -> label */
    transition: color 0.3s, transform 0.2s;
    white-space: normal;         /* cho phép xuống dòng */
    overflow: visible;
}

/* icon sizing (Font Awesome <i>) và legacy <div> emoji fallback */
.app-layout .app-bottom-bar a i,
.app-layout .bottom-bar a i,
.app-layout .app-bottom-bar a div,
.app-layout .bottom-bar a div {
    font-size: 20px;
    line-height: 1;
    display: block;
}

/* label (nếu anh bọc label trong <span class="label">) */
.app-layout .app-bottom-bar a .label,
.app-layout .bottom-bar a .label {
    display: block;
    font-size: 12px;
    line-height: 1.2;
    max-width: 100%;
    word-break: break-word;      /* bẻ chữ dài */
    hyphens: auto;
    text-align: center;
}


.app-layout .app-bottom-bar a.active,
.app-layout .bottom-bar a.active {
    color: #0073aa;
    transform: scale(1.1);
    font-weight:600;
}
.app-layout .app-bottom-bar a:hover,
.app-layout .bottom-bar a:hover {
    color: #0073aa;
    transform: scale(1.1);
}

/* === Nút giữa nổi bật === */
.app-layout .app-bottom-bar a.center {
  position: relative;
  top: -20px; /* nhô lên */
}

.app-layout .app-bottom-bar a.center .circle-btn {
  width: 56px;
  height: 56px;
  background: #0073aa;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 24px;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ================== 5) COMPONENTS & FIXES ================== */
/* đặt trong assets/css/app-layout.css của child theme */
.search-item { 
  display:flex; 
  gap:12px; 
  align-items:flex-start; 
  margin-bottom:20px; 
}
.search-thumb img { 
  display:block; 
  border-radius:8px; 
  width:120px; 
  height:auto; 
  object-fit:cover; 
}
.search-content { 
  flex:1; 
}
.search-title { 
  margin:0 0 6px 0; 
  font-size:18px; 
  line-height:1.3; 
}
.search-excerpt { 
  color:#555; 
}

/* ================== Fix full-bleed issues (Gutenberg + Spectra) ================== */
/* Giữ các block alignfull / cover / spectra section nằm trong container app */
.app-layout .wp-block-cover,
.app-layout .wp-block-cover.alignfull,
.app-layout .wp-block-group.alignfull,
.app-layout .wp-block-image img,
.app-layout .wp-block-media-text,
.app-layout .wp-block-gallery,
.app-layout .alignfull,
.app-layout .alignwide,
.app-layout .uagb-section__wrap {
  max-width:100% !important;
  width:100% !important;
  box-sizing:border-box;
  overflow:hidden;
  margin-left: 0 !important;
  margin-right: 0 !important;
  transform: none !important;
  left: auto !important;
}

/* Nếu Spectra (UAGB) chèn wrapper stretch, hạn chế overflow */
.app-layout .uagb-section__inner-wrap,
.app-layout .uagb-section__wrap {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Đảm bảo nội dung luôn nằm trên các shape/background */
.app-layout #app-content > * { position: relative; z-index: 2; }

/* Nếu plugin chèn phần tử fixed quá to, giới hạn tạm */
.app-layout [style*="position:fixed"] {
  max-width:100vw;
  max-height:100vh;
  box-sizing:border-box;
}

/* ================== 6) RESPONSIVE ================== */

/* small screens tweak */
@media (max-width:640px){
  .app-layout .app-top-bar, .app-layout .app-bottom-bar,
  .app-layout .top-bar, .app-layout .bottom-bar{ height:56px; }
  .app-layout #app-content{ padding-top:64px; padding-bottom:70px; }
}

/* Mobile & small tablet tweaks */
@media (max-width: 768px) {
    .app-layout .search-form .search-field { font-size: 13px; padding: 5px 8px; }
    .app-layout .top-right a { font-size: 20px; }
    .app-layout .app-top-bar, .app-layout .top-bar { height:56px; }
}

/* Larger tablet */
@media (min-width: 768px) {
    .app-layout #app-content { padding: 24px 24px 96px; }
    .app-layout .app-bottom-bar a,
    .app-layout .bottom-bar a { font-size: 13px; }
   .app-layout .app-bottom-bar a i,
.app-layout .bottom-bar a i,
.app-layout .app-bottom-bar a div,
.app-layout .bottom-bar a div { font-size: 22px; }

.app-layout .app-bottom-bar a .label,
.app-layout .bottom-bar a .label { font-size: 13px; }

    /* Đồng bộ cho <i> Font Awesome */
    .app-layout .app-bottom-bar a i,
    .app-layout .bottom-bar a i { font-size: 22px; }

    /* Mở rộng khung search trên màn hình lớn */
    .app-layout .app-top-bar .search-form { max-width: 480px; }
}

/* Desktop */
@media (min-width: 1024px) {
    .app-layout #app-content {
        padding: 70px 32px 120px; /* thêm 70px phía trên để tránh bị top bar che */
    }

    .app-layout .app-bottom-bar a,
    .app-layout .bottom-bar a {
        font-size: 14px;
    }

    .app-layout .app-bottom-bar a i,
.app-layout .bottom-bar a i,
.app-layout .app-bottom-bar a div,
.app-layout .bottom-bar a div { font-size: 24px; }

.app-layout .app-bottom-bar a .label,
.app-layout .bottom-bar a .label { font-size: 14px; }

    /* Đồng bộ cho <i> Font Awesome */
    .app-layout .app-bottom-bar a i,
    .app-layout .bottom-bar a i {
        font-size: 24px;
    }
}

/* Wide desktop */
@media (min-width: 1200px) {
  .app-layout .app-top-bar .search-form {
    max-width: 640px;
  }
}

/* Full width cho mobile */
@media (max-width: 767px) {
  .app-layout #app-content {
    max-width: 100% !important;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}
