/* ==========================================================================
   seller-mobile.css — Mobile / small-screen overhaul for the Seller dashboard
   --------------------------------------------------------------------------
   Loaded AFTER seller.css. EVERYTHING here is scoped to @media (max-width:1023px)
   (plus smaller breakpoints) so the desktop experience is never touched.

   Structure:
     1. SHELL          — mobile top bar, hamburger, overlay, drawer, global
                         container/overflow fixes (Phase 0).
     2. PER-SECTION    — one block per dashboard section (Phase 1), appended below.

   Desktop defaults (outside the media query): hide the mobile-only chrome.
   ========================================================================== */

.seller-mobile-topbar { display: none; }
.mobile-overlay { display: none; }

/* ==========================================================================
   1. SHELL  (<= 1023px)
   ========================================================================== */
@media (max-width: 1023px) {

  /* ---- Kill horizontal overflow site-wide -------------------------------
     Root cause: a 2nd `.content-container` rule (seller.css ~2069) sets
     `margin-left:270px; width:100%`, sourced AFTER the mobile reset, so on
     mobile every section was pushed 270px right and ran 270px past the
     viewport. Reset it here (loaded last) and clamp stray wide children. */
  html, body { overflow-x: hidden; max-width: 100%; }

  .content-container {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    padding: 14px 12px;
    padding-top: 70px;            /* clear the fixed mobile top bar (56px + gap) */
  }

  /* Defensive: nothing inside the content area may force the page wider */
  .content-container * { max-width: 100%; }
  .content-container img { height: auto; }

  /* ---- Mobile top bar ---------------------------------------------------- */
  .seller-mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    padding: 0 14px;
    background: linear-gradient(135deg, #E94B3C 0%, #DC2626 50%, #991b1b 100%);
    border-bottom: 3px solid rgba(245, 166, 35, 0.4);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    z-index: 1030;
    box-sizing: border-box;
  }
  .smt-title {
    font-family: 'Poppins', 'Inter', sans-serif;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: .5px;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    flex: 1 1 auto;
  }
  .smt-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    color: #fff;
    font-size: 18px;
    border-radius: 10px;
    text-decoration: none;
    transition: background .2s ease;
  }
  .smt-home:active { background: rgba(255, 255, 255, 0.18); }

  /* ---- Hamburger button (animates to X) ---------------------------------- */
  .smt-hamburger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px; height: 42px;
    padding: 9px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 10px;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }
  .smt-hamburger:active { background: rgba(255, 255, 255, 0.18); }
  .smt-hamburger span {
    display: block;
    width: 100%; height: 2.5px;
    background: #fff;
    border-radius: 2px;
    transition: transform .3s ease, opacity .2s ease;
  }
  .smt-hamburger.active span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
  .smt-hamburger.active span:nth-child(2) { opacity: 0; }
  .smt-hamburger.active span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

  /* ---- Backdrop behind the drawer --------------------------------------- */
  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
    z-index: 1040;
  }
  .mobile-overlay.active { opacity: 1; visibility: visible; }

  /* ---- Drawer sits above the backdrop ----------------------------------- */
  .sidebar { z-index: 1050; }

  /* ---- Modals override the whole mobile shell --------------------------- */
  /* The shell stacks top bar (1030) < backdrop (1040) < drawer (1050). A plain
     .modal is only z-index:1000, so confirm dialogs opened from the drawer (e.g.
     "Volver al Sitio") were rendered *behind* the hamburger menu. Lift every modal
     above the drawer so it always takes over the screen. */
  .modal { z-index: 1100; }

  /* Tap targets in the drawer: comfortable height on touch */
  .sidebar .main-category { padding: 15px 18px; font-size: 15.5px; }
  .sidebar .subcategories a { padding: 13px 18px; font-size: 14.5px; }
}

/* Tablet drawer width can be a touch wider */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar { width: 320px; }
}

/* ==========================================================================
   2. PER-SECTION  (<= 1023px)
   ========================================================================== */

