/* ==========================================================================
   KXCL APPLICATIONS - PROFESSIONAL MOBILE RESPONSIVENESS STYLESHEET (mobile.css)
   Optimized for all mobile viewports (iOS, Android, small & large screens)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESKTOP SAFETY OVERRIDES (min-width: 1024px)
   Ensure mobile drawers, backdrops & bottom nav are ALWAYS hidden on desktop
   -------------------------------------------------------------------------- */
@media screen and (min-width: 1024px) {
  .landing-mobile-drawer,
  .mobile-sidebar-backdrop,
  nav[aria-label="Navegação principal"] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* --------------------------------------------------------------------------
   2. GLOBAL MOBILE LAYOUT & OVERFLOW CONTROLS (max-width: 1023px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
  html,
  body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative !important;
    -webkit-text-size-adjust: 100%;
  }

  .lg\:pl-\[var\(--sidebar-width\)\] {
    padding-left: 0 !important;
  }

  :root {
    --sidebar-width: 0px !important;
  }

  main {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  p, span, h1, h2, h3, h4, h5, h6, a {
    overflow-wrap: break-word;
    word-break: break-word;
  }
}

/* --------------------------------------------------------------------------
   3. TOP NAVIGATION HEADER ONLY (max-width: 1023px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 639px) {
  body > header a span,
  header.fixed a span,
  header.sticky a span,
  .landing-page header a span,
  header a div span,
  .header-brand-title {
    display: none !important;
  }
}

@media screen and (max-width: 1023px) {
  header nav,
  .landing-page header nav {
    display: none !important;
    visibility: hidden !important;
  }

  body > header,
  header.fixed,
  header.sticky,
  .landing-page header {
    height: 3.75rem !important;
    padding-left: 0.875rem !important;
    padding-right: 0.875rem !important;
  }

  body > header > div,
  header.fixed > div,
  header.sticky > div,
  .landing-page header > div {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  main header,
  div.min-w-0 > header,
  header.flex-col {
    height: auto !important;
    min-height: 0 !important;
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
  }
}

/* --------------------------------------------------------------------------
   4. USER POPOVER FLOATING ON MOBILE (max-width: 1023px)
   Positions account popover perfectly centered floating above bottom nav bar
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
  #sidebar-user-popover:not(.hidden) {
    position: fixed !important;
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)) !important;
    left: 0.875rem !important;
    right: 0.875rem !important;
    width: auto !important;
    max-width: 360px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    z-index: 99999 !important;
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.92) !important;
    background-color: #0c0f14 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
  }
}

/* --------------------------------------------------------------------------
   5. LANDING HERO SECTION (max-width: 1023px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
  .landing-hero-preview,
  div:has(> .landing-hero-preview-frame) {
    display: none !important;
  }

  .landing-section {
    padding-top: 1.75rem !important;
    padding-bottom: 2.5rem !important;
    text-align: center !important;
  }

  .landing-section .max-w-xl {
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
  }

  .landing-kicker {
    display: inline-block !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
    font-size: 0.75rem !important;
    letter-spacing: 0.12em !important;
  }

  .landing-section h1 {
    font-size: 1.85rem !important;
    line-height: 1.25 !important;
    margin-top: 0.75rem !important;
    margin-bottom: 0.75rem !important;
    text-align: center !important;
  }

  .landing-lead {
    font-size: 0.9375rem !important;
    line-height: 1.55 !important;
    max-width: 92% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
    color: #94a3b8 !important;
  }

  .landing-section .mt-7.flex,
  .hero-cta-buttons {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 0.75rem !important;
    margin-top: 1.5rem !important;
  }

  .landing-section .mt-7.flex a,
  .landing-section .mt-7.flex button,
  .hero-cta-buttons a,
  .hero-cta-buttons button {
    width: 100% !important;
    min-height: 48px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    border-radius: 0.75rem !important;
  }
}

/* --------------------------------------------------------------------------
   6. DASHBOARD & PANEL CARDS BEAUTIFICATION (All viewports)
   -------------------------------------------------------------------------- */
.storm-panel,
.storm-card {
  border-radius: 1.25rem !important;
  padding: 1.25rem !important;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
}

.storm-panel:hover,
.storm-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35) !important;
}

