/*
 * KeyurInfo Solutions - Final Responsive Layer
 * Presentation-only overrides. Does not change routes, permissions,
 * database logic, cart, checkout or payment behaviour.
 */

/* Global overflow protection */
html, body { max-width:100%; overflow-x:hidden; }
*, *::before, *::after { box-sizing:border-box; }
img, svg, video, iframe { max-width:100%; }
button, input, select, textarea { max-width:100%; }

/* =========================
   PUBLIC HEADER
   ========================= */
.ki-nav-inner { width:100%; }
.ki-nav-list { min-width:0; }
.ki-nav-link { text-align:center; }
.ki-dropdown { max-width:min(320px, calc(100vw - 24px)); }
.ki-shop-dropdown { max-height:min(70vh, 520px); overflow-y:auto; overflow-x:hidden; }

/* Tablet: keep navigation readable without forcing awkward wrapping. */
@media (max-width:1199px) and (min-width:992px) {
    .ki-nav-link { padding-left:9px; padding-right:9px; font-size:13px; }
    .ki-nav-list { flex-wrap:nowrap; overflow-x:auto; justify-content:flex-start; scrollbar-width:thin; }
    .ki-nav-list > li { flex:0 0 auto; }
}

/* Mobile header: one compact row + accessible menu panel. */
@media (max-width:991px) {
    .ki-mobile-top { min-height:68px; padding:7px 12px; }
    .ki-mobile-logo img { max-width:calc(100vw - 82px); max-height:54px; }
    .ki-mobile-toggle { width:44px; height:44px; flex-basis:44px; }
    .ki-mobile-panel { max-height:calc(100dvh - 68px); overscroll-behavior:contain; }
    .ki-mobile-list a { min-height:50px; padding:13px 15px; }
    .ki-mobile-list ul a { padding-left:32px; }
}

/* =========================
   SHOP CATEGORY NAVIGATION
   ========================= */
.shop-page { min-width:0; }
.shop-category-tabs {
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:8px;
    min-width:0;
    padding:10px;
}
.shop-category-tab {
    flex:0 0 auto;
    min-height:42px;
    justify-content:center;
    white-space:nowrap;
}
.shop-category-tabs-wrap { min-width:0; }
.shop-category-mobile-select { display:none; }

@media (max-width:991px) {
    .shop-category-tabs {
        flex-wrap:nowrap;
        overflow-x:auto;
        overflow-y:hidden;
        scrollbar-width:thin;
        -webkit-overflow-scrolling:touch;
        scroll-snap-type:x proximity;
        padding:8px 6px 10px;
    }
    .shop-category-tab { scroll-snap-align:start; }
}

@media (max-width:575px) {
    /* Mobile gets a native select as well as the swipeable category rail.
       This guarantees every category remains directly accessible. */
    .shop-category-tabs { display:none; }
    .shop-category-mobile-select {
        display:block;
        background:#fff;
        padding:10px;
        border-radius:14px;
        box-shadow:0 6px 24px rgba(0,0,0,.05);
    }
    .shop-category-mobile-select label {
        display:block;
        margin:0 0 6px;
        color:#17324d;
        font-size:13px;
        font-weight:700;
    }
}

/* =========================
   SHOP PRODUCT GRID / CARDS
   ========================= */
.shop-card {
    min-width:0;
    display:flex;
    flex-direction:column;
}
.shop-card > a { display:block; min-width:0; }
.shop-card img { display:block; width:100%; height:240px; object-fit:cover; }
.shop-card-body { min-width:0; display:flex; flex-direction:column; }
.shop-card-body h5 { min-height:44px; overflow-wrap:anywhere; }
.shop-card-body form { margin-top:auto; }
.shop-price, .shop-old-price { white-space:nowrap; }

@media (max-width:1199px) {
    .shop-card img { height:220px; }
}
@media (max-width:767px) {
    .shop-page { padding:36px 0 56px; }
    .shop-sidebar { padding:16px; }
    .shop-card img { height:220px; }
    .shop-card-body { padding:16px; }
    .shop-card-body h5 { min-height:0; }
}
@media (max-width:575px) {
    .shop-page { padding:26px 0 44px; }
    .shop-card img { height:230px; }
    .shop-page .container { width:min(100% - 20px, 1180px); }
    .shop-selected-category { padding:9px 10px; }
}

/* =========================
   SHOP DETAIL
   ========================= */
