/* DB2 Estoque v26.29 — experiência otimizada para celular e tablet */
@media (max-width: 1100px){
  html,body{overflow-x:hidden}
  .content,.dashboard-v19,.product-list-page-v265{max-width:none!important;width:100%!important}
  .hero{padding:18px!important}
  .hero .head{gap:12px!important;align-items:flex-start!important}
  .hero h1{font-size:clamp(22px,3.2vw,30px)!important;line-height:1.08!important}
  .hero .sub{font-size:12px!important;line-height:1.45!important}
  .toolbar{gap:10px!important;flex-wrap:wrap!important}
  .toolbar .search,.product-list-hero-v265 .search{min-width:0!important;width:100%!important;flex:1 1 100%!important}
  .db2-product-view-controls{margin-left:0!important;max-width:100%;overflow-x:auto;scrollbar-width:none}
  .db2-product-view-controls::-webkit-scrollbar{display:none}
  .db2-product-card-fields{max-width:100%!important}
  .modal,.modal.wide{max-width:min(94vw,760px)!important}
}

/* Tablet */
@media (min-width:821px) and (max-width:1100px){
  .shell{grid-template-columns:200px minmax(0,1fr)!important}
  .sidebar{width:200px!important;min-width:200px!important}
  .sidebar .brand{padding-inline:12px!important}
  .sidebar .brand-copy b{font-size:13px!important}
  .nav-item{margin-inline:6px!important;padding-inline:10px!important;font-size:13px!important}
  .content,.dashboard-v19{padding:20px 18px 48px!important}
  .dash-metrics-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .professional-niche-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .product-grid-v265.db2-product-view[data-view="catalog"]{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:12px!important}
  .db2-product-view[data-view="list"] .product-card-v265{grid-template-columns:88px minmax(0,1fr)!important}
  .db2-product-view[data-view="list"] .product-info-v265{grid-template-columns:minmax(150px,1.4fr) minmax(120px,1fr) auto!important;gap:10px!important}
}

