/* ==============================================================================
   PREVIX ELTECH SOLUTIONS — ULTRA-RESPONSIVE ADAPTIVE ENGINE (CSS3)
   Comprehensive Device Coverage:
   - Extra Small Mobile: 320px, 360px, 375px, 390px, 412px, 430px
   - Small Phablet / Landscape: 480px, 576px, 600px
   - Medium Tablet: 768px, 800px, 820px, 991px
   - Desktop & Laptop: 1024px, 1200px, 1280px, 1366px, 1440px, 1920px+
   ============================================================================== */

/* ------------------------------------------------------------------------------
   1. GLOBAL SYSTEM RESETS & ANTI-OVERFLOW GUARANTEES
   ------------------------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  overflow-y: scroll !important;
  scrollbar-gutter: stable;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  margin: 0;
  padding: 0;
  position: relative;
  -webkit-text-size-adjust: 100%;
}

img, video, iframe, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* ------------------------------------------------------------------------------
   2. FLUID CONTAINER ARCHITECTURE
   ------------------------------------------------------------------------------ */
.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  width: 100%;
  max-width: 1320px;
  padding-left: clamp(12px, 3vw, 24px);
  padding-right: clamp(12px, 3vw, 24px);
  margin-left: auto;
  margin-right: auto;
}

/* ------------------------------------------------------------------------------
   3. RESPONSIVE TYPOGRAPHY SCALING
   ------------------------------------------------------------------------------ */
h1, .h1, .display-5 {
  font-size: clamp(1.75rem, 4.5vw, 2.75rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h2, .h2 {
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
  line-height: 1.25;
}

h3, .h3 {
  font-size: clamp(1.2rem, 2.8vw, 1.65rem);
  line-height: 1.3;
}

h4, .h4 {
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
}

h5, .h5 {
  font-size: clamp(0.95rem, 1.8vw, 1.15rem);
}

p, .lead {
  font-size: clamp(0.92rem, 1.4vw, 1.08rem);
  line-height: 1.65;
}

/* ------------------------------------------------------------------------------
   4. NAVIGATION BAR RESPONSIVENESS
   ------------------------------------------------------------------------------ */
.previx-navbar {
  transition: all 0.2s ease;
}

.previx-navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
}

@media (min-width: 992px) and (max-width: 1280px) {
  .nav-link {
    font-size: 0.81rem !important;
    padding: 6px 7px !important;
    gap: 3px !important;
  }
  .nav-link i {
    font-size: 0.85rem !important;
  }
  .navbar-brand span {
    font-size: 1.05rem !important;
  }
}

@media (max-width: 991.98px) {
  :root {
    --navbar-height: 64px;
  }

  .navbar-brand {
    font-size: 1.05rem !important;
    margin-right: 6px !important;
  }

  .navbar-brand img {
    height: 34px !important;
    width: auto;
  }

  /* Right-side quick controls on mobile */
  .previx-navbar .d-flex.align-items-center.gap-2.order-lg-3 {
    gap: 6px !important;
    flex-shrink: 0;
  }

  #theme-toggle-btn,
  button[onclick="Cart.openDrawer()"] {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.9rem;
  }

  #nav-auth-slot .btn {
    padding: 6px 10px !important;
    font-size: 0.8rem !important;
  }

  .navbar-toggler {
    padding: 5px 8px !important;
    font-size: 1.15rem !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm);
  }

  /* Collapsed Mobile Navigation Drawer */
  .navbar-collapse {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: 10px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16);
    max-height: 80vh;
    overflow-y: auto;
  }

  [data-theme="dark"] .navbar-collapse {
    background: #0B1220;
    border-color: #1E2D4A;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  }

  .navbar-nav .nav-link {
    padding: 10px 14px !important;
    margin-bottom: 3px;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
  }
}

/* ------------------------------------------------------------------------------
   5. BUTTONS & INTERACTIVE CONTROLS (ZERO DISTORTION FIX)
   ------------------------------------------------------------------------------ */
/* Preserve button dimensions - DO NOT stretch all buttons blindly */
.btn {
  white-space: nowrap;
  max-width: 100%;
}

/* Dedicated mobile block class for primary submit buttons */
.btn-block-mobile {
  display: flex !important;
  width: 100% !important;
}

