/* Responsive Fixes for Mobile Devices */
/* This file fixes overflow, layout, and visibility issues on small screens */

/* ===== EXTRA SMALL DEVICES (375px - 413px) ===== */
@media screen and (max-width: 413px) {
  /* Fix section overflow - don't hide content */
  .section {
    overflow: visible;
    min-height: auto;
  }

  /* Fix sidebar width on mobile */
  .leftSticky,
  .rightSticky {
    display: none !important;
    flex: none !important;
    max-width: none !important;
    min-width: auto !important;
  }

  /* Fix wrapper for mobile */
  .wrapper {
    flex-direction: column;
    min-height: auto;
  }

  /* Fix modal width */
  .i_modal_bg .i_modal_in {
    max-width: 95%;
    width: 95%;
    margin: 0 auto;
  }

  /* Fix search input */
  .i_s_input {
    max-width: 80%;
    min-width: auto;
    width: 80%;
  }

  /* CRITICAL FIX: Make user menu scrollable */
  .i_general_box_container,
  .generalBox,
  .btest {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Fix menu dropdown */
  .i_user_details {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Fix general box search container */
  .i_general_box_search_container {
    max-height: 250px !important;
    max-width: 90vw !important;
    min-width: auto !important;
    width: 90vw !important;
    overflow-y: auto !important;
  }

  /* Fix dropdown menus */
  [class*="top_actions"],
  [class*="i_action_container"] {
    min-width: auto !important;
    max-width: 95vw !important;
    width: 95vw !important;
    position: absolute !important;
  }

  /* Fix image grids - prevent overflow */
  .i_image_one,
  .i_image_two,
  .i_image_three,
  .i_image_four {
    overflow: visible;
    width: 100% !important;
  }

  /* Fix avatar overflow */
  [class*="avatar"],
  [class*="profile_pic"] {
    overflow: visible;
  }

  /* Fix page width */
  .pageMiddle {
    max-width: 100% !important;
    width: 100% !important;
    padding: 10px;
  }

  /* Fix modal dialogs */
  .i_modal_cover_resize_bg_in .i_modal_in_in,
  .i_modal_avatar_resize_bg_in .i_modal_in_in,
  .i_modal_bg_in .i_modal_in_in,
  .i_moda_bg_in_form .i_modal_in_in {
    max-width: 90vw !important;
    width: 90vw !important;
  }

  /* Fix header */
  .header {
    padding: 10px 5px;
  }

  /* Fix navigation items */
  .i_header_btn_item {
    flex: 0 0 auto;
    margin: 0 3px;
  }

  /* Mobile hamburger visible */
  .mobile_hamburger {
    display: flex !important;
  }

  /* Fix forum/comment boxes */
  .i_payment_pop_box {
    max-width: 95% !important;
    width: 95% !important;
  }

  /* Fix left menu positioning */
  .leftSidebarWrapper {
    position: fixed;
    left: -100%;
    top: 72px;
    width: 85vw;
    max-width: 85vw;
    min-width: auto;
    height: calc(100vh - 72px);
    z-index: 15;
    transition: left 0.3s ease;
    overflow-y: auto;
  }

  .leftSidebarWrapper.active {
    left: 0;
  }

  /* Fix user card dropdown positioning - USE ABSOLUTE POSITIONING */
  .i_general_box_container,
  .i_general_box_message_notifications_container,
  .i_general_box_notifications_container {
    position: absolute !important;
    background-color: #ffffff !important;
    transform: translate(-10px, 50px) !important;
    -webkit-transform: translate(-10px, 50px) !important;
    -moz-transform: translate(-10px, 50px) !important;
    -o-transform: translate(-10px, 50px) !important;
    -ms-transform: translate(-10px, 50px) !important;
    width: 360px !important;
    max-width: 95vw !important;
    right: 0px !important;
    top: 3px !important;
    bottom: auto !important;
    z-index: 9999 !important;
    border-radius: 10px !important;
    display: flex !important;
    flex-direction: column !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15) !important;
    cursor: initial !important;
  }

  .btest {
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Remove scrollable modals, make them fit */
  .i_modal_bg {
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Fix text overflow in narrow spaces */
  [class*="text"],
  p, span, div {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* Fix button sizing */
  .btn, button, [class*="button"] {
    padding: 10px 12px !important;
    min-width: auto;
    max-width: 100%;
  }

  /* Fix input fields */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea,
  select {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Fix gallery/grid layouts */
  .gallery, .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)) !important;
    gap: 5px !important;
  }

  /* Remove fixed widths on content boxes */
  [style*="min-width: 260px"],
  [style*="min-width: 280px"],
  [style*="min-width: 320px"] {
    min-width: auto !important;
  }

  [style*="max-width: 260px"],
  [style*="max-width: 280px"],
  [style*="max-width: 320px"],
  [style*="max-width: 360px"] {
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* ===== SMALL DEVICES (414px - 600px) ===== */
@media screen and (max-width: 600px) {
  .section {
    overflow: visible;
    min-height: auto;
  }

  .wrapper {
    flex-direction: column;
    margin-bottom: 52px;
  }

  .leftSticky {
    display: none !important;
  }

  .rightSticky {
    display: none !important;
  }

  /* Hashtags: 1 per row on all devices */
  .hashtags_container {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hashtag_item {
    font-size: 12px;
    padding: 8px 10px;
  }

  .i_s_input {
    max-width: 70%;
    min-width: auto;
  }

  .i_modal_bg .i_modal_in {
    max-width: 90%;
  }

  .pageMiddle {
    max-width: 100%;
    padding: 15px;
  }

  .nearby_users_container {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
    gap: 10px !important;
  }

  /* Fix sticky positioning for menus */
  .i_header_menu_top_actions {
    position: sticky !important;
    top: 0 !important;
    width: 100% !important;
    z-index: 100 !important;
  }
}

/* ===== TABLETS (601px - 900px) ===== */
@media screen and (max-width: 900px) {
  .section {
    overflow: visible;
  }

  .leftSticky {
    flex: 0 0 auto !important;
    max-width: 200px !important;
    min-width: 200px !important;
  }

  /* Right sidebar VISIBLE on tablets (600px - 900px) */
  .rightSticky {
    display: block !important;
    flex: 0 0 auto !important;
    max-width: 180px !important;
    min-width: 180px !important;
  }

  .i_s_input {
    max-width: 150px;
  }

  .pageMiddle {
    flex: 1;
  }

  .wrapper {
    min-height: auto;
  }

  /* Fix sticky header menu */
  .i_header_menu_top_actions {
    position: sticky;
    top: 0;
    z-index: 100;
  }
}

/* ===== TABLETS LANDSCAPE (901px - 1024px) ===== */
@media screen and (max-width: 1024px) {
  .section {
    overflow: visible;
    min-height: auto;
  }

  .i_modal_bg .i_modal_in {
    max-width: 95%;
  }
}

/* ===== DESKTOP (1025px+) ===== */
@media screen and (min-width: 1025px) {
  .section {
    overflow: hidden;
  }

  .mobile_hamburger {
    display: none !important;
  }
}

/* ===== UNIVERSAL FIXES ===== */

/* Never hide scrollable content completely */
body, html {
  overflow-x: hidden;
}

/* Critical: Fix user menu dropdown overflow and width */
.i_general_box_container,
.i_general_box_message_notifications_container,
.i_general_box_notifications_container {
  position: absolute !important;
  background-color: #ffffff !important;
  transform: translate(-10px, 50px) !important;
  -webkit-transform: translate(-10px, 50px) !important;
  -moz-transform: translate(-10px, 50px) !important;
  -o-transform: translate(-10px, 50px) !important;
  -ms-transform: translate(-10px, 50px) !important;
  width: 360px !important;
  max-width: 95vw !important;
  right: 0px !important;
  top: 3px !important;
  bottom: auto !important;
  z-index: 9999 !important;
  border-radius: 10px !important;
  display: flex !important;
  flex-direction: column !important;
  max-height: 85vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15) !important;
  cursor: initial !important;
}

.generalBox {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.btest {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.i_user_details {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Fix overflow on all modal elements */
.i_modal_bg,
[role="dialog"],
[class*="modal"] {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Ensure images don't overflow */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Fix embedded content */
iframe, video, embed, object {
  max-width: 100%;
  height: auto;
}

/* Ensure text doesn't cause layout shift */
body {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* Fix flex layouts for small screens */
@supports (display: flex) {
  .flex_ {
    flex-wrap: wrap;
  }

  /* Settings payment/subscription tables: keep columns in a row */
  .i_tab_header.flex_,
  .i_tab_list_item.flex_ {
    flex-wrap: nowrap !important;
  }

  .i_tab_header .tab_item,
  .i_tab_list_item .tab_detail_item {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }
}

/* Settings tables: horizontal scroll on narrow screens instead of stacking */
.i_tab_container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.i_tab_header.flex_,
.i_tab_list_item.flex_ {
  min-width: 640px;
}

/* Unsubscribe button in subscription table action column */
.i_sub_flw .i_btn_unsubscribe {
  margin: 0 auto;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 8px;
  white-space: nowrap;
  cursor: pointer;
}

/* ===== HEADER LOGO ===== */
.i_logo {
  height: auto;
  min-height: 52px;
  align-items: center;
}

.i_logo a {
  display: flex;
  align-items: center;
  line-height: 0;
}

.i_logo img {
  width: auto;
  height: 58px;
  max-height: 64px;
  min-height: 48px;
  object-fit: contain;
}

/* ===== SETTINGS SIDEBAR MENU ===== */
.wrapper:has(.settings_wrapper) {
  overflow: visible !important;
}

.settings_wrapper {
  align-items: flex-start !important;
  overflow: visible !important;
}

.settings_left_menu,
.i_s_menu_wrapper,
.i_s_menu_box,
.i_s_menus_title,
.settings_mobile_ope_menu,
.settings_mobile_menu_container {
  max-width: none !important;
  max-height: none !important;
}

.settings_left_menu {
  align-self: flex-start;
  position: sticky;
  top: 88px;
  overflow: visible !important;
  max-height: calc(100vh - 96px);
}

.i_settings_menu_wrapper {
  display: flex !important;
  flex-direction: column !important;
  max-width: none !important;
  max-height: calc(100vh - 96px) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.i_settings_title {
  flex-shrink: 0;
}

.i_s_menus {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start !important;
  padding-bottom: 28px;
  scrollbar-width: thin;
  scrollbar-color: #b8bcc8 transparent;
}

.i_s_menus::-webkit-scrollbar {
  width: 7px;
}

.i_s_menus::-webkit-scrollbar-thumb {
  background: #b8bcc8;
  border-radius: 4px;
}

.i_s_menus::-webkit-scrollbar-track {
  background: transparent;
}

.i_s_menus_title {
  display: block;
  line-height: 1.45;
  margin-top: 14px;
  margin-bottom: 8px;
  padding-top: 12px;
  padding-bottom: 8px;
  overflow: visible !important;
  flex-shrink: 0;
}

.i_s_menus > .i_s_menus_title:first-child {
  margin-top: 0;
}

.i_s_menu_box {
  flex-wrap: nowrap !important;
  white-space: nowrap;
  min-height: 44px;
}

.i_s_menu_box svg {
  flex-shrink: 0;
}

@media screen and (max-width: 1024px) {
  .i_settings_menu_wrapper.settingsMenuDisplay {
    display: flex !important;
    flex-direction: column !important;
    max-height: calc(100vh - 150px) !important;
    overflow: hidden !important;
  }

  .i_settings_menu_wrapper.settingsMenuDisplay .i_s_menus {
    overflow-y: auto !important;
  }
}

/* Ensure header buttons are positioned correctly for dropdowns */
.i_header_btn_item {
  position: relative;
  z-index: 100;
  overflow: visible;
}

.i_one {
  overflow: visible;
  position: relative;
}

.i_header_right {
  overflow: visible;
  position: relative;
}

/* Touch targets minimum 48px */
.i_header_btn_item,
button,
a[role="button"],
[role="button"] {
  min-height: 48px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Readable font size minimum 16px on mobile */
@media screen and (max-width: 600px) {
  body {
    font-size: 16px;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Fix payment methods layout for mobile */
.paymentMethods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

/* Fix nearby users location system for mobile */
@media screen and (max-width: 600px) {
  .location_search_radius,
  .nearby_users_filters {
    width: 100% !important;
    max-width: none !important;
  }

  .user_location_card {
    min-width: auto;
    width: 100%;
  }
}

/* Ensure dropdown menus don't exceed viewport (exclude settings sidebar) */
[class*="dropdown"],
[class*="menu"]:not(.settings_left_menu):not(.i_settings_menu_wrapper):not(.i_s_menus):not(.i_s_menu_wrapper):not(.i_s_menu_box):not(.i_s_menus_title):not(.settings_mobile_ope_menu):not(.settings_mobile_menu_container) {
  max-width: calc(100vw - 20px) !important;
  max-height: calc(100vh - 100px) !important;
  overflow-y: auto;
}

/* Sticky positioning for important elements */
.logout-button-sticky,
.i_header_menu_top_actions {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

/* Print styles - never hide on print */
@media print {
  * {
    overflow: visible !important;
  }

  .hidden-print {
    display: none;
  }
}


/* ===== HASHTAGS/TRENDS RESPONSIVE LAYOUT ===== */

/* All sizes: 1 column (one hashtag per row) */
@media screen and (min-width: 1200px) {
  .hashtags_container {
    grid-template-columns: 1fr;
  }
}

/* Large tablets (900px - 1199px): 1 column */
@media screen and (min-width: 900px) and (max-width: 1199px) {
  .hashtags_container {
    grid-template-columns: 1fr;
  }
}

/* Tablets (601px - 899px): 1 column */
@media screen and (max-width: 900px) {
  .hashtags_container {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hashtag_item {
    font-size: 13px;
    padding: 16px 11px;
    min-height: 50px;
  }
}

/* Mobile (414px - 600px): 1 column */
@media screen and (max-width: 600px) {
  .hashtags_container {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hashtag_item {
    font-size: 12px;
    padding: 14px 10px;
    min-height: 45px;
  }
}

/* Small phones (375px - 413px): 1 column */
@media screen and (max-width: 413px) {
  .hashtags_container {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .hashtag_item {
    font-size: 11px;
    padding: 12px 9px;
    min-height: 40px;
  }
}

/* Extra small (< 375px): 1 column */
@media screen and (max-width: 375px) {
  .hashtags_container {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .hashtag_item {
    font-size: 11px;
    padding: 12px 9px;
    min-height: 40px;
  }
}

/* Live streaming buttons - side by side */
.i_postLiveStreaming {
  display: flex;
  gap: 10px;
  width: 100%;
}

.i_postLiveStreaming .i_live_ {
  flex: 1;
  width: 50%;
}

/* Live stream list - side by side */
.live_stream_list {
  display: flex;
  gap: 10px;
  width: 100%;
}

.live_stream_list .live_item_cont {
  flex: 1;
  width: 50%;
}