/* Celular */
@media (max-width:820px){
  body{font-size:15px;padding-bottom:env(safe-area-inset-bottom)}
  .shell{display:block!important}
  .main{width:100%!important;min-width:0!important}

  /* Menu lateral vira drawer, em vez de desaparecer */
  .sidebar{
    display:flex!important;position:fixed!important;inset:0 auto 0 0!important;
    width:min(84vw,320px)!important;min-width:0!important;height:100dvh!important;
    z-index:1002!important;transform:translateX(-104%)!important;
    transition:transform .22s ease!important;box-shadow:18px 0 44px rgba(0,0,0,.2)!important;
    overflow-y:auto!important;overscroll-behavior:contain;background:var(--panel)!important;
  }
  body.mobile-sidebar-open .sidebar{transform:translateX(0)!important}
  .sidebar .brand{min-height:70px!important;padding:12px 14px!important}
  .sidebar-collapse-btn{display:none!important}
  .sidebar .nav{padding-bottom:90px!important}
  .sidebar .nav-item{min-height:46px!important;margin:3px 8px!important;font-size:14px!important}
  .sidebar .nav-label,.sidebar .brand-copy,.sidebar .nav-title{display:initial!important;opacity:1!important;width:auto!important}

  .mobile-sidebar-backdrop{position:fixed;inset:0;background:rgba(8,15,12,.42);backdrop-filter:blur(2px);z-index:1001;opacity:0;visibility:hidden;transition:.2s ease}
  body.mobile-sidebar-open .mobile-sidebar-backdrop{opacity:1;visibility:visible}
  .mobile-menu-btn{
    width:42px;height:42px;min-width:42px;border:1px solid var(--db2-border,var(--line));border-radius:12px;
    background:var(--panel);color:var(--text);display:grid;place-items:center;font-size:22px;cursor:pointer;
    box-shadow:0 2px 9px rgba(0,0,0,.06);margin-right:4px
  }
  .mobile-menu-btn:active{transform:scale(.96)}

  .topbar{height:60px!important;padding:0 10px!important;gap:7px!important;position:sticky!important;top:0!important;z-index:900!important}
  .top-title{font-size:14px!important;max-width:34vw!important}
  .top-right{margin-left:auto!important;gap:5px!important}
  .global-bell,.profile-button,.avatar{width:40px!important;height:40px!important;min-width:40px!important}

  .content,.dashboard-v19{padding:14px 10px calc(26px + env(safe-area-inset-bottom))!important}
  .hero{padding:14px!important;border-radius:14px!important}
  .hero .head{display:flex!important;flex-direction:column!important;gap:12px!important}
  .hero .head>.actions{width:100%!important;display:flex!important;gap:8px!important}
  .hero .head>.actions .btn{flex:1 1 auto!important;min-height:44px!important}
  .niche-title{width:100%!important;align-items:flex-start!important}
  .niche-title .back{width:40px!important;height:40px!important;min-width:40px!important}
  .hero h1{font-size:23px!important}
  .stats{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:7px!important}
  .stat{padding:10px!important;min-width:0!important}.stat b{font-size:17px!important}.stat small{font-size:9px!important}

  .product-list-hero-v265 .toolbar{display:grid!important;grid-template-columns:1fr!important;gap:9px!important}
  .product-list-hero-v265 .search{height:46px!important;font-size:16px!important}
  .db2-product-view-controls{width:100%!important;display:flex!important;justify-content:space-between!important;gap:6px!important;padding:4px!important}
  .db2-view-seg{flex:0 0 auto!important}.db2-view-seg button{min-width:44px!important;height:38px!important}
  .db2-cols-control{display:none!important}

  .db2-characteristic-filter-panel{padding:10px!important;margin-bottom:10px!important;border-radius:12px!important}
  .db2-filter-head{gap:7px!important}.db2-filter-title{font-size:12px!important;min-width:0!important}.db2-filter-title span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .db2-filter-head-actions{flex-shrink:0}.db2-filter-clear,.db2-filter-toggle{min-height:36px!important;padding:6px 8px!important}
  .db2-characteristic-filters{gap:6px!important;max-height:150px;overflow:auto;padding-bottom:2px}
  .db2-characteristic-filter{height:34px!important;font-size:12px!important;padding:0 10px!important}

  /* Catálogo legível e compacto */
  .product-grid-v265.db2-product-view[data-view="catalog"]{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:9px!important}
  .db2-product-view[data-view="catalog"] .product-card-v265{padding:7px!important;border-radius:12px!important;min-width:0!important}
  .db2-product-view[data-view="catalog"] .product-title-v265{font-size:14px!important;line-height:1.25!important;white-space:normal!important;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
  .db2-product-view[data-view="catalog"] .product-sku-v265{font-size:11px!important}
  .db2-product-view[data-view="catalog"] .product-actions-v265{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .db2-product-view[data-view="catalog"] .product-icon-btn-v265{width:100%!important;min-width:0!important;height:38px!important}
  .db2-highlighted-characteristics{gap:4px!important}.db2-highlighted-characteristics span{font-size:10px!important;min-height:24px!important;padding:3px 7px!important}
  .db2-card-extra-fields{gap:5px!important}.db2-card-extra-field{font-size:11px!important}

  /* Lista pensada para toque */
  .product-grid-v265.db2-product-view[data-view="list"]{gap:8px!important}
  .db2-product-view[data-view="list"] .product-card-v265{grid-template-columns:76px minmax(0,1fr)!important;gap:10px!important;padding:8px!important;align-items:start!important}
  .db2-product-view[data-view="list"] .product-square-v265{width:76px!important;height:76px!important;border-radius:10px!important}
  .db2-product-view[data-view="list"] .product-info-v265{display:block!important;min-width:0!important}
  .db2-product-view[data-view="list"] .product-title-v265{font-size:15px!important;line-height:1.25!important;margin-right:4px!important}
  .db2-product-view[data-view="list"] .product-sku-v265{font-size:11px!important;margin-top:3px!important}
  .db2-product-view[data-view="list"] .product-stock-line-v265{display:block!important;font-size:12px!important;margin-top:5px!important}
  .db2-product-view[data-view="list"] .product-actions-v265{display:flex!important;flex-wrap:wrap!important;justify-content:flex-start!important;gap:5px!important;margin-top:8px!important}
  .db2-product-view[data-view="list"] .product-icon-btn-v265{width:38px!important;height:38px!important;min-width:38px!important}

  /* Formulários como bottom sheet */
  .overlay{padding:0!important;align-items:flex-end!important}
  .modal,.modal.wide{width:100%!important;max-width:100%!important;max-height:92dvh!important;border-radius:20px 20px 0 0!important;padding:16px 12px calc(16px + env(safe-area-inset-bottom))!important;overflow-y:auto!important}
  .modal-head{top:-16px!important;padding-top:4px!important}.modal-head h2{font-size:19px!important}
  .tabs{position:sticky;top:44px;z-index:2;background:var(--panel);padding:4px 0!important;display:flex!important;overflow-x:auto!important;gap:5px!important}.tabs button{flex:1 0 auto!important;min-height:42px!important}
  .field input,.field select,.field textarea{min-height:46px!important;font-size:16px!important}
  textarea{min-height:96px!important}
  .modal-foot{gap:8px!important}.modal-foot .btn{min-height:46px!important}

  /* Detalhe do produto */
  .product-detail-top{position:relative!important;padding-top:4px!important;gap:8px!important}
  .product-detail{padding:10px!important;gap:12px!important}
  .product-main-media{min-height:220px!important;max-height:330px!important}
  .product-detail-info>h1{font-size:22px!important}
  .product-detail-info>.detail-fields,.complete-details-grid{grid-template-columns:1fr 1fr!important}

  /* Administração */
  .backup-grid,.users-grid,.order-admin-grid-v25{grid-template-columns:1fr!important}
  table{font-size:12px!important}
  .profile-menu{top:62px!important;left:8px!important;right:8px!important;max-height:76dvh!important}
}

@media (max-width:430px){
  .product-grid-v265.db2-product-view[data-view="catalog"]{grid-template-columns:1fr!important}
  .product-list-hero-v265 .toolbar{gap:7px!important}
  .stats{grid-template-columns:1fr 1fr!important}.stats .stat:last-child{grid-column:1/-1}
  .product-detail-info>.detail-fields,.complete-details-grid{grid-template-columns:1fr!important}
  .db2-product-view[data-view="list"] .product-card-v265{grid-template-columns:68px minmax(0,1fr)!important}
  .db2-product-view[data-view="list"] .product-square-v265{width:68px!important;height:68px!important}
}

@media (orientation:landscape) and (max-height:540px) and (max-width:1100px){
  .topbar{height:52px!important}
  .content,.dashboard-v19{padding-top:10px!important}
  .modal,.modal.wide{max-height:96dvh!important}
}
