/* =====================================================================
   MBUY CUSTOM CSS  — safe, organized, and easy to maintain
   Last updated: 2025-09-27
   ---------------------------------------------------------------------
   Notes:
   - Keep all custom CSS in this file (not in Elementor pages/snippets).
   - Group rules by section. New rules go in the right section.
   - Use the color variables below so future changes are 1-line edits.
   ===================================================================== */

/* ===== Variables (brand colors) ===== */
:root{
  --mbuy-orange: #f97316;   /* brand orange */
  --mbuy-red:    #e11d2a;   /* price red */
  --mbuy-white:  #ffffff;
  --mbuy-gray-200: #e5e7eb;
}

/* ===== Global / Utilities ===== */
/* (add site-wide tweaks here) */

/* ===== Header / Menu / Search ===== */
/* (header/search bar styles live here) */


/* ===== Catalog / Archive / Search pages ===== */
/* Hide the big "Shop" title on Woo search results only */
body.search .woocommerce-products-header{
  display:none;
}


/* ===== WooCommerce: Product cards / lists ===== */
/* (styles for shop/archive product cards if needed) */


/* ===== WooCommerce: Single Product ===== */
/* Price color + weight */
.woocommerce div.product p.price,
.woocommerce div.product span.price{
  color:var(--mbuy-red);
  font-weight:700;
}

/* Seller box look (Elementor/Dokan widgets on product page) */
.mbuy-seller-box,
.elementor-widget-dokan-single-product-seller,
.elementor-widget .dokan-store-info{
  border:1px solid var(--mbuy-gray-200);
  padding:14px;
  border-radius:10px;
  background:var(--mbuy-white);
}


/* ===== Dokan (Vendor dashboard / forms / buttons) ===== */
/* Brand the main Dokan action buttons */
.dokan-dashboard .dokan-dashboard-content .dokan-btn-theme,
.dokan-dashboard .dokan-dashboard-content .button{
  background-color:var(--mbuy-orange) !important;
  color:var(--mbuy-white) !important;
  border:none !important;
}
.dokan-dashboard .dokan-dashboard-content .dokan-btn-theme:hover,
.dokan-dashboard .dokan-dashboard-content .button:hover{
  filter:brightness(0.95);
}

/* Dokan: vendor identity banner — cleaner card */
.mbuy-whoami{
  display:flex; align-items:center; gap:14px;
  padding:12px 16px; margin:0 0 18px;
  background:#fff;
  border:1px solid var(--mbuy-gray-200);
  border-radius:12px;
  box-shadow:0 2px 6px rgba(0,0,0,.06);
}
.mbuy-whoami-ava img{
  width:48px; height:48px; border-radius:9999px;
  box-shadow:0 0 0 2px #fff, 0 0 0 4px rgba(0,0,0,.04);
}
.mbuy-whoami-text{ line-height:1.25; }
.mbuy-whoami-text strong{ font-size:16px; }
.mbuy-whoami-text .mbuy-username{
  color:#6b7280; font-size:13px; margin-left:6px; padding:2px 6px;
  border:1px solid var(--mbuy-gray-200); border-radius:9999px;
  background:#f9fafb;
}
.mbuy-whoami-text a{ font-size:13px; text-decoration:none; margin-left:8px; }
.mbuy-whoami-text a:hover{ text-decoration:underline; }

/* ===== Footer ===== */
/* (footer tweaks here) */


/* ===== Mobile tweaks (phones, <= 767px) ===== */
@media (max-width:767px){

  /* Smaller breadcrumbs & product title */
  .woocommerce-breadcrumb{font-size:12px; opacity:.85}
  .single-product .product_title{font-size:22px; line-height:1.2}

  /* Gallery thumbs: flex + scroll if overflow */
  .woocommerce-product-gallery__wrapper{overflow:hidden}
  .flex-control-nav.flex-control-thumbs{
    display:flex; gap:8px; overflow:auto;
  }
}


