/**
 * MagicX Token Generator - Advanced Mobile & Tablet Responsive Engine
 * Fully optimized for touchscreens, mobile viewports (320px - 430px), and tablets.
 */

/* ==========================================================================
   1. TABLET & COMPACT DESKTOP (max-width: 900px)
   ========================================================================== */
@media (max-width: 900px) {
  .magicx-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .nav-pills {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 6px;
  }

  .nav-pills::-webkit-scrollbar {
    display: none;
  }

  .nav-tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 7px 14px;
    font-size: 0.82rem;
  }

  .main-content {
    padding: 16px 14px 60px;
  }

  .deposit-grid {
    grid-template-columns: 240px 1fr;
    gap: 20px;
  }
}

/* ==========================================================================
   2. MOBILE DEVICES (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Header Layout */
  .magicx-header {
    padding: 10px 14px;
    gap: 10px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-icon svg {
    width: 18px;
    height: 18px;
  }

  .brand-title {
    font-size: 1.12rem;
  }

  .brand-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .network-selector-btn {
    padding: 6px 10px;
    font-size: 0.76rem;
    gap: 4px;
  }

  .wallet-btn {
    padding: 6px 12px;
    font-size: 0.78rem;
    gap: 6px;
    white-space: nowrap;
  }

  .wallet-connected-pill {
    padding: 5px 10px;
    font-size: 0.74rem;
  }

  /* Navigation Pills Dock */
  .nav-pills {
    background: rgba(13, 18, 30, 0.9);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    padding: 4px;
    gap: 4px;
  }

  .nav-tab-btn {
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: var(--radius-full);
  }

  .nav-tab-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Card Containers */
  .glass-card {
    padding: 16px 14px;
    border-radius: 16px;
  }

  .card-header {
    margin-bottom: 16px;
  }

  .card-title {
    font-size: 1.15rem;
  }

  /* VIEW 1: Generator */
  .generator-container,
  .generator-card {
    width: 100%;
    max-width: 100%;
    margin: 10px auto;
  }

  .generator-card .card-header,
  .generator-container .card-header {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
  }

  .asset-box {
    padding: 14px 16px;
    margin-bottom: 8px;
  }

  .asset-input {
    font-size: 1.25rem;
    min-width: 0;
    width: 0;
    flex: 1 1 0%;
  }

  .token-pill-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .token-pill-btn img {
    width: 22px;
    height: 22px;
  }

  .pct-selector-group {
    display: flex;
    gap: 4px;
    width: 100%;
    margin-top: 8px;
  }

  .pct-btn {
    flex: 1;
    min-width: 0;
    padding: 6px 2px;
    font-size: 0.72rem;
    text-align: center;
  }

  .generator-divider {
    margin: 12px 0;
  }

  .quote-details-card {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 16px;
  }

  .quote-row {
    font-size: 0.76rem;
    padding: 4px 0;
  }

  .btn-primary-action {
    padding: 14px;
    font-size: 0.95rem;
    border-radius: 12px;
  }

  /* VIEW 2: Deposit Center */
  .deposit-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  .deposit-qr-box {
    padding: 20px 14px !important;
    border-radius: 14px !important;
  }

  .qr-wrapper {
    padding: 10px !important;
    margin-bottom: 10px !important;
  }

  .qr-wrapper img,
  .qr-wrapper canvas {
    max-width: 160px !important;
    max-height: 160px !important;
  }

  .deposit-net-tabs {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 18px !important;
  }

  .deposit-net-pill {
    min-width: 0 !important;
    padding: 8px 6px !important;
    font-size: 0.76rem !important;
    width: 100% !important;
    text-align: center !important;
    border-radius: 6px !important;
  }

  .deposit-info-item {
    margin-bottom: 14px !important;
  }

  .deposit-value {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 14px !important;
    border-radius: 10px !important;
  }

  .deposit-address-text {
    font-size: 0.8rem !important;
    text-align: center !important;
    word-break: break-all !important;
    line-height: 1.4 !important;
  }

  .copy-btn-action {
    width: 100% !important;
    justify-content: center !important;
    padding: 9px 14px !important;
    font-size: 0.82rem !important;
    border-radius: 8px !important;
  }

  /* VIEW 3: Transfer Asset */
  .transfer-container {
    margin: 10px auto;
  }

  .transfer-container .text-input {
    font-size: 0.82rem;
    padding: 10px 12px;
  }

  /* VIEW 4: Portfolio */
  #portfolioListContainer .glass-card {
    padding: 12px 14px;
    margin-bottom: 8px;
  }

  /* VIEW 5: Activity Table */
  .table-responsive {
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: rgba(8, 11, 17, 0.6);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .magicx-table {
    min-width: 620px;
  }

  .magicx-table th,
  .magicx-table td {
    padding: 10px 12px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  /* Modals */
  .modal-overlay {
    padding: 12px;
  }

  .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    padding: 18px 14px !important;
    border-radius: 16px !important;
  }

  .wallet-provider-btn {
    padding: 12px 14px !important;
  }

  #tokenSearchInput {
    font-size: 16px !important; /* Prevents auto-zoom on iOS */
  }

  /* System Footer */
  footer {
    padding: 16px 12px !important;
  }

  footer > div {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: center !important;
    text-align: center !important;
  }

  footer > div > div:first-child {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px 12px !important;
    font-size: 0.72rem !important;
    width: 100% !important;
    justify-content: center !important;
  }

  footer > div > div:first-child span {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
  }

  footer > div > div:last-child {
    font-size: 0.75rem !important;
    justify-content: center !important;
    gap: 14px !important;
  }
}

/* ==========================================================================
   3. EXTRA SMALL SCREENS (max-width: 380px)
   ========================================================================== */
@media (max-width: 380px) {
  .brand-title {
    font-size: 1rem;
  }

  .network-selector-btn {
    padding: 5px 8px;
    font-size: 0.72rem;
  }

  .wallet-btn {
    padding: 5px 10px;
    font-size: 0.74rem;
  }

  .deposit-net-tabs {
    grid-template-columns: 1fr !important;
  }

  .deposit-net-pill:last-child {
    grid-column: span 1 !important;
  }
}
