/**
 * JOYA Business Today — Unified Responsive Engine
 * Breakpoints:
 * - Mobile: 320px to 480px (including 360px, 375px, 390px, 414px, 430px)
 * - Tablet: 768px to 1024px
 * - Desktop: 1280px and above
 */

/* ==========================================================================
   1. Universal Overflow, Box-Sizing & Media Safety
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box !important;
}

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

img, video, iframe, embed, object {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Ensure containers never overflow viewport */
.container,
.main-container,
.product-header-card,
.detail-section,
.catalog-section,
.search-box-wrap {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

@media (min-width: 1100px) {
  .container {
    max-width: 1080px !important;
  }
  .catalog-section {
    max-width: 1260px !important;
  }
  .search-box-wrap {
    max-width: 580px !important;
  }
}

/* ==========================================================================
   2. Touch Target Enforcement (Minimum 44px on Mobile & Tablet)
   ========================================================================== */
@media (max-width: 1024px) {
  button,
  .btn,
  .card-btn,
  .nav-icon-btn,
  .lang-flag-btn,
  .mobile-menu-btn,
  .btn-action-buy,
  .btn-action-trial,
  .btn-os-download,
  .search-clear,
  input[type="submit"],
  input[type="button"] {
    min-height: 44px !important;
  }

  .nav-icon-btn {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .lang-flag-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Prevent iOS zoom on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* ==========================================================================
   3. Mobile Navigation Hamburger & Full Drawer Component
   ========================================================================== */
.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 1px solid rgba(226, 232, 240, 0.9);
  color: #0A0F1D;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  transition: all 0.25s ease;
  z-index: 1050;
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: #EFF6FF;
  border-color: #BFDBFE;
  color: #1E40AF;
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
}

.mobile-menu-btn.is-active .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mobile-menu-btn.is-active .hamburger-line:nth-child(2) {
  opacity: 0;
}
.mobile-menu-btn.is-active .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Drawer overlay */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 29, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-drawer-overlay.is-visible {
  display: block !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Drawer Container — Bespoke Apple/Stripe-Grade Minimalist Sheet */
.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.18);
  z-index: 1045;
  padding: 20px 22px 28px;
  transform: translateY(-110%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mobile-drawer.is-open {
  transform: translateY(0);
  opacity: 1;
}

.mobile-drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(241, 245, 249, 0.9);
}

.mobile-drawer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.mobile-drawer-brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.mobile-drawer-brand-text {
  display: flex;
  flex-direction: column;
}

.mobile-drawer-brand-name {
  font-family: var(--font-en, "Outfit", "Plus Jakarta Sans", sans-serif);
  font-size: 19px;
  font-weight: 900;
  color: #0A0F1D;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.mobile-drawer-brand-sub {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #64748B;
  text-transform: uppercase;
}

.mobile-drawer-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(241, 245, 249, 0.85);
  border: 1px solid rgba(226, 232, 240, 0.9);
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-drawer-close:hover {
  background: #EFF6FF;
  color: #1E40AF;
  border-color: #BFDBFE;
  transform: rotate(90deg);
}

.mobile-drawer-links {
  display: flex;
  flex-direction: column;
}

.mobile-drawer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 8px;
  min-height: 50px;
  border-bottom: 1px solid rgba(241, 245, 249, 0.85);
  background: transparent;
  color: #0F172A;
  text-decoration: none;
  transition: all 0.2s ease;
  border-radius: 12px;
}

.mobile-drawer-link:last-of-type {
  border-bottom: none;
}

.mobile-drawer-link-left {
  display: flex;
  align-items: center;
  gap: 13px;
}

.mobile-drawer-link-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(241, 245, 249, 0.9);
  color: #1E40AF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.mobile-drawer-link-icon svg {
  width: 18px;
  height: 18px;
}

.mobile-drawer-link-title {
  font-size: 15px;
  font-weight: 600;
  color: #1E293B;
  transition: color 0.2s ease;
}

.mobile-drawer-chevron {
  width: 17px;
  height: 17px;
  color: #94A3B8;
  transition: transform 0.25s ease, color 0.2s ease;
  flex-shrink: 0;
}

/* RTL vs LTR chevron flip */
html[dir="rtl"] .mobile-drawer-chevron,
body[dir="rtl"] .mobile-drawer-chevron {
  transform: rotate(180deg) !important;
}

html[dir="ltr"] .mobile-drawer-chevron,
body[dir="ltr"] .mobile-drawer-chevron {
  transform: rotate(0deg) !important;
}