/* === ORDERS & RETURNS === */
@media (max-width: 1023px) {

  /* ---------- MIS PEDIDOS (#my-orders) ---------- */

  /* Sticky status-tab bar must dock BELOW the 56px mobile topbar, not vanish
     under it (default desktop value is top:0). */
  #my-orders .modern-tabs-wrapper { top: 56px; }

  /* Stats: 2-up grid instead of one full-width card per row (saves height). */
  #my-orders .order-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  #my-orders .order-stat-card { padding: 14px; gap: 10px; }
  #my-orders .stat-icon { width: 42px; height: 42px; font-size: 17px; }
  #my-orders .stat-content h3 { font-size: 22px; }
  #my-orders .stat-content p { font-size: 12.5px; }

  /* Order card: kill the doubled outer padding (card 20px + header/body 16px).
     This also stops the 4-step progress row clipping "Entregado". */
  #my-orders .order-card { padding: 0; }

  #my-orders .order-card-header { align-items: center; gap: 10px; padding: 14px 16px; }
  /* Number on its own line, date beneath it — no more squished side-by-side. */
  #my-orders .order-card-header-left { flex-direction: column; align-items: flex-start; gap: 3px; }
  #my-orders .order-date-time { font-size: 13px; }

  /* Body is already a single-column grid; just tighten the gap. */
  #my-orders .order-card-body { gap: 14px; }

  /* Footer actions: full-width stacked buttons, >=44px tap targets. */
  #my-orders .order-card-footer { display: block; padding: 0; border-top: none; }
  #my-orders .order-card-actions { flex-direction: column; gap: 8px; padding: 12px 16px; }
  #my-orders .order-card-actions .standard-button {
    width: 100%; min-height: 44px; justify-content: center; font-size: 14px;
  }

  /* ---------- DEVOLUCIONES (#return-refund) ---------- */

  /* Search input: drop the 300px min so it fits narrow screens. */
  #return-refund .return-search-input { min-width: 0; width: 100%; }

  /* Filter tabs wrap with comfortable tap height. */
  #return-refund .return-filter-tab { min-height: 40px; font-size: 13.5px; }

  /* Card header/summary stack (extend the existing 768 behaviour up to 1023). */
  #return-refund .return-card-header { padding: 16px; gap: 14px; }
  #return-refund .return-card-main { flex-direction: column; align-items: flex-start; gap: 14px; }
  #return-refund .return-product-info { width: 100%; min-width: 0; }
  #return-refund .return-card-summary { width: 100%; justify-content: space-between; }
  #return-refund .return-details-grid { grid-template-columns: 1fr; gap: 16px; }
  #return-refund .return-card-actions { flex-direction: column; }
  #return-refund .return-card-actions button { width: 100%; min-height: 44px; }
}

@media (max-width: 479px) {
  #my-orders .order-item-image { width: 64px; height: 64px; }
  #my-orders .order-item-name { font-size: 14px; }
  #my-orders .order-card-actions .standard-button { font-size: 13.5px; }
  #return-refund .return-product-image { width: 56px; height: 56px; }
  #return-refund .return-amount { font-size: 17px; }
}

