/* ============================================================
   MOBILE.CSS — Mobile UX Overhaul for "elite" template
   All styles are scoped to breakpoints — zero impact on desktop.
   Loaded AFTER main.css and custom.css.
   ============================================================ */

@media (max-width: 767px) {
  .desktop-only {
    display: none !important;
  }
}

@media (min-width: 768px) {

  .mobile-only,
  .mobile-bottom-nav,
  .mobile-more-overlay,
  .mobile-more-sheet {
    display: none !important;
  }
}

/* ─── Base Reset for Mobile Components ─── 
   Ensures they are hidden on desktop even if classes are missing. */
.mobile-bottom-nav,
.mobile-more-overlay,
.mobile-more-sheet {
  display: none;
}

/* ─── Touch Targets ─── */
@media (max-width: 767px) {

  .btn,
  a:not(.dropdown-item):not(.nav-link),
  input,
  select,
  textarea,
  button {
    min-height: 12px;
    min-width: 44px;
  }

  /* Override for small inline elements that shouldn't be 44px */
  a.small-link,
  .pagination a {
    min-height: auto;
    min-width: auto;
  }

  /* Active state for touch feedback */
  .btn:active,
  a:active,
  button:active {
    opacity: 0.85;
  }
}

/* ─── Bottom Navigation Bar ─── */
@media (max-width: 767px) {
  body {
    padding-bottom: 70px;
    /* space for fixed bottom nav */
  }

  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    display: flex !important;
    align-items: center;
    justify-content: space-around;
    height: 65px;
    background: #1a1a2e;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
  }

  .mobile-bottom-nav__tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    padding: 4px 0;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    font-size: 10px;
    transition: all 0.2s ease;
    position: relative;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav__tab:hover,
  .mobile-bottom-nav__tab:focus {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
  }

  .mobile-bottom-nav__tab--active {
    color: #5a4fdc;
  }

  .mobile-bottom-nav__tab--active:hover {
    color: #5a4fdc;
  }

  .mobile-bottom-nav__icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 2px;
  }

  .mobile-bottom-nav__label {
    font-size: 10px;
    line-height: 1.2;
    font-weight: 500;
  }

  /* Badge for active trade count */
  .mobile-bottom-nav__badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(calc(50% + 12px));
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
  }

  .mobile-more-overlay {
    position: fixed;
    inset: 0;
    z-index: 1060;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    display: block !important;
  }

  .mobile-more-overlay--open {
    opacity: 1;
    visibility: visible;
  }

  .mobile-more-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1070;
    background: #1a1a2e;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px 16px 0 0;
    padding: 20px 20px 30px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 70vh;
    overflow-y: auto;
    display: block !important;
  }

  .mobile-more-sheet--open {
    transform: translateY(0);
  }

  .mobile-more-sheet__handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 auto 16px;
  }

  .mobile-more-sheet__title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mobile-more-sheet__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 14px;
    border-radius: 8px;
    transition: background 0.2s ease;
    text-decoration: none !important;
  }

  .mobile-more-sheet__item:hover,
  .mobile-more-sheet__item:focus {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
  }

  .mobile-more-sheet__item-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    color: #5a4fdc;
  }

  .mobile-more-sheet__item-label {
    flex: 1;
  }
}