@media screen and (max-width: 639px) {
  section[aria-label="Resumo"] {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
  }

  .storm-panel {
    border-radius: 1rem !important;
    padding: 1rem !important;
  }
}

/* --------------------------------------------------------------------------
   7. SEARCH INPUT & FORM CONTROLS FIX (max-width: 1023px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
  .relative input[placeholder*="Pesquisar"],
  .relative input[placeholder*="pesquisar"],
  .relative input[type="search"],
  .applications-search-bar input {
    padding-left: 2.75rem !important;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* --------------------------------------------------------------------------
   8. DATA TABLES HORIZONTAL SCROLL & NO-SQUISH FIX (Universal)
   -------------------------------------------------------------------------- */
.overflow-x-auto,
.table-responsive,
div:has(> table) {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  padding-bottom: 0.5rem !important;
}

table {
  width: 100% !important;
  min-width: 650px !important;
  table-layout: auto !important;
}

th,
td {
  white-space: nowrap !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  padding: 0.75rem 0.875rem !important;
  font-size: 0.8125rem !important;
  vertical-align: middle !important;
}

th {
  font-weight: 700 !important;
  letter-spacing: 0.04em !important;
}

/* --------------------------------------------------------------------------
   9. MOBILE SIDEBAR DRAWER & OVERLAY (max-width: 1023px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
  aside.storm-sidebar-glow,
  #admin-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    width: 290px !important;
    max-width: 85vw !important;
    z-index: 9999 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.75) !important;
  }

  aside.storm-sidebar-glow.mobile-open,
  #admin-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  .landing-mobile-drawer {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 290px !important;
    max-width: 85vw !important;
    z-index: 9999 !important;
    transform: translateX(100%) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    padding: 1.5rem 1.25rem !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.75) !important;
  }

  .landing-mobile-drawer.mobile-open {
    transform: translateX(0) !important;
  }

  .mobile-sidebar-backdrop {
    position: fixed !important;
    inset: 0 !important;
    background-color: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(8px) !important;
    z-index: 9990 !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease !important;
  }

  .mobile-sidebar-backdrop.active {
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}

/* --------------------------------------------------------------------------
   10. FIXED BOTTOM NAVIGATION BAR FIX & PADDING (max-width: 1023px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
  main,
  #admin-main-content,
  #admin-main-content main,
  body > div > main,
  .admin-dashboard-container {
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  nav[aria-label="Navegação principal"].fixed.bottom-0 {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 4000 !important;
    backdrop-filter: blur(16px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px)) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5) !important;
  }

  nav[aria-label="Navegação principal"] .grid-cols-3 {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    height: 3.75rem !important;
    align-items: center !important;
  }
}

/* --------------------------------------------------------------------------
   11. FLOATING DISCORD FAB BUTTON POSITIONING (max-width: 1023px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
  #storm-discord-fab {
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
    right: 0.875rem !important;
    z-index: 3500 !important;
  }

  #storm-discord-fab a {
    width: 2.625rem !important;
    height: 2.625rem !important;
  }

  #storm-discord-fab svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }
}

/* --------------------------------------------------------------------------
   12. ADMIN PANEL RESPONSIVENESS (admin.html)
   -------------------------------------------------------------------------- */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

@media screen and (max-width: 1023px) {
  #admin-main-content {
    padding-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .admin-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
  }
}

@media screen and (max-width: 540px) {
  .admin-stats-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
}

/* --------------------------------------------------------------------------
   13. SMALL MOBILE SCREENS SPECIFIC (max-width: 639px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 639px) {
  h1, .text-4xl, .text-5xl, .text-6xl {
    font-size: 1.75rem !important;
    line-height: 1.25 !important;
  }

  h2, .text-3xl {
    font-size: 1.35rem !important;
    line-height: 1.3 !important;
  }

  .pricing-grid,
  .features-grid,
  .applications-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    gap: 1rem !important;
  }
}