/* Dokan: simple identity line */
.mbuy-who-line{
  margin: 6px 0 14px;
  font-size:14px;
  color:#374151;
}
.mbuy-who-line .muted{
  color:#6b7280;
  font-size:13px;
  margin-left:6px;
}

/* Dokan: nicer "Logged in as" line */
.mbuy-who-line{
  margin: 6px 0 14px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--mbuy-gray-200);
  border-radius: 10px;
  font-size: 14px;
  color: #111827;
}
.mbuy-who-line strong{ font-weight: 600; }
.mbuy-who-line .muted{
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 12px;
  color: #374151;
  background: #f3f4f6;
  border: 1px solid var(--mbuy-gray-200);
  border-radius: 999px;
}

/* === Mbuy: Similar items grid (same category, other vendors) === */
.mbuy-related-by-category { margin-top: 24px; }
.mbuy-related-by-category h3 { margin: 0 0 12px; font-size: 20px; }

.mbuy-related-by-category ul.products.columns-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* Desktop */
  gap: 14px;
  margin: 0;
  padding: 0;
}

.mbuy-related-by-category ul.products.columns-4 li.product {
  width: auto !important;
  margin: 0 !important;
  list-style: none;
}

@media (max-width: 1024px) {
  .mbuy-related-by-category ul.products.columns-4 {
    grid-template-columns: repeat(3, 1fr); /* Tablet */
  }
}

@media (max-width: 767px) {
  .mbuy-related-by-category ul.products.columns-4 {
    grid-template-columns: repeat(2, 1fr); /* Mobile → 2 × 4 */
    gap: 10px;
  }
  .mbuy-related-by-category h3 {
    font-size: 16px;
    margin: 12px 0;
  }
}

.mbuy-related-by-category li.product img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 767px){
  .mbuy-related-by-category li.product .woocommerce-loop-product__title{
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.25;
  }
}