.mobile-drawer-link:hover,
.mobile-drawer-link.is-active {
  background: rgba(239, 246, 255, 0.6);
  padding-left: 12px;
  padding-right: 12px;
}

.mobile-drawer-link:hover .mobile-drawer-link-icon,
.mobile-drawer-link.is-active .mobile-drawer-link-icon {
  background: #1E40AF;
  color: #FFFFFF;
}

.mobile-drawer-link:hover .mobile-drawer-link-title,
.mobile-drawer-link.is-active .mobile-drawer-link-title {
  color: #1E40AF;
  font-weight: 700;
}

.mobile-drawer-link:hover .mobile-drawer-chevron,
.mobile-drawer-link.is-active .mobile-drawer-chevron {
  color: #1E40AF;
}

html[dir="rtl"] .mobile-drawer-link:hover .mobile-drawer-chevron,
html[dir="rtl"] .mobile-drawer-link.is-active .mobile-drawer-chevron,
body[dir="rtl"] .mobile-drawer-link:hover .mobile-drawer-chevron,
body[dir="rtl"] .mobile-drawer-link.is-active .mobile-drawer-chevron {
  transform: rotate(180deg) translateX(4px) !important;
}

html[dir="ltr"] .mobile-drawer-link:hover .mobile-drawer-chevron,
html[dir="ltr"] .mobile-drawer-link.is-active .mobile-drawer-chevron,
body[dir="ltr"] .mobile-drawer-link:hover .mobile-drawer-chevron,
body[dir="ltr"] .mobile-drawer-link.is-active .mobile-drawer-chevron {
  transform: rotate(0deg) translateX(4px) !important;
}

/* Concierge Card for Direct Support */
.mobile-drawer-concierge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.04) 0%, rgba(37, 99, 235, 0.08) 100%);
  border: 1px solid rgba(191, 219, 254, 0.7);
  text-decoration: none;
  transition: all 0.25s ease;
  margin-top: 4px;
}

.mobile-drawer-concierge:hover {
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.08) 0%, rgba(37, 99, 235, 0.12) 100%);
  border-color: #93C5FD;
  box-shadow: 0 4px 14px rgba(30, 64, 175, 0.08);
}

.mobile-drawer-concierge-info {
  display: flex;
  align-items: center;
  gap: 11px;
}

.mobile-drawer-concierge-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #25D366;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.25);
}

.mobile-drawer-concierge-text {
  display: flex;
  flex-direction: column;
  text-align: start;
}

.mobile-drawer-concierge-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0F172A;
  line-height: 1.25;
}

.mobile-drawer-concierge-sub {
  font-size: 11px;
  color: #64748B;
}

.mobile-drawer-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.mobile-drawer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid rgba(241, 245, 249, 0.9);
}

.mobile-drawer-lang-btn {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-drawer-lang-btn:hover {
  background: #EFF6FF;
  border-color: #BFDBFE;
  color: #1E40AF;
}

.mobile-drawer-lang-btn img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

/* Tablet & Mobile Nav Positioning & Button Filtering */
@media (max-width: 1024px) {
  .mobile-menu-btn {
    display: flex !important;
  }

  /* Centered floating nav with zero horizontal offset issues */
  .nav {
    position: fixed !important;
    top: 12px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    margin: 0 !important;
    width: min(94%, 580px) !important;
    padding: 6px 14px 6px 14px !important;
    z-index: 999 !important;
    box-sizing: border-box !important;
  }

  .page-intro {
    padding-top: 85px !important;
  }

  /* Hide desktop text button and desktop icon buttons inside navbar to avoid crowding */
  .nav #navSystemsBtn,
  .nav .nav-icon-btn {
    display: none !important;
  }

  .nav .nav-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
}

/* ==========================================================================
   4. Catalog Page Responsive Grid (Requirement 3)
   1 col mobile, 2-3 col tablet, 4 col desktop
   ========================================================================== */
.systems-grid {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 22px !important;
  width: 100% !important;
}

@media (max-width: 1180px) {
  .systems-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 18px !important;
  }
}

@media (max-width: 820px) {
  .systems-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }
}

@media (max-width: 480px) {
  .systems-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .catalog-section {
    padding: 0 16px !important;
    margin-bottom: 32px !important;
  }
}

.systems-grid .card {
  width: 100% !important;
  height: 100% !important;
  min-height: 270px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
}

.systems-grid .card .card-desc {
  flex-grow: 1 !important;
}

.systems-grid .card .card-btn {
  margin-top: auto !important;
}

/* ==========================================================================
   5. Homepage (petalyx.html) Responsiveness
   ========================================================================== */
