/* ==========================================================================
   GMR KIT · OMNI-DEVICE RESPONSIVE ARCHITECTURE (SCUM OPS)
   Balanced visual scaling & anti-saturation system for:
     1. Ultra-Wide, 4K & Big TV Screens (>= 1800px)
     2. Standard Desktop & 1080p Laptops (1201px - 1799px)
     3. Medium Laptops & Tablets Landscape (961px - 1200px)
     4. Tablets Portrait & Foldables (641px - 960px)
     5. Smartphones & Small Handhelds (<= 640px)
   ========================================================================== */

/* --------------------------------------------------------------------------
   01. BASE CONTAINER & VIEWPORT MECHANICS (NO OVERFLOW / NO CUT-OFFS)
   -------------------------------------------------------------------------- */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.main-layout {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 22px;
  align-items: start;
}

.content-section {
  container: inline-size / contentSection;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Drawer Handle & Action Group in Header of Sticky Panel */
.mobile-drawer-handle {
  display: none;
  width: 44px;
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  margin: 8px auto 2px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.mobile-drawer-handle:hover {
  background: var(--tac-orange-bright);
}

.cart-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-close-mobile-cart {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-close-mobile-cart:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}

/* --------------------------------------------------------------------------
   02. ULTRA-WIDE, 4K DISPLAYS, TELEVISIONS & LARGE SCREENS (>= 1800px)
   Anti-saturation: prevents oversized bloated cards while using space elegantly
   -------------------------------------------------------------------------- */
@media (min-width: 1800px) {
  .main-layout {
    max-width: 1880px;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 28px;
    padding: 24px 32px;
  }

  .clean-header {
    padding: 14px 32px;
  }

  .header-inner {
    max-width: 1880px;
  }

  /* 3 to 4 balanced weapon columns - keeps cards sharp and military-sized */
  .full-equip-list {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
  }

  /* 4 to 5 outfit columns */
  .outfits-list {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
  }

  /* 6 to 8 catalog items */
  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
  }

  .cart-sticky-panel {
    top: 78px;
    height: calc(100dvh - 92px);
    max-height: calc(100dvh - 92px);
  }

  /* Ergonomic TV / Density scale mode */
  body.density-compact .main-layout {
    max-width: 1540px;
    grid-template-columns: minmax(0, 1fr) 370px;
    gap: 20px;
    padding: 16px 24px;
  }

  body.density-compact .full-equip-list {
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 14px;
  }
}

/* --------------------------------------------------------------------------
   03. STANDARD DESKTOP & 1080P LAPTOPS (1201px - 1799px)
   -------------------------------------------------------------------------- */
@media (min-width: 1201px) and (max-width: 1799px) {
  .main-layout {
    max-width: 1560px;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 22px;
    padding: 20px 24px;
  }

  .full-equip-list {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
  }

  .outfits-list {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
  }

  body.density-compact .main-layout {
    max-width: 1360px;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 16px;
  }
}

/* --------------------------------------------------------------------------
   04. MEDIUM LAPTOPS & TABLETS LANDSCAPE (961px - 1200px)
   -------------------------------------------------------------------------- */
@media (min-width: 961px) and (max-width: 1200px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    padding: 16px 18px;
  }

  .cart-sticky-panel {
    position: sticky;
    top: 72px;
    height: calc(100dvh - 84px);
    max-height: calc(100dvh - 84px);
    display: flex;
    flex-direction: column;
  }

  .clean-header {
    padding: 10px 18px;
  }

  .nav-tab-btn {
    padding: 7px 11px;
    font-size: 0.74rem;
  }

  .nav-text-full {
    display: none;
  }
  .nav-text-short {
    display: inline;
  }

  .full-equip-list {
    grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
    gap: 14px;
  }

  .outfits-list {
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .fe-card {
    padding: 12px;
  }

  .fe-render-box {
    width: 90px;
    height: 72px;
  }
}

/* --------------------------------------------------------------------------
   05. TABLETS PORTRAIT & FOLDABLES (641px - 960px)
   Single column content with accessible floating dock & slide-up drawer
   -------------------------------------------------------------------------- */
@media (min-width: 641px) and (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
    padding: 14px 20px calc(85px + env(safe-area-inset-bottom, 12px));
    gap: 16px;
  }

  /* Cart Panel hidden from main flow, available via dock */
  .cart-sticky-panel:not(.mobile-open) {
    display: none;
  }

  .mobile-cart-dock {
    display: block;
  }

  .clean-header {
    padding: 10px 16px;
  }

  .nav-text-full {
    display: none;
  }
  .nav-text-short {
    display: inline;
  }

  .full-equip-list {
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 14px;
  }

  .outfits-list {
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 14px;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  /* Mobile Drawer */
  .cart-sticky-panel.mobile-open {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    height: min(88dvh, 740px) !important;
    max-height: min(88dvh, 740px) !important;
    width: 100% !important;
    z-index: 900 !important;
    background: #090d14 !important;
    border-top: 2px solid var(--tac-orange) !important;
    border-radius: 16px 16px 0 0 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.95) !important;
    overflow: hidden !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 12px));
    animation: ueDrawerSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .cart-sticky-panel.mobile-open .mobile-drawer-handle {
    display: block;
  }

  .cart-sticky-panel.mobile-open .btn-close-mobile-cart {
    display: inline-flex;
    align-items: center;
  }

  .mobile-cart-backdrop.active {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 890;
  }
}

