/* --- 1. Global Setup --- */
body { 
    font-family: "Helvetica Neue", Arial, sans-serif; 
    line-height: 1.6; color: #333; margin: 0; background: #f9f9f9; 
    border-top: 10px solid #29bd64 !important;
}
header { background: #29bd64; color: #fff; padding: 40px 20px; text-align: center; }
header h1 { margin: 0; font-size: 2.5rem; }
header h1 a { color: #fff; text-decoration: none; }
header p { margin: 10px 0 0; opacity: 0.8; }

.container { 
    max-width: 1200px; margin: 20px auto; background: #fff; padding: 20px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
}

/* --- 2. Top Page Tabs & Grid (index.php) --- */
.tab-container { display: flex; flex-wrap: wrap; margin-top: 20px; }
input[name="tab-item"] { display: none; }
.tab-label { 
    flex: 1; min-width: 150px; padding: 15px; text-align: center; 
    background: #eee; cursor: pointer; border: 1px solid #ddd; font-weight: bold; 
}
input[name="tab-item"]:checked + .tab-label { 
    background: #fff; border-bottom: none; color: #29bd64; border-top: 3px solid #29bd64; 
}
.tab-content { display: none; width: 100%; padding: 30px 0; border-top: 1px solid #ddd; order: 1; }

#tab-brand:checked ~ #content-brand,
#tab-style:checked ~ #content-style,
#tab-maintenance:checked ~ #content-maintenance { display: block; }

.link-group { margin-bottom: 30px; }
.link-group h2 { font-size: 1.3rem; border-left: 5px solid #29bd64; padding-left: 10px; margin-bottom: 15px; border-bottom: 1px solid #eee; }

/* Standard Link Grid */
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.link-grid a { 
    display: block; padding: 10px; background: #fefefe; border: 1px solid #eee; 
    text-decoration: none; color: #333; font-size: 0.9rem; transition: 0.2s; 
}
.link-grid a:hover { background: #29bd64; color: #fff; border-color: #29bd64; }

/* Direct Gender Buttons in Styles Tab */
.style-link-grid-direct {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 10px 0;
}
.style-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: 0.2s;
}
.style-card:hover { border-color: #29bd64; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.style-info strong { display: block; font-size: 1.1rem; color: #29bd64; margin-bottom: 5px; }
.style-info p { font-size: 0.85rem; color: #666; margin-bottom: 15px; line-height: 1.4; }
.style-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-btns a {
    text-align: center; padding: 10px 5px; text-decoration: none; 
    font-weight: bold; font-size: 0.85rem; border-radius: 4px; transition: 0.2s;
}
.btn-men { background: #f8f9fa; color: #2c3e50; border: 1px solid #2c3e50; }
.btn-men:hover { background: #2c3e50; color: #fff !important; }
.btn-women { background: #fdf2f2; color: #c0392b; border: 1px solid #c0392b; }
.btn-women:hover { background: #c0392b; color: #fff !important; }

/* --- 3. Catalog Page Layout --- */
.main-layout { display: flex; max-width: 1400px; margin: 20px auto; gap: 30px; padding: 0 20px; }
.content-main { flex: 1; min-width: 0; }
.sidebar { width: 280px; flex-shrink: 0; }

/* --- 4. Pagination --- */
.pagination { 
    display: flex; justify-content: space-between; align-items: center; 
    margin: 20px 0; padding: 15px; background: #fff; border: 1px solid #eee; 
}
.pagination-left { display: flex; align-items: center; gap: 20px; }
.pagination-right { text-align: right; }
.result-count { font-size: 0.85rem; color: #777; margin: 0; }
.pager-btns a { 
    display: inline-block; padding: 8px 16px; border: 1px solid #29bd64; 
    color: #29bd64; text-decoration: none; border-radius: 4px; font-weight: bold; 
}
.pager-btns a:hover { background: #29bd64; color: #fff !important; }
.btn-home-link { font-size: 0.9rem; color: #333; font-weight: bold; text-decoration: underline; }

/* --- 5. Catalog Item Cards --- */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 25px; margin: 20px 0; }
.item-card { 
    background: #fff; border: 1px solid #eee; padding: 0; 
    display: flex; flex-direction: column; overflow: hidden; transition: 0.3s;
    height: 100%;
}
.item-card:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.1); transform: translateY(-3px); }

.img-container { 
    width: 100%; 
    height: 250px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    margin-bottom: 25px; 
    overflow: hidden; 
    background: #fff;
}
.item-img { max-width: 90%; max-height: 90%; object-fit: contain; }

.item-title { 
    padding: 0 15px;
    font-size: 1rem; 
    font-weight: bold; 
    margin-bottom: 10px; 
    height: 3em; 
    overflow: hidden; 
    line-height: 1.4; 
}
.price { 
    padding: 0 15px;
    color: #d32f2f; 
    font-weight: bold; 
    font-size: 1.5rem; 
    margin-bottom: 15px; 
}

.btn-container { display: flex; width: 100%; margin-top: auto; border-top: 1px solid #eee; }
.btn-detail, .btn-buy { 
    flex: 1; text-align: center; padding: 18px 5px; 
    font-weight: bold; text-decoration: none; font-size: 0.95rem; 
}
.btn-detail { background: #f4f4f4; color: #666; }
.btn-buy { background: #d32f2f; color: #fff !important; }

/* --- 6. Sidebar Tabs --- */
.side-tab-container { background: #fff; border: 1px solid #ddd; }
input[name="side-tab"] { display: none; }
.side-tab-nav { display: flex; border-bottom: 2px solid #222; }
.side-tab-label { flex: 1; padding: 12px; text-align: center; background: #eee; cursor: pointer; font-size: 0.85rem; font-weight: bold; }

input#side-brand:checked ~ .side-tab-nav label.label-brand,
input#side-style:checked ~ .side-tab-nav label.label-style,
input#side-maintenance:checked ~ .side-tab-nav label.label-maint { background: #222; color: #fff; }

.side-tab-content { display: none; padding: 15px; }
#side-brand:checked ~ #side-content-brand,
#side-style:checked ~ #side-content-style,
#side-maintenance:checked ~ #side-content-maintenance { display: block !important; }

.side-link-list { list-style: none; padding: 0; margin: 0; }
.side-link-list li a { display: block; padding: 10px; font-size: 0.9rem; color: #444; text-decoration: none; border-bottom: 1px solid #f0f0f0; }

/* --- 7. Detail Page --- */
.back-link { margin-bottom: 20px; }
.back-link a { color: #666; text-decoration: none; font-size: 0.9rem; font-weight: bold; }
.item-detail-flex { display: flex; gap: 40px; margin-top: 20px; align-items: flex-start; }
.item-detail-img { flex: 1; background: #fff; border: 1px solid #eee; padding: 20px; text-align: center; }
.item-detail-img img { max-width: 100%; height: auto; }
.item-detail-info { flex: 1.2; }

/* Fix: Resolve overlapping and hidden product titles */
.item-detail-info h1 { 
    font-size: 1.8rem; 
    margin: 0 0 15px; 
    line-height: 1.5 !important;
    height: auto !important;
    overflow: visible !important;
    display: block;
}

.item-detail-info .price { font-size: 2.2rem; margin: 20px 0; display: block; }
.item-caption { margin-top: 30px; padding-top: 20px; border-top: 2px solid #eee; font-size: 1rem; color: #444; line-height: 1.8; }

/* --- 8. Footer & Misc --- */
.intro { margin: 20px 0 30px; padding: 20px; background: #fdfdfd; border-left: 4px solid #29bd64; color: #444; }
.cat-desc { font-size: 0.9rem; color: #666; margin-bottom: 15px; line-height: 1.6; background: #fafafa; padding: 10px; }
footer { text-align: center; padding: 40px; color: #888; background: #222; margin-top: 50px; }

/* --- 9. Responsive Queries --- */
@media (max-width: 1000px) {
    .main-layout, .item-detail-flex { flex-direction: column; }
    .sidebar, .item-detail-img, .item-detail-info { width: 100%; }
    .sidebar { order: 2; margin-top: 30px; }
    .content-main { order: 1; }
    .pagination { flex-direction: column; gap: 15px; text-align: center; }
}

/* Mobile Optimizations */
@media (max-width: 650px) {
    /* Catalog 2-column grid */
    .item-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    /* Image height adjustment for 2-column */
    .img-container { 
        height: 160px; 
        margin-bottom: 10px; 
    }
    /* Card inner text adjustment */
    .item-title { 
        height: 3.5em; 
        font-size: 0.85rem; 
        padding: 0 8px; 
    }
    .price { 
        font-size: 1.1rem; 
        padding: 0 8px; 
        margin-bottom: 10px; 
    }
    /* Buttons adjustment */
    .btn-detail, .btn-buy { 
        padding: 12px 2px; 
        font-size: 0.75rem; 
    }
    .style-link-grid-direct { grid-template-columns: 1fr; }

    /* Add: Adjust detail page title for mobile environment */
    .item-detail-info h1 {
        font-size: 1.3rem !important;
        line-height: 1.4 !important;
    }
}