@media (max-width: 1024px) {
  .cards {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
    width: min(100%, 640px) !important;
  }

  .card {
    height: auto !important;
    min-height: 110px !important;
    padding: 16px 18px !important;
  }

  section.stats {
    height: auto !important;
    min-height: auto !important;
    padding: 90px 16px 60px !important;
    overflow: hidden !important;
  }

  .stats-inner {
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  section.loop {
    height: auto !important;
    min-height: auto !important;
    padding: 80px 16px 40px !important;
  }

  .loop-head {
    position: relative !important;
    top: auto !important;
    margin-bottom: 24px !important;
  }

  .track {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    width: min(100%, 680px) !important;
    margin: 0 auto !important;
  }

  .panel {
    flex: none !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    border-left: none !important;
    border-radius: 20px !important;
    background: #F8FAFC !important;
    border: 1px solid #E2E8F0 !important;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04) !important;
  }

  .panel-in {
    position: relative !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    padding: 22px 20px !important;
    display: flex !important;
    align-items: center !important;
    gap: 18px !important;
  }

  .num {
    font-size: clamp(48px, 12vw, 84px) !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
  }

  .step {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    width: 100% !important;
    text-align: right !important;
  }

  html[dir="ltr"] .step {
    text-align: left !important;
  }

  .step h3 {
    font-size: clamp(16px, 3.5vw, 20px) !important;
    margin-bottom: 6px !important;
  }

  .step p {
    font-size: 13.5px !important;
    line-height: 1.5 !important;
  }

  .mini-cloud {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .cards {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .card b {
    font-size: 32px !important;
  }

  section.stats {
    padding: 70px 16px 50px !important;
  }

  .tree-wrap {
    width: min(240px, 60vw) !important;
    opacity: 0.8 !important;
  }

  section.hero {
    height: 100svh !important;
    min-height: 540px !important;
  }

  h1#heroTitle {
    top: 32% !important;
    font-size: clamp(21px, 6vw, 28px) !important;
    line-height: 1.4 !important;
    padding: 0 16px !important;
    min-height: 90px !important;
  }

  .cloud-l { width: 75vw !important; left: -22vw !important; top: 4% !important; }
  .cloud-r { width: 70vw !important; right: -20vw !important; top: 8% !important; }

  section.cta {
    height: auto !important;
    min-height: 440px !important;
    padding: 18px 16px 30px !important;
  }

  .cta-card {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    width: 100% !important;
    padding: 24px 18px !important;
    margin: -30px auto 0 !important;
  }

  .cta-img {
    height: 100% !important;
  }
}

@media (min-width: 1025px) {
  .cta-card {
    top: 6% !important;
  }
}

/* ==========================================================================
   6. System Details Page (system-details.html) Responsiveness
   ========================================================================== */
@media (max-width: 1024px) {
  .container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 80px 16px 60px !important;
    margin: 0 auto !important;
  }

  .product-header-card,
  .detail-section {
    width: 100% !important;
    max-width: 100% !important;
    padding: 24px 18px !important;
    border-radius: 20px !important;
    margin-bottom: 20px !important;
    box-sizing: border-box !important;
  }

  .header-top {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 14px !important;
  }

  .features-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .video-container {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px !important;
  }

  .plans-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
    width: 100% !important;
  }

  .actions-sticky-bar {
    width: 100% !important;
    max-width: 100% !important;
    margin: 24px auto 0 !important;
    padding: 16px 14px !important;
    flex-direction: column !important;
    gap: 12px !important;
    box-sizing: border-box !important;
    border-radius: 20px !important;
  }

  .btn-action-buy,
  .btn-action-trial {
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
  }
}

@media (max-width: 600px) {
  .plans-grid {
    grid-template-columns: 1fr !important;
  }

  .os-spec-card {
    padding: 16px !important;
  }

  .os-spec-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }
}

/* ==========================================================================
   7. Dreamflow Footer Mobile & Tablet Layout
   ========================================================================== */
@media (max-width: 900px) {
  footer#footer {
    padding: 0 0 20px !important;
  }

  .df-top-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  .df-col-links {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .df-col-newsletter {
    width: 100% !important;
  }

  .df-news-form {
    width: 100% !important;
  }

  .df-news-input-wrap {
    width: 100% !important;
  }

  .df-watermark {
    font-size: clamp(80px, 24vw, 180px) !important;
    overflow: hidden !important;
    max-width: 100% !important;
  }

  .df-artwork {
    width: 120px !important;
    height: 100px !important;
    opacity: 0.12 !important;
  }
}

@media (max-width: 480px) {
  .df-col-links {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  .df-link-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    padding-bottom: 14px !important;
  }
}