/* === ADD-PRODUCT WIZARD / BULK IMPORT === */
@media (max-width: 1023px) {

  /* ---- Wizard: kill iOS zoom + guarantee 44px+ touch targets ----------- */
  /* product-wizard.css only bumps inputs to 16px at <=640px, so on the
     641-1023 band (tablets / large phones) they stay 15px and iOS zooms.   */
  #add-new-product .wizard-input,
  #add-new-product .wizard-select,
  #add-new-product .wizard-textarea {
    font-size: 16px !important;
  }
  #add-new-product .wizard-input,
  #add-new-product .wizard-select {
    min-height: 48px;
  }

  /* Nav / action buttons: comfortable tap height across the whole range */
  #add-new-product .wizard-btn,
  #add-new-product .wizard-upload-btn,
  #add-new-product .wizard-btn-add-variation,
  #add-new-product .variation-remove-btn {
    min-height: 46px;
  }

  /* Image thumbnails sized for touch (preview grid id used by the live JS) */
  #add-new-product #product-image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 12px;
    width: 100%;
  }
  #add-new-product #product-image-preview-container img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
  }

  /* ---- Bulk import: comfortable tap heights ----------------------------- */
  #bulk-import .bi-download-btn,
  #bulk-import .bi-btn-pick,
  #bulk-import .bi-btn-import,
  #bulk-import .bi-btn-change {
    min-height: 44px;
  }
  /* Preview table is wide (8 cols): keep it scrolling inside its wrapper,
     never let it stretch the page. (wrapper already has overflow-x:auto). */
  #bulk-import .bi-table-wrap { max-width: 100%; }
  #bulk-import .bi-preview-table { min-width: 560px; }
}

@media (max-width: 479px) {

  /* Step indicator: let the 3 step labels breathe / wrap, never overflow */
  #add-new-product .step-label {
    font-size: 10.5px;
    max-width: 72px;
    white-space: normal;
    line-height: 1.15;
  }

  /* Availability cards are inline-styled side-by-side (flex:1 each); stack
     them so each gets full width + a real tap area on small phones */
  #add-new-product #availability-cards {
    flex-direction: column;
  }

  /* Made-to-order "days" row: let helper text wrap instead of squeezing */
  #add-new-product #mto-days-field > div {
    flex-wrap: wrap;
  }

  /* Bulk import buttons full-width on phones */
  #bulk-import .bi-download-zone .bi-download-btn,
  #bulk-import .bi-btn-import,
  #bulk-import .bi-btn-change,
  #bulk-import .bi-btn-pick {
    width: 100%;
    justify-content: center;
  }
}

/* === FINANCE / ANALYTICS === */
@media (max-width: 1023px) {

  /* ---------- MIS INGRESOS (#my-income) ---------- */
  #my-income .fp-hero-card { padding: 24px 22px; }
  #my-income .fp-hero-amount { font-size: 38px; letter-spacing: -1px; word-break: break-word; }
  #my-income .fp-hero-withdraw-btn {
    width: 100%; justify-content: center; min-height: 48px; font-size: 15px; margin-top: 14px;
  }
  #my-income .fp-sec-tile { padding: 16px 18px; }
  #my-income .fp-sec-val { font-size: 24px; }

  #my-income .fp-card-head { flex-direction: column; align-items: stretch; gap: 12px; }
  #my-income .fp-txn-filters {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 8px; padding-bottom: 4px;
  }
  #my-income .fp-txn-filters::-webkit-scrollbar { display: none; }
  #my-income .fp-filter { flex: 0 0 auto; }
  #my-income .fp-txn-row { padding: 14px 16px; gap: 12px; }
  #my-income .fp-txn-desc { font-size: 14px; }
  #my-income .fp-txn-amount { font-size: 16px; }
  #my-income .fp-load-more { width: 100%; }

  /* ---------- PAGOS (#payment-settings) ---------- */
  /* how-it-works: vertical stack on tablet too (matches phone) */
  #payment-settings .fp-how-it-works { flex-direction: column; align-items: flex-start; gap: 16px; }
  #payment-settings .fp-hiw-arrow { transform: rotate(90deg); align-self: flex-start; margin: 0 0 0 16px; }

  /* Balance stat cards: 2-up on tablet / large phone */
  #payment-settings .fp-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  #payment-settings .fp-stat-card { padding: 18px 16px; }
  #payment-settings .fp-stat-val { font-size: 24px; }
  #payment-settings .fp-stat-date { font-size: 16px; }

  /* Card head + full-width add button */
  #payment-settings .fp-card-head { flex-direction: column; align-items: stretch; gap: 12px; }
  #payment-settings .fp-add-btn { width: 100%; justify-content: center; min-height: 46px; }

  /* Bank method rows: stack info above full-width actions */
  #payment-settings .fp-method-row { flex-wrap: wrap; padding: 16px; gap: 12px; }
  #payment-settings .fp-method-info { flex: 1 1 100%; }
  #payment-settings .fp-method-actions { flex: 1 1 100%; flex-wrap: wrap; }
  #payment-settings .fp-action-btn { flex: 1 1 auto; min-height: 44px; text-align: center; }
  #payment-settings .fp-current-default-label { flex: 1 1 100%; }

  /* ---------- SHARED FINANCE MODALS (withdraw / add bank / delete) ---------- */
  .fp-overlay { padding: 14px; }
  .fp-modal, .fp-modal-sm { max-width: 100%; max-height: 94vh; }
  .fp-input, .fp-select { font-size: 16px; padding: 13px 14px; min-height: 48px; }
  .fp-field-row { grid-template-columns: 1fr; gap: 0; }
  .fp-modal-ft { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .fp-modal-ft .fp-btn-primary,
  .fp-modal-ft .fp-btn-ghost,
  .fp-modal-ft .fp-btn-danger {
    width: 100%; justify-content: center; min-height: 48px; font-size: 15px;
  }

  /* ---------- RENDIMIENTO (#business-insights) ---------- */
  #business-insights .bi2-header { flex-direction: column; align-items: stretch; gap: 14px; }
  #business-insights .bi2-period-btns { width: 100%; }
  #business-insights .bi2-period-btn { flex: 1 1 0; text-align: center; min-height: 42px; }

  #business-insights .bi2-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  #business-insights .bi2-kpi-card { padding: 16px; }
  #business-insights .bi2-kpi-value { font-size: 22px; }

  #business-insights .bi2-main-grid { grid-template-columns: 1fr; gap: 16px; }
  #business-insights .bi2-card { padding: 16px; }
  #business-insights .bi2-card canvas { max-width: 100%; }
}