/* ─── Banner Compact (Mobile) ─── */
@media (max-width: 767px) {
  .account-setting-banner {
    padding: 20px 0 !important;
  }

  .account-setting-banner .author {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left !important;
  }

  .account-setting-banner .author__thumb {
    width: 48px;
    height: 48px;
    margin: 0 !important;
    flex-shrink: 0;
  }

  .account-setting-banner .author__thumb img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
  }

  .account-setting-banner .author__hello {
    font-size: 16px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .account-setting-banner .author__email {
    font-size: 12px;
    margin: 0;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Collapse the details row — hide less important fields */
  .account-setting-banner .author-details {
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .account-setting-banner .author-details__item {
    flex: 0 0 auto;
    padding: 4px 10px;
  }

  .account-setting-banner .author-details__title {
    font-size: 10px;
  }

  .account-setting-banner .author-details__info {
    font-size: 11px;
  }

  /* Banner shape hidden on mobile */
  .banner-section__shape {
    display: none;
  }
}

/* ─── Footer Hidden on Mobile User Pages ─── */
@media (max-width: 767px) {
  .user-page .footer-area {
    display: none;
  }
}

/* ─── Card-Based Table Replacement ─── */
@media (max-width: 767px) {
  .mobile-card-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .mobile-card-table .mobile-trade-card {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
    transition: border-color 0.2s ease;
  }

  .mobile-card-table .mobile-trade-card:active {
    border-color: #5a4fdc;
  }

  .mobile-trade-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }

  .mobile-trade-card__trader {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
  }

  .mobile-trade-card__trader .thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
  }

  .mobile-trade-card__trader .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .mobile-trade-card__badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
  }

  .mobile-trade-card__body {
    margin-bottom: 10px;
  }

  .mobile-trade-card__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
  }

  .mobile-trade-card__label {
    color: rgba(255, 255, 255, 0.5);
  }

  .mobile-trade-card__value {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    text-align: right;
  }

  .mobile-trade-card__value--highlight {
    color: #5a4fdc;
  }

  .mobile-trade-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .mobile-trade-card__time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
  }

  .mobile-trade-card__action {
    font-size: 12px;
    font-weight: 600;
    color: #5a4fdc;
    text-decoration: none;
  }

  .mobile-trade-card__action:hover {
    text-decoration: underline;
  }

  /* Wallet card variant */
  .mobile-wallet-card {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .mobile-wallet-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(90, 79, 220, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .mobile-wallet-card__icon img {
    width: 24px;
    height: 24px;
  }

  .mobile-wallet-card__info {
    flex: 1;
    min-width: 0;
  }

  .mobile-wallet-card__code {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 2px;
  }

  .mobile-wallet-card__address {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-wallet-card__date {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 2px;
  }

  /* Transaction card variant */
  .mobile-tx-card {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .mobile-tx-card__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
  }

  .mobile-tx-card__icon--plus {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
  }

  .mobile-tx-card__icon--minus {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
  }

  .mobile-tx-card__body {
    flex: 1;
    min-width: 0;
  }

  .mobile-tx-card__remark {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-tx-card__meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
  }

  .mobile-tx-card__amount {
    font-size: 14px;
    font-weight: 700;
    text-align: right;
    flex-shrink: 0;
  }

  .mobile-tx-card__amount--credit {
    color: #2ecc71;
  }

  .mobile-tx-card__amount--debit {
    color: #e74c3c;
  }
}

/* ─── Skeleton Loaders ─── */
@media (max-width: 767px) {
  @keyframes skeleton-pulse {
    0% {
      opacity: 0.6;
    }

    50% {
      opacity: 1;
    }

    100% {
      opacity: 0.6;
    }
  }

  .skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 6px;
  }

  .skeleton--text {
    height: 14px;
    width: 100%;
    margin-bottom: 8px;
  }

  .skeleton--text-sm {
    height: 10px;
    width: 60%;
    margin-bottom: 6px;
  }

  .skeleton--circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
  }

  .skeleton--card {
    height: 100px;
    width: 100%;
  }

  .skeleton--badge {
    width: 60px;
    height: 20px;
    border-radius: 4px;
  }
}

/* ─── Chat Sticky Input on Mobile ─── */
@media (max-width: 767px) {
  .chatbox__bottom {
    position: sticky;
    bottom: 0;
    background: #1a1a2e;
    padding: 10px 0;
    z-index: 10;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  /* Ensure the chat container has proper bottom padding */
  .chatbox__inner-wrapper {
    padding-bottom: 0;
  }
}

/* ─── Sidebar Drawer on Mobile ─── */
@media (max-width: 767px) {
  .sidebar-menu {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 1060;
    background: #1a1a2e;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding-top: 16px;
  }

  .sidebar-menu--open {
    left: 0;
  }

  .sidebar-overlay--active {
    display: block !important;
    z-index: 1055;
    background: rgba(0, 0, 0, 0.5);
  }
}

/* ─── Trade Details Mobile Stacking ─── */
@media (max-width: 767px) {
  .buy-details .row>[class*="col-"] {
    width: 100%;
  }

  .buy-details__right-middle .list {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .buy-details__right-middle .list__item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
  }
}

/* ─── Form Optimizations ─── */
@media (max-width: 767px) {
  .form--control {
    font-size: 16px !important;
    /* prevent iOS zoom on focus */
  }

  .form-group {
    margin-bottom: 14px;
  }

  .form-group label {
    font-size: 13px;
    margin-bottom: 4px;
  }

  /* Stack labels above inputs on mobile */
  .form-group .input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .form-group .input-group>* {
    border-radius: 6px !important;
    margin: 0 !important;
  }
}

/* ─── Pull-to-Refresh Indicator ─── */
@media (max-width: 767px) {
  .ptr-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 0;
    overflow: hidden;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    transition: height 0.2s ease;
  }

  .ptr-indicator--visible {
    height: 50px;
  }

  .ptr-indicator__spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #5a4fdc;
    border-radius: 50%;
    animation: ptr-spin 0.6s linear infinite;
    margin-right: 8px;
  }

  @keyframes ptr-spin {
    to {
      transform: rotate(360deg);
    }
  }
}

/* ─── Pagination on Mobile ─── */
@media (max-width: 767px) {
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
  }

  .pagination .page-item .page-link {
    min-width: 36px;
    height: 36px;
    padding: 4px 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
}
}

/* ─── P2P Responsive Grid ─── */
@media (max-width: 767px) {

  .p2p-col-seller,
  .p2p-col-price,
  .p2p-col-limit,
  .p2p-col-payment,
  .p2p-col-trade {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
}

@media (min-width: 768px) {
  .p2p-offer-card__main-row {
    align-items: center !important;
  }
}

/* ─── P2P Dual-Card Support ─── */

/* Hide the global table header on mobile to prevent squashing */
@media (max-width: 767px) {
  .p2p-cards-header {
    display: none !important;
  }
}

/* Ensure desktop cards are row-based and aligned */
@media (min-width: 768px) {
  .p2p-offer-card.desktop-view {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
  }
}

/* Override global 44px min-height for P2P action buttons */
@media (max-width: 767px) {

  .p2p-offer-card .btn,
  .p2p-offer-card a,
  .p2p-offer-card button {
    min-height: 0 !important;
    min-width: 0 !important;
  }
}