@media (max-width: 576px) {
  .btn-group-mobile {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .btn-group-mobile .btn {
    width: 100% !important;
  }
}

/* ------------------------------------------------------------------------------
   6. CARDS, GRIDS & COMPONENT SCALING
   ------------------------------------------------------------------------------ */
.previx-card {
  padding: clamp(14px, 3vw, 24px);
  border-radius: clamp(8px, 2vw, 14px);
}

.product-card-img-wrap {
  width: 100%;
  height: clamp(160px, 25vw, 220px);
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------------------
   7. FULL TABLE RESPONSIVENESS & TOUCH SCROLL
   ------------------------------------------------------------------------------ */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

/* Maintain minimum readable column width on mobile tables */
.table-responsive > .table {
  margin-bottom: 0;
  min-width: 620px;
}

.table-responsive-sm > .table {
  min-width: 500px;
}

/* ------------------------------------------------------------------------------
   8. ADMIN CMS RESPONSIVE SIDEBAR & WORKSPACE
   ------------------------------------------------------------------------------ */
@media (max-width: 991.98px) {
  /* Stack admin layout vertically on mobile/tablet */
  body > .d-flex[style*="min-height: 100vh"],
  div[style*="min-height: 100vh"].d-flex {
    flex-direction: column !important;
  }

  .admin-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid #1E293B !important;
    padding: 12px 16px !important;
    background: #0B1120 !important;
  }

  .admin-sidebar > .d-flex.align-items-center {
    margin-bottom: 8px !important;
    padding-bottom: 8px !important;
  }

  /* Horizontal scrollable nav pills on mobile admin */
  .admin-sidebar .nav-pills {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 8px !important;
    margin-bottom: 0 !important;
    gap: 6px !important;
  }

  .admin-sidebar .nav-pills::-webkit-scrollbar {
    height: 4px;
  }

  .admin-sidebar .nav-pills::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
  }

  .admin-sidebar .nav-item {
    flex-shrink: 0 !important;
  }

  .admin-sidebar .nav-link {
    white-space: nowrap !important;
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
    border-radius: 6px !important;
  }

  .admin-sidebar .border-top {
    display: none !important; /* Hide redundant desktop bottom footer on mobile */
  }

  /* Main admin area takes full mobile width */
  .flex-grow-1.p-4.overflow-auto {
    padding: 16px 12px !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
}

/* ------------------------------------------------------------------------------
   9. FORMS & INPUT FIELD ZOOM PREVENTION (iOS SAFARI & ANDROID CHROME)
   ------------------------------------------------------------------------------ */
@media (max-width: 767.98px) {
  input,
  select,
  textarea,
  .form-control,
  .form-select {
    font-size: 16px !important; /* Prevents auto-zoom in mobile browsers */
  }

  .input-group {
    flex-wrap: nowrap;
  }
}

textarea {
  max-width: 100%;
}

/* ------------------------------------------------------------------------------
   10. MODAL DIALOG RESPONSIVENESS
   ------------------------------------------------------------------------------ */
@media (max-width: 576px) {
  .modal-dialog {
    margin: 10px !important;
    max-width: calc(100vw - 20px) !important;
  }

  .modal-content {
    border-radius: 12px !important;
    overflow: hidden;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 14px 16px !important;
  }
}

/* ------------------------------------------------------------------------------
   11. CODE CONVERSION & EDITOR BLOCKS
   ------------------------------------------------------------------------------ */
pre, code {
  max-width: 100%;
  overflow-x: auto;
  word-break: break-word;
}

pre code {
  white-space: pre;
  word-break: normal;
}

/* ------------------------------------------------------------------------------
   12. HERO SECTIONS & LOGO SHOWCASE RESPONSIVENESS (ZERO JITTER & CLS FREE)
   ------------------------------------------------------------------------------ */
@media (max-width: 767.98px) {
  .hero-section {
    padding: 36px 0 45px !important;
  }

  .hero-logo-showcase {
    height: 270px !important;
    max-width: 320px !important;
    margin: 24px auto 0 !important;
  }

  .previx-hero-logo-img {
    max-width: 210px !important;
    max-height: 125px !important;
  }

  .previx-orbit-system {
    width: 250px !important;
    height: 250px !important;
    margin-top: -125px !important;
    margin-left: -125px !important;
  }

  .previx-logo-ground-shadow {
    width: 140px !important;
    height: 12px !important;
    margin-top: 6px !important;
  }

  .previx-logo-ambient-glow {
    width: 220px !important;
    height: 220px !important;
    margin-top: -110px !important;
    margin-left: -110px !important;
  }

  .previx-status-pill {
    font-size: 0.68rem !important;
    padding: 4px 12px !important;
  }

  .hero-3d-wrap {
    height: 240px !important;
    margin-top: 20px;
  }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
  .hero-section {
    padding: 50px 0 65px !important;
  }

  .hero-logo-showcase {
    height: 320px !important;
    max-width: 390px !important;
  }

  .previx-hero-logo-img {
    max-width: 245px !important;
    max-height: 155px !important;
  }

  .previx-orbit-system {
    width: 300px !important;
    height: 300px !important;
    margin-top: -150px !important;
    margin-left: -150px !important;
  }

  .previx-logo-ground-shadow {
    width: 170px !important;
    height: 14px !important;
  }

  .previx-logo-ambient-glow {
    width: 280px !important;
    height: 280px !important;
    margin-top: -140px !important;
    margin-left: -140px !important;
  }

  .hero-3d-wrap {
    height: 320px !important;
  }
}

/* ------------------------------------------------------------------------------
   13. FOOTER RESPONSIVE ADJUSTMENTS
   ------------------------------------------------------------------------------ */
@media (max-width: 767.98px) {
  .previx-footer {
    padding: 40px 0 24px;
    text-align: center;
  }

  .previx-footer .d-flex.align-items-center {
    justify-content: center;
  }

  .previx-footer .col-lg-4,
  .previx-footer .col-md-4 {
    margin-bottom: 24px;
  }
}

/* ------------------------------------------------------------------------------
   14. WIDE DISPLAY REFINEMENT (1440px - 2560px+)
   ------------------------------------------------------------------------------ */
@media (min-width: 1440px) {
  .container, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl {
    max-width: 1360px;
  }
}

@media (min-width: 1920px) {
  .container, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl {
    max-width: 1480px;
  }
}
