/* ================================
   Baro News Magazine – Fluid Responsive
   ================================ */

/* Design tokens */
:root{
    --baro-gap: clamp(14px, 1.8vw, 25px);
    --baro-radius-lg: 12px;
    --baro-radius-md: 10px;
    --baro-shadow-1: 0 4px 20px rgba(0,0,0,0.08);
    --baro-shadow-2: 0 8px 30px rgba(0,0,0,0.12);
    --baro-shadow-sm: 0 2px 15px rgba(0,0,0,0.06);
    --baro-border: 1px solid rgba(0,0,0,0.05);
    --baro-primary: #3498db;
    --baro-overlay: linear-gradient(180deg, rgba(19,50,86,0) 35.67%, #38a749 100%);
    --baro-text: #2c3e50;
    --baro-muted: #666;
  }
  
  /* Root layout - 3 cột với feature chiếm 2x2 */
  .baro-news-magazine{
    display:grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: var(--baro-gap);
    margin: clamp(12px,2.2vw,20px) 0;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  }
  
  /* Empty state */
  .baro-empty{
    text-align:center;
    padding: clamp(24px,4vw,40px) clamp(16px,3vw,20px);
    background: linear-gradient(135deg,#f5f7fa 0%,#c3cfe2 100%);
    color:#666;
  }
  
  /* Cards */
  .baro-featured,
  .baro-side-item,
  .baro-grid-item{
    position:relative;
    overflow:hidden;
    transition: transform .3s ease, box-shadow .3s ease;
    will-change: transform;
  }
  
  .baro-featured{
    grid-column: 1 / 3;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  
  .baro-featured > a{
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
  }
  
  .baro-featured:hover{ transform: translateY(-2px); box-shadow: var(--baro-shadow-2); }
  .baro-side-item:hover,
  .baro-grid-item:hover{ transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
  
  /* Images (stable ratios) */
  .baro-featured .baro-post-image,
  .baro-side-item .baro-post-image,
  .baro-grid-item .baro-post-image{
    position:relative;
    overflow:hidden;
  }
  
  /* Featured: fill full height, remove aspect-ratio constraint */
  .baro-featured .baro-post-image{
    flex: 1;
    min-height: 0;
    width: 100%;
  }


  
  .baro-side-item .baro-post-image{ aspect-ratio: 16/9; }
  .baro-grid-item .baro-post-image{ aspect-ratio: 16/10; }
  
  .baro-featured .baro-post-image img,
  .baro-side-item .baro-post-image img,
  .baro-grid-item .baro-post-image img{
    width:100%;
    height:100%;
    object-fit:cover;
    transform: translateZ(0);
    transition: transform .3s ease;
  }
  .baro-featured:hover .baro-post-image img,
  .baro-side-item:hover .baro-post-image img,
  .baro-grid-item:hover .baro-post-image img{ transform: scale(1.05); }
  
  /* Overlays */
  .baro-featured .baro-post-image::before{
    content:""; position:absolute; inset:0; background: var(--baro-overlay); z-index:1;
  }
  .baro-side-item .baro-post-image::before{
    content:""; position:absolute; inset:0; background: rgba(0,0,0,.25); z-index:1;
  }
  
  /* Content areas */
  .baro-featured .baro-post-content{
    position:absolute; inset-inline:0; bottom:0; z-index:2;
    padding: clamp(14px,2.8vw,20px);
    color:#fff;
    flex-shrink: 0;
  }
  .baro-side-item .baro-post-content{
    position:absolute; inset-inline:0; bottom:0; z-index:2;
    padding: clamp(12px,2.2vw,16px);
    background: var(--baro-overlay);
    color:#fff;
  }
  .baro-grid-item .baro-post-content{ padding: clamp(12px,2.2vw,16px); }
  
  /* Headings with fluid size */
  .baro-featured h2{
    margin: 0 0 clamp(8px,1vw,12px) 0;
    font-size: clamp(18px, 2.2vw, 24px);
    font-weight:700; line-height:1.3; color:#fff;
  }
  .baro-featured h2 a{ color:#fff; text-decoration:none; }
  .baro-featured h2 a:hover{ color:#e8f4ff; }
  
  .baro-side-item h3{
    margin:0 0 6px 0; font-weight:700; line-height:1.32; color:#fff;
    font-size: clamp(16px,1.8vw,22px);
  }
  .baro-side-item h3 a{ color:#fff; text-decoration:none; }
  
  .baro-grid-item h4{
    margin:0 0 6px 0; font-weight:600; line-height:1.32;
    font-size: clamp(14px,1.4vw,16px);
  }
  .baro-grid-item h4 a{
    color: var(--baro-text); text-decoration:none; transition: color .3s ease;
  }
  .baro-grid-item h4 a:hover{ color: var(--baro-primary); }
  
  /* Line clamp helpers */
  .baro-side-item .baro-post-content h3 a{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow:hidden; text-overflow:ellipsis;
  }
  .baro-excerpt{
    color: var(--baro-muted);
    font-size: clamp(13px,1.2vw,14px);
    line-height:1.55; margin:0 0 12px 0;
  }
  
  /* Meta */
  .baro-eye-icon{ width:15px; height:15px; color:white; }
  .baro-eye-icon.invert {
    filter: invert(1) brightness(2);
  }
  .baro-meta{
    display:flex; align-items:center; gap: clamp(8px,1.5vw,15px);
    font-size: clamp(12px,1.2vw,13px);
    color:#7f8c8d; margin-top:8px; flex-wrap: wrap;
  }
  .baro-date,.baro-views{
    display:flex; align-items:center; gap:4px; font-weight:500;
  }
  .baro-views{
    padding:2px 8px;
  }
  .baro-featured .baro-post-content .baro-meta .baro-date,
  .baro-featured .baro-post-content .baro-meta .baro-views,
  .baro-side .baro-meta,.baro-side .baro-views{ color:#fff; }
  
  /* Side column - nằm ở cột thứ 3 */
  .baro-side{
    grid-column: 3;
    grid-row: 1 / 3;
    display:flex; flex-direction:column; gap: clamp(12px,2vw,20px);
  }
  
  /* Grid list (fluid) - 3 cột bên dưới, bắt đầu từ hàng 3 */
  .baro-grid{
    grid-column: 1 / -1;
    grid-row: 3;
    display:grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(12px,2vw,20px);
    margin-top: clamp(16px,2.2vw,25px);
  }
  
  /* Grid layout for page 2+ */
  .baro-grid-layout{
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: clamp(12px,2vw,20px) !important;
    margin: clamp(12px,2.2vw,20px) 0 !important;
  }
  
  .baro-grid-layout .baro-grid{
    grid-column: unset !important;
    margin-top: 0 !important;
  }
  
  /* Grid items in grid layout should behave as grid items */
  .baro-grid-layout .baro-grid-item{
    display: block;
  }
  
  /* Hover color tweaks */
  .baro-side-item h3 a:hover{ color:#fff; }
  
  /* Loading */
  .baro-loading{
    display:inline-block; width:20px; height:20px;
    border:3px solid rgba(52,152,219,.3); border-radius:50%;
    border-top-color: var(--baro-primary);
    animation: baro-spin 1s ease-in-out infinite;
  }
  @keyframes baro-spin{ to{ transform: rotate(360deg);} }
  
  /* Pagination */
  .baro-pagination{
    text-align: center;
    margin: clamp(20px, 3vw, 30px) 0;
    padding: 0 clamp(16px, 3vw, 20px);
  }
  
  .baro-pagination-wrapper{
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(4px, 0.8vw, 8px);
    flex-wrap: wrap;
  }
  
  .baro-page-link{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: clamp(36px, 4vw, 44px);
    height: clamp(36px, 4vw, 44px);
    padding: 0 clamp(8px, 1.2vw, 12px);
    background: #fff;
    color: var(--baro-text);
    text-decoration: none;
    border: 1px solid #e1e8ed;
    font-size: clamp(13px, 1.3vw, 15px);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--baro-shadow-sm);
  }
  
  .baro-page-link:hover:not(.disabled):not(.baro-page-current){
    background: var(--e-global-color-primary);
    color: #fff;
    border-color: var(--e-global-color-primary);
    transform: translateY(-1px);
    box-shadow: var(--baro-shadow-2);
  }
  
  .baro-page-link:active:not(.disabled):not(.baro-page-current){
    transform: translateY(0);
  }
  
  .baro-page-current{
    background: var(--e-global-color-primary);
    color: #fff;
    border-color: var(--e-global-color-primary);
    font-weight: 600;
    cursor: default;
  }
  
  .baro-page-link.disabled{
    background: #f8f9fa;
    color: #adb5bd;
    border-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
  }
  
  .baro-page-prev,
  .baro-page-next{
    font-weight: 600;
    min-width: auto;
    padding: 0 clamp(12px, 2vw, 16px);
  }
  
  .baro-page-dots{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: clamp(36px, 4vw, 44px);
    height: clamp(36px, 4vw, 44px);
    color: var(--baro-muted);
    font-size: clamp(13px, 1.3vw, 15px);
    font-weight: 500;
  }
  
  .baro-news-magazine-wrapper.loading{
    opacity: 0.7;
    pointer-events: none;
    position: relative;
  }
  
  .baro-news-magazine-wrapper.loading::after{
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border-top-color: var(--baro-primary);
    animation: baro-spin 1s ease-in-out infinite;
    z-index: 1000;
  }
  
  /* ======================
     Responsive breakpoints
     ====================== */
  
  /* <= 1200px: lớn vừa */
  @media (max-width: 1200px){
    .baro-news-magazine{
      grid-template-columns: repeat(3, 1fr);
    }
  }
  
  /* <= 992px: tablet landscape */
  @media (max-width: 992px){
    .baro-news-magazine{
      grid-template-columns: 1fr;  /* stack tất cả */
      grid-template-rows: auto;
    }
    .baro-featured{
      grid-column: 1;
      grid-row: 1;
    }
    .baro-side{
      grid-column: 1;
      grid-row: 2;
      order: 2;
    }
    .baro-grid{
      grid-column: 1;
      grid-row: 3;
      order: 3;
      grid-template-columns: repeat(3, 1fr);
    }
    .baro-grid-layout{
      grid-template-columns: repeat(3, 1fr) !important;
    }
    /* tăng độ tương phản overlay để chữ dễ đọc khi ảnh nhỏ */
    .baro-featured .baro-post-image::before{ background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(0,0,0,.7) 100%); }
  }
  
  /* <= 768px: tablet portrait & mobile lớn */
  @media (max-width: 768px){
    .baro-featured .baro-post-image{ 
      min-height: clamp(200px, 48vw, 360px);
    }
    .baro-meta{ gap: 10px; }
    .baro-grid-layout{
      grid-template-columns: repeat(2, 1fr) !important;
    }
  }
  
  /* <= 576px: mobile phổ biến */
  @media (max-width: 576px){
    .baro-grid{
      grid-template-columns: 1fr;
      gap: 14px;
    }
    .baro-grid-layout{
      grid-template-columns: 1fr !important;
    }
    .baro-featured .baro-post-content,
    .baro-side-item .baro-post-content,
    .baro-grid-item .baro-post-content{
      padding: 12px;
    }
    /* tăng line-clamp để title đỡ dài */
    .baro-side-item .baro-post-content h3 a{ 
      -webkit-line-clamp: 2; 
      line-clamp: 2; 
    }
  }
  
  /* <= 380px: mobile rất nhỏ */
  @media (max-width: 380px){
    .baro-featured h2{ font-size: 17px; }
    .baro-side-item h3{ font-size: 15px; }
    .baro-grid-item h4{ font-size: 14px; }
  }
  
  
  /* Print */
  @media print{
    .baro-news-magazine{ display:block !important; box-shadow:none !important; }
    .baro-featured,.baro-side-item,.baro-grid-item{
      box-shadow:none !important; border:1px solid #ddd !important; break-inside: avoid; margin-bottom:20px;
    }
  }
  
  /* Motion accessibility */
  @media (prefers-reduced-motion: reduce){
    *{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  }
  .baro-review-grid {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.baro-review-wrapper h2 {
    text-transform: uppercase;
    font-weight: bold;
    font-size: 1.5rem;
}

.baro-review-left, .baro-review-middle, .baro-review-right {
    flex: 1;
}

.baro-review-middle {
    border-right: 1px solid #eee;
    border-left: 1px solid #eee;
    padding: 20px 40px;
}

.baro-review-right, .baro-review-left {
    text-align: center;
}

.baro-review-average {
    font-size: 2.5em;
    color: green;
    font-weight: bold;
}

.baro-stars .star {
    color: #ccc;
    font-size: 1.2em;
}

.baro-review-average-container{
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-around;
}

.baro-rating-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
}

.baro-bar {
    flex: 1;
    height: 6px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.baro-bar .fill {
    height: 100%;
    background: green;
}

.baro-review-btn {
    padding: 8px 14px;
    border: 2px solid green;
    background: white;
    color: green;
    cursor: pointer;
}

#baro-review-form input,
#baro-review-form textarea {
    width: 100%;
    padding: 8px;
    margin: 5px 0;
    box-sizing: border-box;
}

#baro-review-form .baro-stars-input label {
    font-size: 20px;
    color: #ccc;
    cursor: pointer;
}

#baro-review-form .baro-stars-input input {
    display: none;
}

#baro-review-form .baro-stars-input input:checked ~ label {
    color: gold;
}

.baro-submit {
    padding: 10px 20px;
    background: orange;
    border: none;
    color: white;
    cursor: pointer;
}

.baro-stars-input {
    display: flex;
    flex-direction: row-reverse; 
    justify-content: flex-end;
}

.baro-stars-input input {
    display: none;
}

.baro-stars-input label {
    font-size: 24px;
    color: #ccc;
    cursor: pointer;
    padding: 0 2px;
}

.baro-stars-input input:checked ~ label {
    color: gold;
}

.baro-review-list {
    margin-top: 30px;
}

.baro-single-review {
    border-bottom: 1px solid #eee;
    padding: 10px 0;
}

.baro-review-stars .star-rating {
    font-size: 16px;
    color: gold;
}

.baro-review-author {
    margin: 5px 0 0;
}

.baro-review-content {
    margin: 5px 0;
}

.baro-review-date {
    font-size: 12px;
    color: #888;
}

.baro-pagination {
    margin-top: 15px;
    text-align: center;
}

.baro-pagination .page-numbers {
    display: inline-block;
    margin: 0 4px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
}

.baro-pagination .current {
    background: green;
    color: white;
    border-color: green;
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */

/* Tablet (768px và nhỏ hơn) */
@media (max-width: 768px) {
    .baro-review-wrapper h2 {
        font-size: 1.3rem;
        text-align: center;
        margin-bottom: 15px;
    }
    
    .baro-review-grid {
        flex-direction: column;
        align-items: stretch;
    }
    
    .baro-review-left, .baro-review-middle, .baro-review-right {
        flex: none;
        width: 100%;
    }
    
    .baro-review-middle {
        border: none;
        border-top: 1px solid #eee;
        border-bottom: 1px solid #eee;
        padding: 15px 20px;
        order: 3;
    }
    
    .baro-review-left {
        order: 1;
        padding: 15px 0;
    }
    
    .baro-review-right {
        order: 2;
        padding: 15px 0;
    }
    
    .baro-review-average {
        font-size: 2em;
    }
    
    .baro-rating-row {
        gap: 8px;
        margin: 6px 0;
    }
    
    .baro-stars-input label {
        font-size: 20px;
    }
    
    .baro-pagination .page-numbers {
        padding: 8px 10px;
        margin: 0 2px;
    }
}

/* Mobile (480px và nhỏ hơn) */
@media (max-width: 480px) {
    .baro-review-wrapper h2 {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }
    
    .baro-review-middle {
        padding: 12px 15px;
    }
    
    .baro-review-left, .baro-review-right {
        padding: 10px 0;
    }
    
    .baro-review-average {
        font-size: 1.8em;
    }
    
    .baro-stars .star {
        font-size: 1em;
    }
    
    .baro-rating-row {
        gap: 6px;
        margin: 8px 0;
        font-size: 0.9em;
    }
    
    .baro-review-btn {
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
        max-width: 200px;
    }
    
    #baro-review-form input,
    #baro-review-form textarea {
        padding: 10px;
        font-size: 16px; /* Tránh zoom trên iOS */
    }
    
    .baro-stars-input {
        justify-content: center;
        margin: 10px 0;
    }
    
    .baro-stars-input label {
        font-size: 24px;
        padding: 0 4px;
    }
    
    .baro-submit {
        padding: 12px 24px;
        width: 100%;
        max-width: 200px;
        font-size: 16px;
    }
    
    .baro-single-review {
        padding: 15px 0;
    }
    
    .baro-review-stars .star-rating {
        font-size: 14px;
    }
    
    .baro-pagination {
        margin-top: 20px;
    }
    
    .baro-pagination .page-numbers {
        padding: 10px 8px;
        margin: 0 1px;
        font-size: 14px;
        min-width: 35px;
        text-align: center;
    }
}

/* Mobile nhỏ (320px và nhỏ hơn) */
@media (max-width: 320px) {
    .baro-review-wrapper h2 {
        font-size: 1rem;
    }
    
    .baro-review-average {
        font-size: 1.6em;
    }
    
    .baro-rating-row {
        font-size: 0.85em;
        flex-wrap: wrap;
    }
    
    .baro-stars-input label {
        font-size: 20px;
        padding: 0 2px;
    }
    
    .baro-pagination .page-numbers {
        padding: 8px 6px;
        font-size: 12px;
        min-width: 30px;
    }
}

/* Landscape orientation trên mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .baro-review-grid {
        flex-direction: row;
    }
    
    .baro-review-left, .baro-review-middle, .baro-review-right {
        flex: 1;
    }
    
    .baro-review-middle {
        border: none;
        border-left: 1px solid #eee;
        border-right: 1px solid #eee;
        order: 2;
        padding: 10px 20px;
    }
    
    .baro-review-left {
        order: 1;
    }
    
    .baro-review-right {
        order: 3;
    }
}

/* Cải thiện touch targets cho mobile */
@media (hover: none) and (pointer: coarse) {
    .baro-review-btn,
    .baro-submit,
    .baro-stars-input label,
    .baro-pagination .page-numbers {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto;
    }

    .baro-pagination{
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }

    .baro-pagination .page-numbers{
        margin: unset;
    }

    
    
    .baro-stars-input label {
        min-width: 44px;
        margin: 0 auto;
    }
}
/* Baro Contact Chat Styles */
.bcc-contact-buttons {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    z-index: 9999;
}

.bcc-contact-buttons a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    border-radius: 50px;
    color: white;
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.bcc-contact-buttons a img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.bcc-contact-buttons .phone-wrapper .bcc-phone-text {
    position: absolute;
    left: -125px;
    z-index: -1;
    padding: 5px 33px 5px 15px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

/* Buttons that are icon-only on desktop */
.bcc-zalo,
.bcc-messenger,
.bcc-phone,
.bcc-email {
    width: 50px;
}

/* Pulse effect */
.bcc-pulse {
    animation: pulse 2s infinite;
}

.bcc-contact-buttons .phone-wrapper{
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
}
/* Keyframes are added dynamically via wp_add_inline_style */

/* --- Mobile Styles --- */
@media (max-width: 768px) {
    .bcc-contact-buttons {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 60px;
        border-radius: 0;
        padding: 5px 0;
        gap: 0;
    }

    /* On mobile, all buttons are circular icons */
    .bcc-contact-buttons a {
        width: 45px; /* A bit smaller for mobile */
        height: 45px;
        box-shadow: none;
    }

    .bcc-contact-buttons a img{
        width: 40px;
        height: 40px;
    }

    .bcc-contact-buttons .bcc-messenger,
    .bcc-contact-buttons .bcc-zalo,
    .bcc-contact-buttons .bcc-phone,
    .bcc-contact-buttons .bcc-email {
        background-color: transparent !important;
    }

    /* Hide phone text on mobile */
    .bcc-phone-text {
        display: none;
    }

    .bcc-email img {
        color: white;
    }
}

@media (min-width: 769px) {
  .bcc-email {
    display: none !important;
  }
}
/* ===== CRITICAL LAYOUT - LOAD FIRST ===== */
.baro-filter-layout {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    width: 100% !important;
    box-sizing: border-box;
    position: relative;
    /* Performance optimization: contain layout changes */
    contain: layout;
}

/* Force width calculation on first load */
.baro-filter-layout:not(.initialized) {
    width: 100% !important;
    max-width: 100% !important;
}

/* Filter sidebar - spans 1 column */
#baro-filter-form {
    grid-column: span 1;
    min-width: 0; /* Prevents overflow */
    /* Performance: isolate filters from main content reflow */
    contain: layout style;
}

/* Product content - spans 3 columns */
.baro-filter-layout > div:last-child {
    grid-column: span 3;
    min-width: 0; /* Prevents overflow */
}

/* ===== OPTIMIZED PRODUCT GRID ===== */
.baro-products {
    display: grid;
    gap: 20px;
    /* Performance: prevent layout shifts during loading */
    min-height: 400px;
    contain: layout;
}
.baro-col-3 { grid-template-columns: repeat(3, 1fr); }
.baro-col-4 { grid-template-columns: repeat(4, 1fr); }
.baro-col-5 { grid-template-columns: repeat(5, 1fr); }

.baro-product {
    padding: 10px;
    text-align: center;
    /* Performance optimization: prepare for animations */
    will-change: transform, opacity;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.baro-product:hover {
    transform: translateY(-2px);
}

.baro-product img {
    width: 100%;
    height: auto;
    object-fit: cover;
    background-color: #f5f5f5; /* Placeholder color while loading */
    display: block;
    /* Performance: optimize image rendering */
    image-rendering: -webkit-optimize-contrast;
}

/* ===== OPTIMIZED PAGINATION ===== */
.baro-pagination {
    text-align: center;
    margin-top: 20px;
    /* Performance: isolate pagination from main content */
    contain: layout style;
}

.baro-pagination a {
    margin: 0 5px;
    padding: 5px 10px;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    display: inline-block;
}

.baro-pagination a:hover {
    background-color: #f5f5f5;
    transform: scale(1.05);
}
.baro-pagination a.active {
    background: green;
    color: #fff;
    border-color: green;
    transform: scale(1.1);
}

/* ===== FILTER GROUP STYLING ===== */
.baro-filter-group{
    margin-bottom: 20px;
    border: 1px solid #eee;
    padding: 15px;
    border-radius: 5px;
    background: #fafafa;
    /* Performance: isolate filter groups */
    contain: layout style;
}

.baro-heading-filter{
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0px;
    text-transform: uppercase;
    color: var(--e-global-color-primary);
    padding-bottom: 5px;
}

.baro-product-heading {
    font-size: 24px;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--e-global-color-primary);
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

.checkbox-wrapper-1{
    display: flex;
    padding-bottom: 10px;
    /* Performance: optimize checkbox rendering */
    contain: layout;
}

/* ===== OPTIMIZED LOADING STATES ===== */

/* Loading state container */
.baro-loading-state {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

/* Skeleton loading animation - optimized */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.baro-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: skeleton-shimmer 1.5s infinite linear;
    border-radius: 4px;
}

.baro-skeleton-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    margin-bottom: 10px;
}

.baro-skeleton-title {
    height: 20px;
    width: 80%;
    margin: 0 auto 10px auto;
}

/* Error state styling */
.baro-error {
    text-align: center;
    padding: 40px 20px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 5px;
    color: #c33;
    font-weight: 500;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Reduce repaints during animations */
.baro-product,
.baro-pagination a,
.baro-skeleton {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Optimize filter checkbox transitions */
.checkbox-wrapper-1 input[type="checkbox"] {
    transition: all 0.2s ease;
}

.checkbox-wrapper-1 label {
    transition: color 0.2s ease;
    cursor: pointer;
}

/* ===== CATEGORY SEARCH FORM STYLING ===== */
.baro-cat-search {
    width: 100%;
    max-width: 600px;
}

.baro-cat-search__inner {
    display: flex;
    align-items: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.baro-cat-search__inner:focus-within {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.baro-cat-search__select {
    position: relative;
    flex: 0 0 auto;
    background: #f8f9fa;
    border-right: 1px solid #ddd;
}

.baro-cat-search__select select {
    appearance: none;
    background: transparent;
    border: none;
    padding: 12px 35px 12px 15px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    min-width: 120px;
    outline: none;
}

.baro-cat-search__caret {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #666;
    font-size: 12px;
}

.baro-cat-search__input {
    flex: 1;
    border: none;
    padding: 12px 15px;
    font-size: 14px;
    outline: none;
    background: transparent;
}

.baro-cat-search__input::placeholder {
    color: #999;
}

.baro-cat-search__btn {
    flex: 0 0 auto;
    background: #007cba;
    border: none;
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.baro-cat-search__btn:hover {
    background: #005a87;
}

.baro-cat-search__btn svg {
    width: 18px;
    height: 18px;
    color:white;
}

/* Responsive design for category search */
@media (max-width: 768px) {
    .baro-cat-search__inner {
        flex-direction: column;
    }
    
    .baro-cat-search__select {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    
    .baro-cat-search__select select {
        width: 100%;
        text-align: center;
    }
    
    .baro-cat-search__input {
        padding: 15px;
    }
    
    .baro-cat-search__btn {
        width: 100%;
        justify-content: center;
        padding: 15px;
    }
}

/* Legacy skeleton classes for backward compatibility */
.skeleton-item {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: skeleton-shimmer 1.5s infinite linear;
    animation-timing-function: linear;
    will-change: background-position;
    border-radius: 8px;
}

.skeleton-title {
    height: 20px;
    margin-bottom: 10px;
    width: 80%;
}

/* Desktop skeleton grid - 4 columns, 3 rows */
.skeleton-grid-desktop {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

/* Mobile skeleton grid - 2 columns, 1 row */
.skeleton-grid-mobile {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

#baro-filter-results.loading {
    opacity: 1;
    position: relative;
}

#baro-filter-results.loading .skeleton-container {
    display: block;
}

#baro-filter-results:not(.loading) .skeleton-container {
    display: none;
}

/* ===== RESPONSIVE FOR SKELETON LOADING ===== */

/* Tablet skeleton adjustments */
@media (max-width: 1023px) and (min-width: 768px) {
    .skeleton-grid-desktop {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile skeleton - show mobile grid */
@media (max-width: 767px) {
    .skeleton-grid-desktop {
        display: none;
    }
    .skeleton-grid-mobile {
        display: grid;
    }
}

/* Desktop - show desktop grid */
@media (min-width: 768px) {
    .skeleton-grid-mobile {
        display: none;
    }
    .skeleton-grid-desktop {
        display: grid;
    }
}
/* Layout chính: sidebar + sản phẩm - REMOVED CONFLICTING GRID LAYOUT */

/* Grid sản phẩm */
.baro-products {
    display: grid;
    gap: 20px;
}
.baro-col-2 { grid-template-columns: repeat(2, 1fr); }
.baro-col-3 { grid-template-columns: repeat(3, 1fr); }
.baro-col-4 { grid-template-columns: repeat(4, 1fr); }
.baro-col-5 { grid-template-columns: repeat(5, 1fr); }
.baro-col-6 { grid-template-columns: repeat(6, 1fr); }

/* Sản phẩm */
.baro-product {
    padding: 10px;
    text-align: center;
}

/* ===== PAGINATION STYLES ===== */
.baro-pagination {
    text-align: center;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.baro-pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: #fff;
}

.baro-pagination a:hover {
    background: #f5f5f5;
    border-color: #bbb;
    transform: translateY(-1px);
}

.baro-pagination a.active {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
    font-weight: 600;
}

.baro-pagination a.active:hover {
    background: #16a34a;
    border-color: #16a34a;
    transform: none;
}

.baro-pagination .baro-pagination-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    color: #666;
    font-weight: 500;
    user-select: none;
    font-size: 16px;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
    .baro-filter-layout {
        gap: 30px;
        grid-template-columns: repeat(4, 1fr);
    }
    #baro-filter-form {
        grid-column: span 1;
    }
    .baro-filter-layout > div:last-child {
        grid-column: span 3;
    }
    .baro-products {
        gap: 0px;
    }
    .baro-product {
        padding: 15px;
    }
}

/* Desktop (1024px - 1199px) */
@media (max-width: 1199px) and (min-width: 1024px) {
    .baro-filter-layout {
        gap: 20px;
        grid-template-columns: repeat(4, 1fr);
    }
    #baro-filter-form {
        grid-column: span 1;
    }
    .baro-filter-layout > div:last-child {
        grid-column: span 3;
    }
    .baro-products {
        gap: 20px;
    }
}

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) and (min-width: 768px) {
    .baro-filter-layout {
        gap: 15px;
        grid-template-columns: repeat(4, 1fr);
    }
    #baro-filter-form {
        grid-column: span 1;
    }
    .baro-filter-layout > div:last-child {
        grid-column: span 3;
    }
    .baro-products {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 15px;
    }
    .baro-product {
        padding: 8px;
    }
    .baro-heading-filter {
        font-size: 1.3rem;
    }
    .baro-product-heading {
        font-size: 20px;
    }
}

/* Mobile - All sizes (768px and below) */
@media (max-width: 768px) {
    .baro-filter-layout {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    #baro-filter-form {
        grid-column: span 1 !important;
    }
    .baro-filter-layout > div:last-child {
        grid-column: span 1 !important;
    }
}

/* Mobile Large (481px - 767px) */
@media (max-width: 767px) and (min-width: 481px) {
    .baro-filter-layout {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    #baro-filter-form {
        grid-column: span 1;
    }
    .baro-filter-layout > div:last-child {
        grid-column: span 1;
    }
    .baro-products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
    .baro-product {
        padding: 8px;
    }
    .baro-heading-filter {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }
    .baro-product-heading {
        font-size: 18px;
        margin-bottom: 15px;
    }
    .baro-filter-group {
        padding: 12px;
        margin-bottom: 15px;
    }
    .baro-product h3 a {
        font-size: 14px;
    }
}

/* Mobile Small (320px - 480px) */
@media (max-width: 480px) {
    .baro-filter-layout {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    #baro-filter-form {
        display: none;
    }
    .baro-filter-layout > div:last-child {
        grid-column: span 1;
    }
    .baro-products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    .baro-product {
        padding: 6px;
    }
    .baro-heading-filter {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }
    .baro-product-heading {
        font-size: 16px;
        margin-bottom: 12px;
    }
    .baro-filter-group {
        padding: 10px;
        margin-bottom: 12px;
    }
    .baro-product h3 a {
        font-size: 13px;
    }
    .baro-pagination a {
        padding: 4px 8px;
        margin: 0 3px;
        font-size: 14px;
    }
}


.checkbox-wrapper-1 *,
.checkbox-wrapper-1 ::after,
.checkbox-wrapper-1 ::before {
  box-sizing: border-box;
}
.checkbox-wrapper-1 [type=checkbox].substituted {
  margin: 0;
  width: 0;
  height: 0;
  display: inline;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.checkbox-wrapper-1 [type=checkbox].substituted + label:before {
  content: "";
  display: inline-block;
  vertical-align: top;
  height: 1.15em;
  width: 1.15em;
  margin-right: 0.6em;
  color: rgba(0, 0, 0, 0.275);
  border: solid 0.06em;
  box-shadow: 0 0 0.04em, 0 0.06em 0.16em -0.03em inset, 0 0 0 0.07em transparent inset;
  border-radius: 0.2em;
  background: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0 0 9 9"><rect x="0" y="4.3" transform="matrix(-0.707 -0.7072 0.7072 -0.707 0.5891 10.4702)" width="4.3" height="1.6" /><rect x="2.2" y="2.9" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 12.1877 2.9833)" width="6.1" height="1.7" /></svg>') no-repeat center, white;
  background-size: 0;
  transition: color 0.1s, border 0.1s, background 0.15s, box-shadow 0.1s;
}
.checkbox-wrapper-1 [type=checkbox].substituted:checked + label:before {
  background-color: #3B99FC;
  background-size: 0.75em;
  color: rgba(0, 0, 0, 0.075);
}
.checkbox-wrapper-1 [type=checkbox].substituted + label {
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
}


.checkbox-wrapper-1 label {
  display: flex;
  justify-content: start;
  align-items: center;         
  width: 100%;                 
}

.checkbox-wrapper-1 label::before {
  flex-shrink: 0; 
}

/* ===== RESPONSIVE FOR CHECKBOXES ===== */

/* Tablet cho checkboxes */
@media (max-width: 1023px) and (min-width: 768px) {
  .checkbox-wrapper-1 [type=checkbox].substituted + label:before {
    height: 1.1em;
    width: 1.1em;
    margin-right: 0.5em;
  }
  .checkbox-wrapper-1 [type=checkbox].substituted:checked + label:before {
    background-size: 0.7em;
  }
}

/* Mobile cho checkboxes */
@media (max-width: 767px) {
  .checkbox-wrapper-1 [type=checkbox].substituted + label:before {
    height: 1.05em;
    width: 1.05em;
    margin-right: 0.4em;
  }
  .checkbox-wrapper-1 [type=checkbox].substituted:checked + label:before {
    background-size: 0.65em;
  }
  .checkbox-wrapper-1 label {
    font-size: 14px;
    padding: 4px 0;
  }
}

/* Mobile Small cho checkboxes */
@media (max-width: 480px) {
  .checkbox-wrapper-1 [type=checkbox].substituted + label:before {
    height: 1em;
    width: 1em;
    margin-right: 0.3em;
  }
  .checkbox-wrapper-1 [type=checkbox].substituted:checked + label:before {
    background-size: 0.6em;
  }
  .checkbox-wrapper-1 label {
    font-size: 13px;
    padding: 3px 0;
  }
}

.baro-product h3 a{
    margin-bottom: 10px;
    line-height: 1 !important;
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    color: #000;
}

.baro-product h3{
  line-height: 1 !important;
}


/* ===== BARO CATEGORY SEARCH – clean unified style ===== */

.baro-cat-search { max-width: 780px; }
.baro-cat-search__inner{
  display:flex; align-items:center; gap:0;
  background:#fff;
  border:1px solid #d1d5db;           /* gray-300 */
  border-radius:10px;
  overflow:hidden;
  box-shadow:0 1px 2px rgba(0,0,0,.03);
  transition:border-color .2s, box-shadow .2s;
}
.baro-cat-search__inner:focus-within{
  border-color:#22c55e;                /* green-500 */
  box-shadow:0 0 0 3px rgba(34,197,94,.15);
}

/* Select column */
.baro-cat-search__select{
  position:relative;
  flex:0 0 170px;                      /* width of select area */
  border-right:1px solid #e5e7eb;      /* divider */
  background:#fff;
}
.baro-cat-search__select select{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  width:100%;
  height:46px;
  padding:0 38px 0 14px;
  font-size:16px;
  line-height:46px;
  background:transparent;
  border:0 !important;
  box-shadow:none !important;
  color:#0f172a;                        /* slate-900 */
  cursor:pointer;
}
.baro-cat-search__select select:focus{ outline:none; }

/* custom caret */
.baro-cat-search__caret{
  position:absolute; right:12px; top:50%;
  transform:translateY(-50%);
  pointer-events:none;
  font-size:12px; color:#64748b;       /* slate-500 */
}

/* Keyword input */
.baro-cat-search__input{
  flex:1;
  height:46px;
  padding:0 14px;
  font-size:16px;
  border:0 !important;
  box-shadow:none !important;
  background:#fff;
  color:#0f172a;
}
.baro-cat-search__input::placeholder{ color:#9ca3af; }
.baro-cat-search__input:focus{ outline:none; }

/* Fix các pseudo buttons trên Safari/Chrome cho input[type=search] */
.baro-cat-search__input::-webkit-search-decoration,
.baro-cat-search__input::-webkit-search-cancel-button,
.baro-cat-search__input::-webkit-search-results-button,
.baro-cat-search__input::-webkit-search-results-decoration { display:none; }

/* Submit button */
.baro-cat-search__btn{
  width:56px; height:46px;
  display:flex; align-items:center; justify-content:center;
  border:0; border-left:1px solid #e5e7eb;
  background:#22c55e;                  /* green-500 */
  cursor:pointer;
  transition:filter .15s, background .15s;
}
.baro-cat-search__btn:hover{ filter:brightness(.96); }
.baro-cat-search__btn:active{ filter:brightness(.9); }
.baro-cat-search__btn:focus{ outline:none; }

/* Remove ugly outlines/borders from any child on focus */
.baro-cat-search select:focus,
.baro-cat-search input:focus,
.baro-cat-search button:focus{
  outline:none !important;
  box-shadow:none !important;
}

/* ===== RESPONSIVE FOR SEARCH FORM ===== */

/* Tablet cho search form */
@media (max-width: 1023px) and (min-width: 768px) {
  .baro-cat-search { max-width: 100%; }
  .baro-cat-search__select { flex: 0 0 150px; }
  .baro-cat-search__inner { height: 44px; }
  .baro-cat-search__select select,
  .baro-cat-search__input { height: 44px; font-size: 15px; }
  .baro-cat-search__btn { width: 50px; height: 44px; }
}

/* Mobile Large cho search form */
@media (max-width: 767px) and (min-width: 481px) {
  .baro-cat-search { max-width: 100%; }
  .baro-cat-search__inner { 
    flex-wrap: wrap; 
    border-radius: 12px; 
    height: auto;
  }
  .baro-cat-search__select { 
    flex: 1 1 100%; 
    border-right: 0; 
    border-bottom: 1px solid #e5e7eb; 
  }
  .baro-cat-search__select select {
    height: 44px;
    font-size: 15px;
  }
  .baro-cat-search__input {
    height: 44px;
    font-size: 15px;
  }
  .baro-cat-search__btn { 
    width: 100%; 
    height: 44px;
    border-left: 0; 
    border-top: 1px solid #e5e7eb; 
  }
}

/* Mobile Small cho search form */
@media (max-width: 480px) {
  .baro-cat-search { max-width: 100%; }
  .baro-cat-search__inner { 
    flex-wrap: wrap; 
    border-radius: 10px; 
    height: auto;
  }
  .baro-cat-search__select { 
    flex: 1 1 100%; 
    border-right: 0; 
    border-bottom: 1px solid #e5e7eb; 
  }
  .baro-cat-search__select select {
    height: 42px;
    font-size: 14px;
    padding: 0 32px 0 12px;
  }
  .baro-cat-search__caret {
    right: 10px;
    font-size: 11px;
  }
  .baro-cat-search__input {
    height: 42px;
    font-size: 14px;
    padding: 0 12px;
  }
  .baro-cat-search__btn { 
    width: 100%; 
    height: 42px;
    border-left: 0; 
    border-top: 1px solid #e5e7eb; 
  }
  .baro-cat-search__btn svg {
    width: 18px;
    height: 18px;
    color: white;
  }
}

/* Button search (override mạnh) */
.baro-cat-search__btn {
    width: 56px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border: transparent !important;
    background: #22c55e !important;   /* màu mặc định */
    cursor: pointer;
    transition: background 0.2s ease, filter 0.2s ease;
    border-radius: 0 !important;                  /* bỏ viền bo riêng */
  }
  
  /* Hover */
  .baro-cat-search__btn:hover {
    background: #16a34a !important;   /* xanh lá đậm hơn */
  }
  
  /* Active khi click */
  .baro-cat-search__btn:active {
    background: #15803d !important;   /* xanh lá đậm nhất */
  }

/* ===== ADDITIONAL RESPONSIVE IMPROVEMENTS ===== */

/* Touch-friendly improvements for mobile */
@media (max-width: 767px) {
  .baro-pagination a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
  }
  
  .baro-pagination .baro-pagination-dots {
    min-width: 44px;
    min-height: 44px;
    font-size: 14px;
  }
  
  .checkbox-wrapper-1 label {
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
  }
  
  .baro-filter-group {
    border-radius: 8px;
  }
}

/* Landscape orientation for mobile */
@media (max-width: 767px) and (orientation: landscape) {
  .baro-filter-layout {
    gap: 8px;
  }
  .baro-products {
    gap: 8px;
  }
  .baro-product {
    padding: 4px;
  }
  .baro-heading-filter {
    font-size: 1rem;
    margin-bottom: 8px;
  }
  .baro-product-heading {
    font-size: 16px;
    margin-bottom: 10px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .baro-product img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Print styles */
@media print {
  .baro-filter-layout {
    grid-template-columns: 1fr;
  }
  .baro-filter-group {
    break-inside: avoid;
    border: 1px solid #000;
    background: #fff !important;
  }
  .baro-product {
    break-inside: avoid;
    border: 1px solid #ccc;
    margin-bottom: 10px;
  }
  .baro-pagination {
    display: none;
  }
}
  