@media (max-width: 479px) {
  /* Single-column stat / KPI cards on small phones */
  #payment-settings .fp-stat-grid { grid-template-columns: 1fr; }
  #business-insights .bi2-kpi-grid { grid-template-columns: 1fr; }
}

/* === SETTINGS / SHIPPING / PROMOTIONS === */
@media (max-width: 1023px) {

  /* ---------- SHIPPING SETTINGS (#shipping-settings) ---------- */

  /* Summary cards: stack icon+body on a row, full-width Editar below */
  #shipping-settings .ss-sum-cards { grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
  #shipping-settings .ss-sum-card {
    flex-wrap: wrap;
    padding: 16px;
    row-gap: 12px;
  }
  #shipping-settings .ss-sum-card-body { flex: 1 1 auto; }
  #shipping-settings .ss-sum-edit-btn {
    flex: 1 1 100%;
    width: 100%;
    min-height: 44px;
    font-size: 14px;
    padding: 10px 14px;
    align-self: stretch;
    order: 3;
  }

  /* Header: let title + status wrap */
  #shipping-settings .ss-sum-header,
  #shipping-settings .ss-header { flex-wrap: wrap; gap: 6px; }

  /* Method grid: 2 columns on larger phones/tablets */
  #shipping-settings .ss-method-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Section card padding tighter */
  #shipping-settings .ss-section { padding: 16px; }

  /* Subsetting rows: stack label over input, input full width */
  #shipping-settings .ss-subsetting-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  #shipping-settings .ss-subsetting-row .ss-lempira-input { width: 100%; }

  /* Lempira / number inputs: 44px tall, 16px font (no iOS zoom) */
  #shipping-settings .ss-lempira-input { width: 100%; }
  #shipping-settings .ss-lempira-input input,
  #shipping-settings input[type="number"] {
    font-size: 16px;
    min-height: 44px;
    width: 100%;
    box-sizing: border-box;
  }
  /* small inline rate inputs (weight/zone rows) keep a sane fixed width */
  #shipping-settings .ss-lempira-sm { width: 120px; flex-shrink: 0; }
  #shipping-settings .ss-lempira-sm input { min-height: 44px; font-size: 16px; }

  /* Zone rows: wrap toggle + rate below the name */
  #shipping-settings .ss-zone-row { flex-wrap: wrap; gap: 10px; }
  #shipping-settings .ss-zone-info { flex: 1 1 100%; }

  /* Wizard nav buttons: full-width, tappable */
  #shipping-settings .ss-wiz-nav { flex-wrap: wrap; gap: 10px; }
  #shipping-settings .ss-wiz-next,
  #shipping-settings .ss-wiz-prev,
  #shipping-settings .ss-save-btn {
    min-height: 44px;
    font-size: 15px;
  }

  /* ---------- SHOP SETTINGS (#shop-settings) ---------- */

  #shop-settings .tab-container { margin-top: 14px; }

  /* Tab strip: even 3-up distribution, big tap targets, no clipping */
  #shop-settings .tab-menu {
    display: flex;
    overflow-x: visible;
    white-space: normal;
    padding-bottom: 0;
  }
  #shop-settings .tab-menu li {
    display: block;
    flex: 1 1 0;
    text-align: center;
    padding: 13px 8px;
    min-height: 46px;
    font-size: 14px;
    box-sizing: border-box;
  }

  #shop-settings .tab-content { padding: 16px 14px; }

  /* Inputs full width, 44px, 16px */
  #shop-settings .settings-user-info input,
  #shop-settings input[type="text"],
  #shop-settings input[type="password"] {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 4px;
  }

  /* Action buttons full width + tappable */
  #shop-settings .settings-button,
  #shop-settings .custom-file-upload {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin-top: 12px;
  }
  #shop-settings .custom-file-upload { text-align: center; }

  /* Avatar/banner previews shouldn't overflow */
  #shop-settings .shop-avatar { display: block; }
  #shop-settings .shop-banner { width: 100%; height: auto; }

  /* ---------- PROMOTIONS (#promotional) — light polish ---------- */

  /* Top create-action card: stack on phones */
  #promotional .promo-action-wide { flex-wrap: wrap; gap: 12px; }
  #promotional .promo-action-wide .action-btn-simple {
    width: 100%;
    min-height: 44px;
  }

  /* Discount card action buttons: ensure 44px tap targets */
  #promotional .discount-card-btn { min-height: 44px; }
}

