/* ============================================================
   ALIEXPRESS MOBILE REDESIGN
   Visi stili ir @media (max-width: 767px) — desktop nav skarts
   ============================================================ */

/* Visi jaunie elementi slēpti uz desktop */
#mobile-bottom-nav,
#mobile-product-bar,
#mobile-cart-bar,
#mobile-confirm-bar,
#mobile-product-header {
  display: none;
}

/* Checkout error toast — hidden until .is-visible is added by JS */
#mobile-checkout-toast {
  display: none;
  position: fixed;
  z-index: 1055;
  left: 10px;
  right: 10px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: #991b1b;
  align-items: flex-start;
  gap: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  line-height: 1.4;
}
#mobile-checkout-toast.is-visible {
  display: flex;
}
#mobile-checkout-toast-text {
  flex: 1;
}
#mobile-checkout-toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #991b1b;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  margin-top: -1px;
}

@media (max-width: 767px) {
  #mobile-checkout-toast {
    bottom: 124px; /* above confirm bar (56px) + bottom nav (60px) + 8px gap */
  }
}

/* -------- MOBILE ONLY -------- */
@media (max-width: 767px) {

  /* ===================================================
     GLOBAL — body, header, footer
     =================================================== */

  /* Vieta fiksētajam apakšas navigātoram */
  body {
    padding-bottom: 60px !important;
  }

  /* Paslēpt ciprime #top joslu (valūta, valoda, kontakti) uz mobile */
  #top.ciprime_top {
    display: none !important;
  }

  /* Paslēpt tradicionālo footer saturu uz mobile */
  footer > .container {
    display: none !important;
  }
  footer {
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    border: none !important;
  }

  /* ===================================================
     SEARCH BAR — AliExpress stils: noapaļoti stūri
     =================================================== */
  .ciprime_search .form-control-lg {
    border-radius: 20px 0 0 20px !important;
    border-right: none !important;
    height: 40px !important;
    font-size: 14px !important;
    padding: 0 14px !important;
  }
  .ciprime_search .btn-lg {
    border-radius: 0 20px 20px 0 !important;
    height: 40px !important;
    padding: 0 14px !important;
    font-size: 16px !important;
    background: #e52e2e !important;
    border-color: #e52e2e !important;
    color: #fff !important;
    text-shadow: none !important;
  }
  .ciprime_search .btn-lg:hover,
  .ciprime_search .btn-lg:focus {
    background: #c82020 !important;
    border-color: #c82020 !important;
  }

  /* ===================================================
     GLOBAL BOTTOM NAVIGATION BAR
     =================================================== */
  #mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    z-index: 1050;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.10);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    color: #888 !important;
    font-size: 10px;
    gap: 2px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
    min-width: 0;
  }
  .mobile-nav-item i {
    font-size: 20px;
    line-height: 1;
  }
  .mobile-nav-item > span:not(.mobile-cart-badge) {
    font-size: 10px;
    line-height: 1.1;
    white-space: nowrap;
  }
  .mobile-nav-item.active {
    color: #e52e2e !important;
  }
  .mobile-nav-item:hover,
  .mobile-nav-item:active {
    color: #e52e2e !important;
  }

  /* Cart badge */
  .mobile-cart-badge {
    position: absolute;
    top: 4px;
    left: calc(50% + 2px);
    background: #e52e2e;
    color: #fff !important;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    pointer-events: none;
  }

  /* ===================================================
     KATEGORIJAS LAPA — slēpt description
     =================================================== */
  #product-category #content h1 + .row {
    display: none !important;
  }
  #product-category #content > p:first-of-type {
    display: none !important;
  }

  /* ===================================================
     PRODUKTA LAPA — slēpt bottom nav, rādīt product bar
     =================================================== */
  body:has(#product-info) #mobile-bottom-nav {
    display: none !important;
  }
  body:has(#product-info) {
    padding-bottom: 60px !important;
  }

  /* Slēpt oriģinālo qty + cart button input grupu (pārcelts uz mobile bar) */
  #product-info #content .input-group:has(#button-cart) {
    display: none !important;
  }
  /* Fallback vecākiem browser */
  #product-info .mb-3 > .input-group {
    display: none !important;
  }

  /* ===================================================
     PRODUCT ACTION BAR (Add to Cart + Buy Now)
     =================================================== */
  #mobile-product-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 56px !important;
    background: #fff !important;
    border-top: 1px solid #e5e7eb;
    z-index: 1050 !important;
    padding: 8px 10px;
    gap: 8px;
    align-items: center;
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.08);
  }

  /* Qty selector: [ - 1 + ] */
  .mobile-qty-selector {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    height: 40px;
  }
  .mobile-qty-btn {
    width: 32px;
    height: 40px;
    background: #f3f4f6;
    border: none;
    font-size: 18px;
    font-weight: 400;
    color: #222;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-qty-btn:active {
    background: #e5e7eb;
  }
  .mobile-qty-input {
    width: 36px;
    height: 40px;
    border: none;
    border-left: 1.5px solid #d1d5db;
    border-right: 1.5px solid #d1d5db;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #111;
    background: #fff;
    -moz-appearance: textfield;
    padding: 0;
  }
  .mobile-qty-input::-webkit-outer-spin-button,
  .mobile-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
  }

  .mobile-product-addtocart {
    flex: 1;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: #1a1a1a;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    padding: 0 8px;
    transition: background 0.15s;
  }
  .mobile-product-addtocart:active {
    background: #333;
  }
  .mobile-product-addtocart:disabled {
    opacity: 0.7;
    cursor: default;
  }

  .mobile-product-buynow {
    flex: 1;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: #005e9f;
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    padding: 0 8px;
    transition: background 0.15s;
  }
  .mobile-product-buynow:active {
    background: #004d82;
  }
  .mobile-product-buynow:disabled {
    opacity: 0.7;
    cursor: default;
  }

  /* ===================================================
     GROZA LAPA — papildu padding + slēpt orig. pogas
     =================================================== */
  body:has(#checkout-cart) {
    padding-bottom: 120px !important;
  }

  /* Slēpt oriģinālās "Continue shopping" un "Checkout" pogas rindu */
  #checkout-cart #content .row:has(a.btn-light, a.btn-primary) {
    display: none !important;
  }
  /* Fallback */
  #output-cart ~ br,
  #output-cart ~ .row:last-child {
    display: none !important;
  }

  /* ===================================================
     CART ACTION BAR (Total + Checkout)
     =================================================== */
  #mobile-cart-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 60px !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 56px !important;
    background: #fff !important;
    border-top: 1px solid #e5e7eb;
    z-index: 1045 !important;
    padding: 8px 16px;
    gap: 12px;
    align-items: center;
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.08);
  }

  .mobile-cart-total {
    flex: 1;
    font-size: 12px;
    color: #555;
    line-height: 1.3;
    min-width: 0;
    overflow: hidden;
  }
  .mobile-cart-total strong {
    color: #e52e2e;
    font-size: 15px;
    font-weight: 700;
    display: block;
  }

  .mobile-cart-checkout {
    flex: 0 0 auto;
    padding: 10px 20px;
    background: #005e9f;
    color: #fff !important;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none !important;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
  }
  .mobile-cart-checkout:active {
    background: #004d82;
    color: #fff !important;
  }

  /* ===================================================
     CHECKOUT LAPA
     =================================================== */

  /* Extra bottom padding on checkout page (nav 60px + confirm bar 56px) */
  body:has(#checkout-checkout) {
    padding-bottom: 120px !important;
  }

  /* Confirm Order bar — fixed above bottom nav */
  #mobile-confirm-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 60px !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 56px !important;
    background: #fff !important;
    border-top: 1px solid #e5e7eb;
    z-index: 1045 !important;
    padding: 8px 16px;
    gap: 12px;
    align-items: center;
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.08);
  }
  .mobile-confirm-total {
    flex: 1;
    font-size: 12px;
    color: #555;
    line-height: 1.3;
    min-width: 0;
    overflow: hidden;
  }
  .mobile-confirm-total strong {
    color: #005e9f;
    font-size: 15px;
    font-weight: 700;
    display: block;
  }
  .mobile-confirm-btn {
    flex: 0 0 auto;
    padding: 10px 20px;
    background: #005e9f;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
  }
  .mobile-confirm-btn:active {
    background: #004d82;
  }
  .mobile-confirm-btn:disabled {
    opacity: 0.7;
    cursor: default;
  }

  /* Sticky header — scoped to checkout only */
  body:has(#checkout-checkout) .headerFixed {
    position: fixed !important;
    top: 0 !important;
    z-index: 1060 !important;
  }

  /* Step circles — bigger */
  #checkout-checkout .step-number {
    flex-shrink: 0;
    width: 36px !important;
    height: 36px !important;
    font-size: 17px !important;
    margin-right: 14px !important;
  }

  /* Step titles */
  #checkout-checkout .checkout-step h2 {
    font-size: 1.25rem !important;
  }

  /* Step row spacing */
  #checkout-checkout .checkout-step {
    margin-top: 32px !important;
    margin-bottom: 16px !important;
  }

  /* Form inputs — 44px touch target + prevent iOS zoom-on-focus */
  #checkout-checkout .form-control,
  #checkout-checkout .form-select {
    min-height: 44px !important;
    font-size: 16px !important;
    padding: 10px 12px !important;
  }

  /* Buttons — 44px touch target */
  #checkout-checkout .btn {
    min-height: 44px !important;
    font-size: 15px !important;
    padding: 10px 18px !important;
  }

  /* Form labels */
  #checkout-checkout .form-label {
    font-size: 14px !important;
    font-weight: 500 !important;
    margin-bottom: 6px !important;
  }

  /* Radio/checkbox — bigger tap area */
  #checkout-checkout .form-check {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }
  #checkout-checkout .form-check-input {
    width: 20px !important;
    height: 20px !important;
    margin-top: 2px !important;
  }
  #checkout-checkout .form-check-label {
    font-size: 15px !important;
    padding-left: 8px !important;
  }

  /* ===================================================
     CATEGORY MENU — lielāki tap targets mobilajam skatam
     =================================================== */

  /* Top-level category links (Engine, Electronics, …) */
  #menu .navbar-nav > li > a {
    font-size: 17px !important;
    min-height: 48px !important;
    padding: 13px 15px !important;
    display: flex !important;
    align-items: center !important;
  }

  /* Chevron — float doesn't work inside flex; push to right edge instead */
  #menu .navbar-nav .dropdown-toggle::after {
    float: none !important;
    margin-left: auto !important;
    font-size: 15px !important;
    line-height: 1 !important;
    flex-shrink: 0;
  }

  /* Sub-items inside expanded dropdowns */
  #menu .dropdown-menu .dropdown-item {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 12px 16px !important;
    display: flex !important;
    align-items: center !important;
    white-space: normal !important;
    line-height: 1.3 !important;
  }

  /* Dropdown panel — a bit more room top/bottom */
  #menu .dropdown-menu {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }

  /* ===================================================
     WHATSAPP FLOATING BUTTON — pārvietot virs fixed bar
     =================================================== */
  .whatsapp_chat-wrapper a {
    bottom: 70px !important;
    right: 10px !important;
  }
  body:has(#checkout-cart) .whatsapp_chat-wrapper a {
    bottom: 130px !important;
  }
  .show_whatsapp {
    bottom: 195px !important;
    right: 10px !important;
  }
  body:has(#checkout-cart) .show_whatsapp {
    bottom: 255px !important;
  }

  /* ============================================================
     PRODUCT PAGE COMPACT HEADER (AliExpress-style)
     Shown ONLY on mobile product pages via body:has(#product-info)
     ============================================================ */

  /* Show our bar, hide ciprime's full header visual layer */
  body:has(#product-info) #mobile-product-header {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 48px !important;
    background: #fff !important;
    border-bottom: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08) !important;
    z-index: 1061 !important;
    align-items: center !important;
    padding: 0 4px !important;
    gap: 0 !important;
  }

  /* Override ciprime's JS-set spacer so content starts below our 48px bar */
  body:has(#product-info) .spacer {
    height: 48px !important;
  }

  /* Fix headerFixed below our bar so #navbar-menu stays accessible when scrolling */
  body:has(#product-info) .headerFixed {
    position: fixed !important;
    top: 48px !important;
    left: 0 !important;
    right: 0 !important;
    height: 0 !important;
    overflow: visible !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    z-index: 1058 !important;
  }

  /* Hide the visual header row (logo / search / cart) — already hidden globally, belt+braces */
  body:has(#product-info) header.ciprime_header {
    display: none !important;
  }

  /* Collapse the menu bar row to zero height, keep DOM for dropdown */
  body:has(#product-info) .menuCi,
  body:has(#product-info) #menu {
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    visibility: hidden !important;
  }

  /* Dropdown opens right at the top of .headerFixed (which is at viewport y=48) */
  body:has(#product-info) #navbar-menu.show {
    visibility: visible !important;
    top: 0 !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    border-top: 2px solid #005e9f !important;
    border-radius: 0 0 12px 12px !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15) !important;
  }

  /* Product page WhatsApp button — bump up to clear both our bar and bottom bar */
  body:has(#product-info) .whatsapp_chat-wrapper a {
    bottom: 72px !important;
  }

  /* ---- Product header element styles ---- */

  .mobile-ph-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #333;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    text-decoration: none !important;
    -webkit-tap-highlight-color: transparent;
    border-radius: 6px;
  }
  .mobile-ph-btn:active {
    background: #f3f4f6;
  }

  /* Logo — centred between hamburger and icons, grows to fill available space */
  .mobile-ph-logo {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-decoration: none !important;
    min-width: 0;
  }
  .mobile-ph-logo-img {
    max-height: 30px;
    max-width: 90px;
    object-fit: contain;
    display: block;
  }
  .mobile-ph-logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #005e9f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-ph-spacer {
    flex: 0;
    width: 0;
  }

  /* Cart icon with badge */
  .mobile-ph-cart-btn {
    position: relative;
  }
  .mobile-ph-cart-badge {
    display: none;
    position: absolute;
    top: 3px;
    right: 3px;
    background: #e52e2e;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
  }
  .mobile-ph-cart-badge:not(:empty) {
    display: flex;
  }

  /* Search overlay — covers full bar width when .is-open */
  #mobile-ph-search-overlay {
    display: flex;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #fff;
    padding: 0 6px;
    gap: 6px;
    z-index: 1;
    transform: translateY(-100%);
    transition: transform 0.2s ease;
    pointer-events: none;
  }
  #mobile-ph-search-overlay.is-open {
    transform: translateY(0);
    pointer-events: auto;
  }
  .mobile-ph-search-input {
    flex: 1;
    height: 34px;
    border: 1.5px solid #005e9f;
    border-radius: 17px;
    padding: 0 14px;
    font-size: 15px;
    outline: none;
    background: #f8fafc;
    min-width: 0;
  }
  .mobile-ph-search-submit {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: #005e9f;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

}
/* -------- END MOBILE -------- */