.shop-detail-image {
    display:block;
    width:100%;
    max-width:100%;
    height:auto;
    max-height:520px;
}
.shop-detail-actions { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.shop-detail-actions form { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }

@media (max-width:767px) {
    .shop-detail-image { max-height:420px; }
    .shop-detail-actions,
    .shop-detail-actions form { width:100%; }
    .shop-detail-actions .default-btn,
    .shop-detail-actions .btn { min-height:44px; }
}
@media (max-width:575px) {
    .shop-detail-image { max-height:330px; }
    .shop-detail-actions form { width:100%; }
    .shop-detail-actions form input[type="number"] { flex:0 0 82px; }
    .shop-detail-actions form .default-btn,
    .shop-detail-actions > form .btn { flex:1 1 auto; }
}

/* =========================
   CART TABLE
   ========================= */
.shop-table { min-width:700px; }
.shop-table th, .shop-table td { vertical-align:middle; }
.shop-table .cart-product-cell { min-width:240px; }
.shop-table .cart-product-name { overflow-wrap:anywhere; }
.cart-thumb { flex:0 0 70px; }

.shop-table-wrap {
    width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:thin;
}

@media (max-width:575px) {
    .shop-table-wrap { margin-right:-10px; width:calc(100% + 20px); padding:0 10px 6px; }
    .shop-table { min-width:660px; }
    .shop-table .cart-thumb { width:56px; height:56px; flex-basis:56px; }
}

/* =========================
   CHECKOUT / SUCCESS
   ========================= */
.shop-checkout-card { min-width:0; }
.shop-order-item { min-width:0; gap:12px; }
.shop-order-item > span { min-width:0; overflow-wrap:anywhere; }

@media (max-width:767px) {
    .shop-checkout-card { padding:20px !important; }
    .shop-checkout-card h3,
    .shop-checkout-card h4 { font-size:24px; }
}
@media (max-width:575px) {
    .shop-checkout-card { padding:16px !important; }
    .shop-checkout-card .input-group { flex-wrap:nowrap; }
    .shop-checkout-card .input-group .form-control { min-width:0; }
    .shop-checkout-card .input-group .btn { flex:0 0 auto; }
}

/* =========================
   PUBLIC CMS TABLES / TABS
   ========================= */
.cms-rich-content .table-responsive,
.cms-rich-content table { max-width:100%; }
.cms-rich-content table { width:100%; }

@media (max-width:767px) {
    .page-card { padding:20px !important; }
    .page-content { overflow-wrap:anywhere; }
    .cms-rich-content { font-size:15px; line-height:1.7; }
    .cms-rich-content table { display:block; overflow-x:auto; white-space:nowrap; }
}

/* =========================
   BOOTSTRAP PAGINATION
   ========================= */
.shop-page .pagination { flex-wrap:wrap; gap:4px; }
.shop-page .pagination .page-link { min-width:40px; min-height:40px; display:flex; align-items:center; justify-content:center; }

/* =========================
   ADMIN - TABLES, FORMS, BUTTONS
   ========================= */
.admin-responsive-table {
    width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:thin;
}
.admin-responsive-table > table { min-width:760px; margin-bottom:0; }
.admin-responsive-table .nowrap { white-space:nowrap; }
.admin-responsive-actions { display:flex; flex-wrap:wrap; gap:5px; }
.admin-category-edit-form { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.admin-category-edit-form .category-name-input { flex:1 1 180px; min-width:150px; }
.admin-category-edit-form .category-order-input { flex:0 0 85px; }

@media (max-width:991px) {
    .page-content { min-width:0; }
    .page-content .card { max-width:100%; }
    .page-content .d-flex { min-width:0; }
    .page-content h4 { overflow-wrap:anywhere; }
}

@media (max-width:767px) {
    .page-content { padding-left:12px !important; padding-right:12px !important; }
    .page-content .card-body { padding:16px; }
    .page-content .row > [class*="col-"] { min-width:0; }
    .page-content .btn { min-height:38px; }
    .page-content .form-control,
    .page-content .form-select { min-height:40px; }
    .admin-responsive-table > table { min-width:720px; }
    .admin-responsive-actions .btn { flex:0 0 auto; }
}

@media (max-width:575px) {
    .page-content { padding-left:8px !important; padding-right:8px !important; }
    .page-content .card-body { padding:12px; }
    .page-content .d-flex.justify-content-between { align-items:flex-start !important; }
    .page-content .d-flex.justify-content-between > * { max-width:100%; }
    .page-content .btn { white-space:normal; }
    .admin-responsive-table { margin-right:-4px; width:calc(100% + 8px); }
    .admin-responsive-table > table { min-width:680px; }
}

/* Category page: on phones make action controls wrap cleanly. */
.admin-category-edit-form .btn { flex:0 0 auto; }

/* Product form: prevent long controls from forcing horizontal overflow. */
.page-content form.row { min-width:0; }
.page-content textarea { resize:vertical; }
.page-content input[type="file"] { min-width:0; }

/* Focus visibility for keyboard/touch accessibility. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline:3px solid rgba(16,166,166,.35);
    outline-offset:2px;
}

/* Reduce accidental fixed-width overflow from legacy Bootstrap content. */
.container, .container-fluid, .row, [class*="col-"] { min-width:0; }

/* Final Shop dropdown polish: keep the desktop dropdown centered under Shop and
   keep it inside the viewport on narrower tablets. */
@media (min-width:992px) {
    .ki-shop-dropdown {
        max-height:min(70vh,520px);
        overflow-y:auto;
        overflow-x:hidden;
        scrollbar-width:thin;
    }
}
@media (min-width:992px) and (max-width:1199px) {
    .ki-shop-dropdown {
        min-width:250px;
        max-width:calc(100vw - 24px);
    }
}
@media (max-width:991px) {
    .ki-shop-dropdown .ki-shop-category-heading {
        padding:11px 15px 8px;
    }
}