@media (max-width: 479px) {
  /* Method grid single column on small phones */
  #shipping-settings .ss-method-grid { grid-template-columns: 1fr; }

  /* Small inline rate inputs go full width on tiny screens */
  #shipping-settings .ss-zone-row .ss-lempira-sm { width: 100%; }
}

/* === PRODUCTS / DRAFTS / VIOLATIONS === */
@media (max-width: 1023px) {

  /* ---------- MIS PRODUCTOS (#my-products) ---------- */
  /* products-latm.css forces .product-card-header height:280px !important on
     ALL widths — far too tall on a phone. Override with id-scoped !important. */
  #my-products .product-card-header { height: 200px !important; }
  #my-products .products-list-cards { grid-template-columns: 1fr !important; gap: 16px !important; }
  #my-products .product-card-body { padding: 16px; }
  #my-products .product-card-title-new { font-size: 16px; min-height: 0; }
  #my-products .product-card-meta-grid { padding: 14px; gap: 10px; margin-bottom: 14px; }
  #my-products .meta-value.price { font-size: 20px; }
  /* Action buttons: comfortable tap height; keep the 2-up split. */
  #my-products .btn-card-action { min-height: 46px; padding: 12px; font-size: 13.5px; }

  /* ---------- BORRADORES (#drafts) ---------- */
  /* The compact draft card classes ship essentially unstyled; give them a
     sensible full-width mobile layout (safe: desktop is unaffected). */
  #drafts .product-card-compact {
    display: flex; gap: 12px; align-items: flex-start;
    background: #fff; border: 1px solid #eef0f3; border-radius: 12px;
    padding: 14px; margin-bottom: 12px;
  }
  #drafts .product-image-compact {
    width: 64px; height: 64px; flex-shrink: 0;
    object-fit: cover; border-radius: 10px;
  }
  #drafts .product-main-info { flex: 1 1 auto; min-width: 0; }
  #drafts .product-name-compact { font-size: 15px; font-weight: 700; word-break: break-word; }
  #drafts .product-details-compact,
  #drafts .product-meta-compact { flex-wrap: wrap; gap: 6px 12px; }
  #drafts .product-actions-compact,
  #drafts .action-buttons-compact { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; margin-top: 10px; }
  #drafts .btn-action-compact { flex: 1 1 auto; min-height: 44px; justify-content: center; }

  /* ---------- INFRACCIONES (#product-violations) ---------- */
  /* 2-up stat cards were clipping their labels ("Sancionado", "Restauradas")
     because the flex content couldn't shrink. Let it shrink + wrap. */
  #product-violations .stat-elegant { padding: 14px; gap: 12px; }
  #product-violations .stat-elegant-icon { width: 40px; height: 40px; font-size: 17px; flex-shrink: 0; }
  #product-violations .stat-elegant-content { min-width: 0; }
  #product-violations .stat-elegant-value { font-size: 20px; }
  #product-violations .stat-elegant-label { font-size: 12px; white-space: normal; line-height: 1.2; }
  /* Filter chips + refresh fit and wrap */
  #product-violations .violations-filter-elegant { flex-wrap: wrap; gap: 8px; }
  #product-violations .violations-refresh-btn { min-height: 40px; }
  /* Violation row already stacks to 1col at <=768 via products-latm.css; just
     make sure the thumb + details don't overflow. */
  #product-violations .violation-elegant-thumb { width: 64px; height: 64px; object-fit: cover; }
  #product-violations .violation-elegant-details { min-width: 0; }
}