/* --------------------------------------------------------------------------
   06. SMARTPHONES & SMALL HANDHELDS (<= 640px)
   De-cluttered layout: horizontal swipe shelves, compact cards, thumb navigation
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* Header Ultra-Optimized */
  .clean-header {
    padding: 8px 10px;
  }

  .header-inner {
    flex-direction: column;
    gap: 8px;
  }

  .brand-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .brand-name {
    font-size: 1.12rem;
  }

  .header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .btn-optics-toggle {
    padding: 6px 8px;
    font-size: 0.7rem;
  }
  .btn-optics-toggle #opticsLabelText {
    display: none;
  }

  .btn-density-toggle {
    padding: 6px 8px;
  }
  .btn-density-toggle .density-label {
    display: none;
  }

  .header-stat {
    display: none; /* Shown in floating bottom dock */
  }

  .btn-audio {
    width: 32px;
    height: 32px;
    padding: 0;
  }

  .btn-scum-logout {
    padding: 5px 9px;
    font-size: 0.68rem;
  }

  /* Navigation Tabs: Horizontal Touch Carousel */
  .header-nav {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    gap: 6px;
    width: 100%;
    padding: 2px 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-tab-btn {
    padding: 6px 10px;
    font-size: 0.72rem;
    flex-shrink: 0;
  }
  .nav-text-full {
    display: none;
  }
  .nav-text-short {
    display: inline;
  }
  .nav-tab-btn .nav-badge {
    padding: 1px 5px;
    font-size: 0.65rem;
  }

  /* Main Layout: safe area spacing for bottom dock */
  .main-layout {
    grid-template-columns: 1fr;
    padding: 8px 10px calc(85px + env(safe-area-inset-bottom, 12px));
    gap: 12px;
  }

  .cart-sticky-panel:not(.mobile-open) {
    display: none;
  }

  /* Ultra-Compact Search Card: avoids taking 250px vertical screen space */
  .search-card {
    padding: 10px;
    gap: 8px;
  }

  .search-box-wrap {
    padding: 0 10px;
    height: 40px;
  }

  .search-input {
    font-size: 0.84rem;
    touch-action: manipulation;
  }

  .search-kbd {
    display: none;
  }

  /* Horizontal swipe row for Quick Tags */
  .search-quick-tags {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    gap: 6px;
    width: 100%;
    padding: 2px 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .search-quick-tags::-webkit-scrollbar {
    display: none;
  }

  .quick-tag-label {
    display: none;
  }

  .btn-quick-tag {
    flex-shrink: 0;
    padding: 4px 9px;
    font-size: 0.68rem;
  }

  /* Horizontal swipe row for Category Pills */
  .categories-shelf {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    gap: 6px;
    padding: 2px 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .categories-shelf::-webkit-scrollbar {
    display: none;
  }

  .cat-pill {
    flex-shrink: 0;
    padding: 5px 9px;
    font-size: 0.72rem;
  }

  /* Full Equip Weapon Cards on Mobile */
  .full-equip-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .fe-card {
    padding: 10px;
    gap: 8px;
    border-radius: 6px;
  }

  .fe-hero-stage {
    height: 105px;
  }

  .fe-hero-render img {
    max-height: 64px;
  }

  .fe-watermark {
    font-size: 20px;
  }

  .fe-title {
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .fe-tele-hud {
    padding: 4px 6px;
    gap: 4px;
  }

  .fe-chip-lbl {
    font-size: 7.5px;
  }

  .fe-chip-val {
    font-size: 9.5px;
  }

  .fe-armory-rack {
    padding: 5px 6px;
    gap: 4px;
  }

  .fe-rack-cell {
    width: 36px;
    height: 36px;
  }

  .fe-rack-img-wrap {
    width: 24px;
    height: 24px;
  }

  .fe-quick-strip {
    gap: 3px;
  }

  .btn-addon-chip {
    font-size: 8px;
    height: 21px;
    padding: 1px 5px;
  }

  .fe-card-footer {
    display: flex;
    gap: 6px;
    margin-top: 2px;
  }

  .btn-card-inspect {
    width: 35%;
    min-height: 38px;
    padding: 6px 4px;
    font-size: 0.68rem;
    justify-content: center;
  }

  .btn-equip-weapon {
    width: 65%;
    min-height: 38px;
    padding: 6px 8px;
    font-size: 0.72rem;
    justify-content: center;
  }

  /* Outfits Cards on Mobile */
  .outfits-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .outfit-card {
    padding: 10px;
    gap: 8px;
  }

  .outfit-components-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }

  .outfit-card-footer {
    display: flex;
    gap: 6px;
  }

  .btn-inspect-outfit {
    width: 36%;
    min-height: 40px;
    padding: 8px 4px;
    font-size: 0.68rem;
    justify-content: center;
  }

  .outfit-card-footer .btn-equip-outfit {
    width: 64%;
    min-height: 40px;
    padding: 8px 6px;
    font-size: 0.72rem;
    justify-content: center;
  }

  /* Catalog Grid on Mobile (2 Crisp Columns) */
  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .grid-card {
    padding: 8px;
    border-radius: 5px;
  }

  .card-thumb-wrap {
    height: 70px;
    margin-bottom: 6px;
  }

  .card-name {
    font-size: 0.72rem;
    min-height: 26px;
    margin-bottom: 2px;
  }

  .card-id {
    font-size: 0.62rem;
    margin-bottom: 4px;
  }

  /* Floating Tactical Bottom Dock */
  .mobile-cart-dock {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 850;
    background: rgba(8, 11, 16, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--tac-orange);
    box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.8), 0 0 10px var(--tac-orange-glow);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 8px));
  }

  .mobile-dock-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-dock-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
  }

  .mobile-dock-icon {
    font-size: 1.25rem;
    color: var(--tac-orange-bright);
    flex-shrink: 0;
  }

  .mobile-dock-stats {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .mobile-dock-title {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-dock-sub {
    font-size: 0.6rem;
    color: var(--tac-orange-bright);
  }

  .mobile-dock-btn-copy {
    background: var(--grad-orange);
    color: #000;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 800;
    padding: 8px 12px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 0 8px var(--tac-orange-glow);
    flex-shrink: 0;
  }

  /* Slide-up Delivery Drawer */
  .cart-sticky-panel.mobile-open {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    height: min(88dvh, 720px) !important;
    max-height: min(88dvh, 720px) !important;
    width: 100% !important;
    z-index: 900 !important;
    background: #090d14 !important;
    border-top: 2px solid var(--tac-orange) !important;
    border-radius: 16px 16px 0 0 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.95) !important;
    overflow: hidden !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 12px));
    animation: ueDrawerSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .cart-sticky-panel.mobile-open .mobile-drawer-handle {
    display: block;
  }

  .cart-sticky-panel.mobile-open .btn-close-mobile-cart {
    display: inline-flex;
    align-items: center;
  }

  .cart-scroll-content {
    overscroll-behavior: contain;
  }

  .mobile-cart-backdrop.active {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 890;
  }

  /* Telemetry Strip inside Mobile Panel */
  .telemetry-strip-hud {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px;
  }

  .telemetry-stats-group {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: space-between;
  }

  /* GMR-Bot & NLP inside Mobile Panel */
  .gmr-bot-panel {
    padding: 10px;
    margin: 8px 0 10px;
  }

  .gmr-bot-input-group {
    flex-direction: column;
    gap: 6px;
  }

  .btn-gmr-bot-submit {
    padding: 8px;
    justify-content: center;
  }

  /* Container selector tiles in Mobile Panel */
  .container-tiles {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .container-tile {
    padding: 6px 4px;
  }
  .container-tile img {
    width: 32px;
    height: 28px;
  }
  .container-tile-name {
    font-size: 0.65rem;
  }

  /* Modals on Mobile: Weapon Inspector & Server Info */
  #weaponInspectorModal,
  #serverInfoModal {
    padding: 8px;
  }

  .inspector-chassis,
  .server-info-chassis {
    width: 100%;
    max-height: 92dvh;
    border-radius: 6px;
  }

  .inspector-header,
  .server-info-header {
    padding: 10px 12px;
  }

  .inspector-title,
  .server-info-title {
    font-size: 0.98rem;
  }

  .inspector-body {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    max-height: calc(92dvh - 110px);
  }

  .inspector-stage {
    min-height: 160px;
    padding: 10px;
  }

  .inspector-weapon-img {
    max-height: 130px;
  }

  .server-info-body {
    padding: 10px 12px;
    gap: 10px;
    max-height: calc(92dvh - 120px);
  }

  .server-metrics-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .server-metric-card {
    padding: 10px;
    gap: 8px;
  }

  .metric-val {
    font-size: 1.25rem;
  }

  .server-info-footer {
    padding: 8px 12px;
    flex-direction: column-reverse;
    gap: 6px;
  }

  .btn-refresh-server,
  .btn-close-server-modal {
    width: 100%;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   07. DRAWER ANIMATION KEYFRAMES
   -------------------------------------------------------------------------- */
@keyframes ueDrawerSlideUp {
  0% { transform: translateY(100%); }
  100% { transform: translateY(0); }
}