.mbuy-who-line{ background:#fffbcc !important; border:2px solid #f59e0b !important; }

/* === Mbuy: Similar items grid (same category, other vendors) — FORCE GRID === */
.mbuy-related-by-category { margin-top: 24px; }
.mbuy-related-by-category h3 { margin: 0 0 12px; font-size: 20px; }

/* Force the UL to be a grid, override theme flex/float rules */
.mbuy-related-by-category ul.products.columns-4 {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none;
}

/* Neutralize theme floats/margins on product cards */
.mbuy-related-by-category ul.products.columns-4 > li.product {
  float: none !important;
  clear: none !important;
  width: auto !important;
  margin: 0 !important;
  list-style: none !important;
  box-sizing: border-box;
}

/* Tablet: 3 columns */
@media (max-width: 1024px) {
  .mbuy-related-by-category ul.products.columns-4 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* Mobile: 2 columns → 8 items = 2 x 4 */
@media (max-width: 767px) {
  .mbuy-related-by-category ul.products.columns-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .mbuy-related-by-category h3 {
    font-size: 16px;
    margin: 12px 0;
  }
}

/* Keep images tidy */
.mbuy-related-by-category li.product img {
  width: 100%;
  height: auto;
  display: block;
}

/* Clamp long titles on mobile */
@media (max-width: 767px){
  .mbuy-related-by-category li.product .woocommerce-loop-product__title{
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.25;
  }
}

/* Make "More from this seller" tab pop */
.woocommerce-tabs ul.tabs li.more_seller_product_tab a {
  background:#f97316; color:#fff !important; font-weight:600;
  padding:8px 14px; border-radius:6px;
}
.woocommerce-tabs ul.tabs li.more_seller_product_tab.active a,
.woocommerce-tabs ul.tabs li.more_seller_product_tab a:hover {
  background:#ea580c; color:#fff !important;
}

/* If your theme draws triangle notches on tabs, hide them for this one */
.woocommerce-tabs ul.tabs li.more_seller_product_tab:before,
.woocommerce-tabs ul.tabs li.more_seller_product_tab:after { display:none !important; }


/* MBUY: space for vendor identity above the menu */
.dokan-dash-sidebar .mbuy-vendor-identity {
  display:block;
  padding:12px 16px;
  margin-bottom:12px; /* space below name */
  color:#fff;
  border-bottom:1px solid rgba(255,255,255,.15);
}

/* Make sure menu doesn't overlap */
.dokan-dash-sidebar .dokan-dashboard-menu {
  margin-top:0;
  padding-top:0;
}

/* MBUY: identity row inside the menu */
.dokan-dashboard-menu .mbuy-vendor-identity-li{
  list-style:none;
  padding:12px 16px;
  margin:0 0 8px 0;
  color:#fff;
  border-bottom:1px solid rgba(255,255,255,.15);
}

/* Ensure the first real menu item sits nicely below */
.dokan-dashboard-menu > li:first-child.mbuy-vendor-identity-li + li > a{
  margin-top:0;
}

/* MBUY — hide Brand & Tags fields on Dokan vendor product form */
.dokan-dashboard .dokan-product-edit-form .dokan-form-group:has(label[for="product_brand"]),
.dokan-dashboard .dokan-product-edit-form .dokan-form-group:has(label[for="product_tag"]),
.dokan-dashboard .dokan-product-edit-form .dokan-form-group:has(label:contains("Brand")),
.dokan-dashboard .dokan-product-edit-form .dokan-form-group:has(label:contains("Tags")) {
  display: none !important;
}

/* MBUY — hide Brand & Tags fields on Dokan vendor product form */
.dokan-dashboard .dokan-product-edit-form .dokan-form-group:has(label[for="product_brand"]),
.dokan-dashboard .dokan-product-edit-form .dokan-form-group:has(label[for="product_tag"]),
.dokan-dashboard .dokan-product-edit-form .dokan-form-group:has(label:contains("Brand")),
.dokan-dashboard .dokan-product-edit-form .dokan-form-group:has(label:contains("Tags")) {
  display: none !important;
}

/* MBUY — tighten vertical gaps on vendor form */
.dokan-dashboard .dokan-product-edit-form .dokan-form-group { margin-bottom: 14px; }
.dokan-dashboard .dokan-product-edit-form .dokan-form-group label { margin-bottom: 6px; }

/* Remove any extra top spacing around the gallery/cover image blocks */
.dokan-dashboard .dokan-feat-image-upload,
.dokan-dashboard .dokan-product-gallery { margin-top: 8px; }

/* Ensure hidden (Brand/Tags) rows don't leave whitespace */
.dokan-dashboard .dokan-product-edit-form .dokan-form-group[style*="display: none"] { margin: 0 !important; padding: 0 !important; }


/* ensure each line stacks vertically */
.mbuy-seller-box { display: block; }
.mbuy-seller-line { display: block; margin: 6px 0; }

/* force the button to live on its own line below Phone */
.mbuy-seller-button { display: block; margin: 6px 0 10px !important; }

/* orange button */
.call-seller-btn {
  display: inline-block !important;
  padding: 8px 14px !important;
  background: #f97316 !important; /* mbuy orange */
  color: #fff !important;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
}
.call-seller-btn:hover { background: #e05d0f !important; }

.mbuy-seller-line{display:block;margin:6px 0}
.mbuy-seller-button{display:block;margin:6px 0 10px !important}
.mbuy-seller-block .call-seller-btn{
  display:inline-block !important;
  padding:8px 14px !important;
  background:#f97316 !important; /* mbuy orange */
  color:#fff !important;
  font-weight:700;
  border-radius:8px;
  text-decoration:none !important;
  border:none !important;
}
.mbuy-seller-block .call-seller-btn:hover{background:#e05d0f !important}

.mbuy-seller-line{display:block;margin:6px 0}
.mbuy-seller-button{display:block;margin:6px 0 10px !important}
.mbuy-seller-block .call-seller-btn{
  display:inline-block !important;padding:8px 14px !important;
  background:#f97316 !important;color:#fff !important;
  font-weight:700;border-radius:8px;text-decoration:none !important;border:none !important;
}
.mbuy-seller-block .call-seller-btn:hover{background:#e05d0f !important}


/* ===== Dokan: nicer "Logged in as" line ===== */
.dokan-dashboard .mbuy-who-line{
  display:flex; align-items:center; gap:8px;
  margin:8px 0 16px; padding:10px 14px;
  background:#fff; border:1px solid #e5e7eb; border-radius:10px;
  font-size:14px; color:#111827;
  width:100%; max-width:100%; box-sizing:border-box;
}
.dokan-dashboard .mbuy-who-line strong{ font-weight:600; }
.dokan-dashboard .mbuy-who-line .muted,
.dokan-dashboard .mbuy-who-line .mbuy-user{
  display:inline-block; margin-left:8px; padding:2px 8px;
  font-size:12px; color:#374151; background:#f3f4f6;
  border:1px solid #e5e7eb; border-radius:999px;
}

/* Mbuy orange pill for @username */
.dokan-dashboard .mbuy-who-line .mbuy-user{
  background: var(--mbuy-orange, #f97316);
  border-color: var(--mbuy-orange, #f97316);
  color:#fff;
}

/* ===== Dokan: Mbuy-styled vendor sidebar ===== */
:root{
  /* DARK version (current) */
  --mbuy-side-bg:        #0F172A;                /* sidebar background */
  --mbuy-side-text:      #e5e7eb;                /* item text */
  --mbuy-side-hover-bg:  rgba(249,115,22,.15);   /* hover tint */
  --mbuy-side-active-bg: #f97316;                /* active item (mbuy orange) */
  --mbuy-side-active-tx: #ffffff;                /* active item text */
  /* LIGHT version (optional):
  --mbuy-side-bg:#ffffff; --mbuy-side-text:#111827;
  --mbuy-side-hover-bg:rgba(17,24,39,.06);
  --mbuy-side-active-bg:#f97316; --mbuy-side-active-tx:#ffffff;
  */
}
.dokan-dashboard .dokan-dash-sidebar,
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu{
  background: var(--mbuy-side-bg) !important;
  border-radius:12px !important;
  overflow: visible !important; /* keep mobile menu usable */
}
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu li,
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu li a{
  background:transparent !important;
  color:var(--mbuy-side-text) !important;
  padding:12px 16px !important;
}
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu li a:hover{
  background:var(--mbuy-side-hover-bg) !important;
  color:#fff !important;
}
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu li.active,
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu li.active > a{
  background:var(--mbuy-side-active-bg) !important;
  color:var(--mbuy-side-active-tx) !important;
}
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu li a i,
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu li.active > a i{
  color:inherit !important;
}
.dokan-dashboard .dokan-dash-sidebar:before,
.dokan-dashboard .dokan-dash-sidebar:after{ background:transparent !important; }
.dokan-dashboard .dokan-dash-sidebar .dokan-dashboard-menu li{ border:0 !important; }

/* ===== Larger Price & Quantity inputs on Dokan forms ===== */
#mbuy_regular_price.dokan-form-control,
#mbuy_qty.dokan-form-control{
  width:100% !important;
  max-width:520px !important;
  height:48px !important;
  font-size:20px !important;
  font-weight:600 !important;
  padding:10px 12px !important;
  box-sizing:border-box;
}

/* Optional: hide the tiny number spinners so it looks cleaner */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button{ -webkit-appearance: none; margin:0; }
input[type=number]{ -moz-appearance:textfield; }

/* ===== Seller box styles ===== */
.mbuy-seller-link{ font-weight:600; text-decoration:none; }
.mbuy-seller-link:hover{ text-decoration:underline; }

.mbuy-seller-block{
  font-size:16px; line-height:1.6;
  padding:14px 16px; border-radius:12px; background:#fff;
}
.mbuy-seller-block strong{
  display:inline-block; min-width:110px; font-weight:700; color:#111 !important; font-size:16px !important;
}
@media (max-width:600px){
  .mbuy-seller-block{ font-size:15px; padding:12px 14px; }
}
.mbuy-seller-line{ display:block; margin:6px 0; }
.mbuy-seller-button{ display:block; margin:10px 0 4px !important; }
.call-seller-btn{
  display:inline-block !important; padding:8px 14px !important;
  background:#f97316 !important; color:#fff !important;
  font-weight:700; border-radius:8px; text-decoration:none;
}
.call-seller-btn:hover{ background:#e05d0f !important; }
.mbuy-seller-block br{ display:block; content:""; margin:8px 0; }

/* ===== Hide theme/builder price ONLY on single product pages ===== */
.single-product .summary .price,
.single-product .product .summary .price,
.single-product .entry-summary .price,
.single-product .elementor-widget-woocommerce-product-price{
  display:none !important;
}

/* ===== Hide Short Description on Dokan vendor product form ===== */
.dokan-dashboard label[for="post_excerpt"],
.dokan-dashboard #wp-post_excerpt-wrap,
.dokan-dashboard #post_excerpt{ display:none !important; }

/* ===== Hide Woo password strength meter + hint ===== */
.woocommerce-password-strength,
.woocommerce-password-hint,
.woocommerce-form-row .password-input + small.description{
  display:none !important;
}

/* ===== Hide the "I am a customer" option (fallback CSS) ===== */
.dokan-form-group.user-role input[value="customer"],
.dokan-form-group.user-role label[for="role-customer"],
.dokan-form-group.user-role .role-customer{
  display:none !important;
}

/**
 * Mbuy: Force vendor role at registration and remove customer option.
 * Works even if the radio still renders due to cache/templates.
 */

// A) Tell Dokan not to render the customer register form at all
add_filter('dokan_show_customer_register_form', '__return_false');

// B) Hard-set the submitted role to 'seller' before Woo/Dokan process it
add_action('woocommerce_register_post', function($username, $email, $errors){
    $_POST['role'] = 'seller';
}, 1, 3);

// C) After user is created, ensure vendor capabilities are enabled
add_action('user_register', function($user_id){
    // Mark as vendor (Dokan)
    update_user_meta($user_id, 'dokan_enable_selling', 'yes');

    // If the site requires manual approval, leave this; otherwise optionally ensure 'seller' role:
    $user = get_user_by('id', $user_id);
    if ( $user && ! in_array('seller', (array) $user->roles, true) ) {
        $user->add_role('seller'); // adds seller role in addition to 'customer' if any
    }
}, 10);


/* Mbuy: hide role chooser completely */
.dokan-form-group.user-role { display: none !important; }


.mbuy-toggle{
  display:inline-block;padding:6px 12px;font-size:13px;line-height:1.2;
  border-radius:8px;border:1px solid rgba(0,0,0,.12);background:#fff;cursor:pointer;
  transition:opacity .2s ease, transform .02s ease
}
.mbuy-toggle:hover{opacity:.9}
.mbuy-toggle.is-busy{opacity:.6;pointer-events:none}
tr:not(.mbuy-disabled-row) .mbuy-toggle{border-color:#f97316;color:#f97316} /* active -> Disable */
.mbuy-disabled-row .mbuy-toggle{border-color:#666;color:#666}               /* disabled -> Enable */
.mbuy-disabled-row{opacity:.55}
.mbuy-disabled-row a{opacity:1}


.mbuy-toggle{
  display:inline-block;padding:6px 12px;font-size:13px;line-height:1.2;
  border-radius:8px;border:1px solid rgba(0,0,0,.12);background:#fff;cursor:pointer;
  transition:opacity .2s ease, transform .02s ease
}
.mbuy-toggle:hover{opacity:.9}
.mbuy-toggle.is-busy{opacity:.6;pointer-events:none}
tr:not(.mbuy-disabled-row) .mbuy-toggle{border-color:#f97316;color:#f97316}
.mbuy-disabled-row .mbuy-toggle{border-color:#666;color:#666}
.mbuy-disabled-row{opacity:.55}
.mbuy-disabled-row a{opacity:1}