@media (max-width: 479px) {
  /* Single-column stats on small phones so labels never clip */
  #product-violations .violations-stats-elegant { grid-template-columns: 1fr; }
}

/* === CHATS / REVIEWS === */
@media (max-width: 1023px) {

  /* ---------- CHATS (#chats) — list ---------- */
  /* Conversation cards already have a mobile rule; just guarantee tap height
     and that the redesigned content doesn't overflow. */
  #chats .conversation-card { min-height: 76px; }
  #chats .conv-card-content { min-width: 0; }
  #chats .conv-card-name { word-break: break-word; }
  /* Stat boxes at the top: 2-up on phones, full row on tiny */
  #chats .stat-box { min-width: 0; }
  /* Filter dropdown + search fit width */
  #chats .search-filter,
  #chats .modern-filters { flex-wrap: wrap; gap: 10px; }
  #chats .search-filter input,
  #chats .modern-filters input { width: 100%; min-height: 44px; font-size: 16px; }
  /* Pagination fits */
  #chats .modern-pagination { flex-wrap: wrap; gap: 8px; }
  #chats .page-btn { min-height: 40px; }

  /* ---------- RESEÑAS (#reviews) ---------- */
  /* The review-card grid is unstyled in the loaded CSS, so the product thumb
     renders at natural (huge) size on mobile. Define a proper mobile card. */
  #reviews .reviews-grid { display: block !important; }
  #reviews .review-card {
    background: #fff; border: 1px solid #eef0f3; border-radius: 14px;
    padding: 16px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.05);
  }
  #reviews .review-card-header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
  #reviews .review-product-thumb {
    width: 56px; height: 56px; flex-shrink: 0;
    object-fit: cover; border-radius: 10px;
  }
  #reviews .review-card-info { flex: 1 1 auto; min-width: 0; }
  #reviews .review-product-name { font-size: 15px; font-weight: 700; margin: 2px 0; word-break: break-word; }
  #reviews .review-customer-line { flex-wrap: wrap; gap: 4px 8px; font-size: 13px; }
  #reviews .review-stars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  #reviews .review-card-body { margin-bottom: 12px; }
  #reviews .review-title { font-size: 15px; margin: 0 0 6px; }
  #reviews .review-content { font-size: 14px; line-height: 1.5; word-break: break-word; }
  #reviews .review-images { flex-wrap: wrap; }
  #reviews .review-images img { width: 72px; height: 72px; }
  /* Footer: badge above a full-width action button */
  #reviews .review-card-footer {
    display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  }
  #reviews .review-action-btn { width: 100%; min-height: 46px; justify-content: center; }
  /* Header + filters + pagination */
  #reviews .modern-reviews-header { flex-direction: column; align-items: stretch; gap: 12px; }
  #reviews .modern-filters { flex-wrap: wrap; gap: 10px; }
  #reviews .search-filter input { width: 100%; min-height: 44px; font-size: 16px; }
  #reviews .filter-item, #reviews .modern-filters select { min-height: 44px; font-size: 15px; }
  #reviews .modern-pagination { flex-wrap: wrap; gap: 8px; }
  #reviews .page-btn { min-height: 40px; }

  /* Review reply modal: full-width controls (response form lives in the modal) */
  #reviews .response-form textarea,
  .review-modal .response-form textarea { font-size: 16px; min-height: 120px; }
  #reviews .response-form .send-btn,
  .review-modal .send-btn { width: 100%; min-height: 46px; justify-content: center; }
}

@media (max-width: 479px) {
  #reviews .review-images img { width: 64px; height: 64px; }
}

/* === FOLLOW-UP FIXES (round 2) === */
@media (max-width: 1023px) {

  /* ---------- Products / Drafts header controls ----------
     products-latm.css stacks .products-header-actions to a column on mobile but
     leaves its base height:40px, so everything past the first row (sort, refresh,
     "Agregar") got clipped. Free the height and lay the controls out as a compact
     quick-action row with the SEARCH BAR as the big element on its own line below. */
  #my-products .products-header-actions,
  #drafts .products-header-actions {
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
  }
  /* My Productos: [sort] [refresh] [Agregar]  /  [ search — full width ] */
  #my-products #sort-products   { order: 1; flex: 1 1 auto; height: 44px; }
  #my-products #refresh-products{ order: 2; flex: 0 0 auto; width: 44px; height: 44px; }
  #my-products .btn-add-product { order: 3; flex: 1 1 auto; width: auto; height: 44px; }
  #my-products #products-search { order: 4; flex: 1 1 100%; width: 100%; height: 48px; font-size: 16px; }
  /* Borradores: [refresh]  /  [ search — full width ] */
  #drafts #refresh-drafts { order: 1; flex: 0 0 auto; width: 44px; height: 44px; }
  #drafts #drafts-search  { order: 2; flex: 1 1 100%; width: 100%; height: 48px; font-size: 16px; }

  /* ---------- Chat modal (seller reuses #customerChatModal) ---------- */
  /* Store/customer icon was oversized. */
  #customerChatModal .customer-avatar { width: 40px; height: 40px; font-size: 16px; }
  #customerChatModal .customer-avatar i { font-size: 16px; }

  /* The messages container carries an inline height:400px/max-height:400px that
     fights the flex column layout — leaving a dead gap and landing the scroll in
     the wrong spot. Let it flex-fill the modal so auto-scroll hits the latest msg. */
  #customerChatModal .chat-messages-container {
    height: auto !important;
    max-height: none !important;
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Per-message entrance animation thrashes layout while the modal is sliding up
     and auto-scrolling on open — that's the "jitter". Drop it on mobile. */
  #customerChatModal .message { animation: none !important; }
}

/* === FOLLOW-UP FIXES (round 3) === */
@media (max-width: 1023px) {

  /* ---------- Modal close buttons: make them obvious + tappable ----------
     On mobile these modals render full-screen, so the close control is the ONLY
     way out. The defaults were near-invisible (.modal-close-btn = transparent/#666
     on a light header; .close × = #aaa), so users got trapped (e.g. "Ver Detalles"
     on Mis Pedidos). Give every close affordance a solid 44px target — EXCEPT the
     chat modal, whose white-on-red close is already correct. */
  .modal .modal-close-btn,
  .modal:not(#customerChatModal) .close {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.07);
    color: #1a1a1a !important;
    border: none;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
    opacity: 1;
    flex-shrink: 0;
    z-index: 20;
    cursor: pointer;
  }
  .modal .modal-close-btn:active,
  .modal:not(#customerChatModal) .close:active {
    background: rgba(0, 0, 0, 0.15);
  }
  /* The × spans are mostly position:absolute already; pin them to the top-right
     corner consistently so they're always reachable above the content. */
  .modal:not(#customerChatModal) .close {
    position: absolute;
    top: 12px;
    right: 12px;
    float: none;
  }
  /* Make sure headers reserve room and don't overlap the corner close button. */
  .modern-order-header { padding-right: 64px; position: relative; }

  /* ---------- Chat search bar (#chats) ----------
     Give the search a clear bordered, branded, full-width look so it reads as the
     primary action in the filter row. */
  #chats .modern-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #chats .filter-item.search-filter {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 2px solid #DC2626;
    border-radius: 12px;
    padding: 0 14px;
    min-height: 50px;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
  }
  #chats .filter-item.search-filter .fa-search { color: #DC2626; font-size: 16px; }
  #chats .filter-item.search-filter input {
    flex: 1 1 auto;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    min-height: 48px;
    font-size: 16px;
    padding: 0;
  }
  /* Keep the filter dropdown comfortable above the search */
  #chats .filter-item:not(.search-filter) { min-height: 48px; }
}

/* === FOLLOW-UP FIXES (round 4) === */
@media (max-width: 1023px) {

  /* ---------- Create-discount: % vs Monto Fijo as tappable cards ----------
     The tiny native radios were hard to switch on touch. Pair with the JS that
     makes the whole option selectable; here we give each a real card target and
     a clear selected state. */
  #createDiscountModal .discount-type-options {
    flex-direction: row;
    gap: 10px;
  }
  #createDiscountModal .discount-type-option {
    flex: 1 1 0;
    min-height: 48px;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    justify-content: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
  }
  #createDiscountModal .discount-type-option label { cursor: pointer; margin: 0; }
  /* Selected highlight (modern browsers); harmless where :has is unsupported. */
  #createDiscountModal .discount-type-option:has(input:checked) {
    border-color: #DC2626;
    background: #fef2f2;
  }

  /* ---------- Análisis (#business-insights) ---------- */
  /* "Productos Más Vendidos": the product name is flex:1 with ellipsis but lacked
     min-width:0, so long names couldn't shrink and pushed the row off-screen. */
  #business-insights .bi2-top-name { min-width: 0; }
  #business-insights .bi2-top-row { gap: 10px; }

  /* Period segmented control (7/30/90 días) must never clip — let it fit/scroll. */
  #business-insights .bi2-period-btns { display: flex; width: 100%; }
  #business-insights .bi2-period-btn { flex: 1 1 0; min-width: 0; white-space: nowrap; }
  /* Card heads (title + loading) wrap instead of overflowing on tiny screens. */
  #business-insights .bi2-card-head { flex-wrap: wrap; gap: 6px; }
  #business-insights .bi2-card { overflow: hidden; }
}

/* Extra-small phones (≤360px): give the discount cards room to stack if needed */
@media (max-width: 360px) {
  #createDiscountModal .discount-type-option { padding: 10px 8px; font-size: 14px; }
  #business-insights .bi2-kpi-value { font-size: 20px; }
}
