/* ===== MOBILE ADAPTATION - COMPLETE REWRITE ===== */

/* Hide mobile elements on desktop */
.mobile-cards,
.mobile-stats {
    display: none;
}

/* ========== TABLET & MOBILE (< 992px) ========== */
@media (max-width: 992px) {
    /* Hide mobile menu button */
    .mobile-menu-btn {
        display: none !important;
    }
    
    .sidebar {
        display: none;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .main-page .header {
        height: 52px;
    }
    
    .main-page .nav {
        height: 52px;
        padding: 0 12px;
    }
    
    .main-page .logo-icon {
        width: 36px;
        height: 36px;
    }
}

/* ========== MOBILE (< 768px) ========== */
@media (max-width: 768px) {
    /* Base - prevent iOS zoom */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* Header - compact fixed */
    .header {
        height: 52px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
    }
    
    .nav {
        height: 52px;
        padding: 0 12px;
        display: flex;
        align-items: center;
    }
    
    .logo {
        gap: 8px;
    }
    
    .logo-text {
        display: block;
        font-size: 14px;
    }
    
    /* Wallet button - always visible with text */
    .btn-wallet {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 0 12px;
        height: 38px;
        background: transparent;
        border: 2px solid var(--accent-primary);
        color: var(--accent-primary);
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        
        white-space: nowrap;
        flex-shrink: 0;
        min-width: 38px;
    }
    
    .btn-wallet i {
        font-size: 14px;
    }
    
    .btn-wallet span {
        display: inline;
    }
    
    .btn-wallet.connected {
        background: var(--accent-primary);
        color: #000;
        animation: none;
    }
    
    /* Nav actions - wallet positioning */
    .nav-actions {
        margin-left: auto;
        display: flex;
        align-items: center;
        order: 2;
    }
    
    /* Mobile menu button */
    .mobile-menu-btn {
        display: flex;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--accent-primary);
        color: var(--accent-primary);
        background: transparent;
        margin-left: 8px;
        flex-shrink: 0;
        order: 3;
    }
    
    /* Layout - with ticker bar */
    .main-layout {
        margin-top: 80px;
        min-height: calc(100vh - 80px);
    }
    
    /* Content area */
    .tab-content {
        padding: 12px;
    }
    
    .content-header {
        flex-direction: row;
        gap: 8px;
        margin-bottom: 12px;
        flex-wrap: nowrap;
    }
    
    .search-box {
        max-width: none;
        flex: 1;
        min-width: 0;
    }
    
    .search-box input {
        padding: 12px 12px 12px 40px;
        font-size: 14px;
        height: 44px;
        width: 100%;
    }
    
    .search-box input::placeholder {
        font-size: 12px;
    }
    
    .content-actions {
        gap: 4px;
        flex-shrink: 0;
        display: flex;
    }
    
    .content-actions .btn {
        padding: 0;
        height: 44px;
        width: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .content-actions .btn span {
        display: none;
    }
    
    /* Hide refresh and export buttons on mobile */
    .content-actions {
        display: none;
    }
    
    /* Content tabs - scrollable */
    .content-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 0;
        padding: 0;
        background: var(--bg-secondary);
        border-bottom: 2px solid var(--border);
    }
    
    .content-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        padding: 14px 18px;
        font-size: 11px;
        letter-spacing: 1px;
        white-space: nowrap;
        flex-shrink: 0;
        border-bottom: 2px solid transparent;
        margin-bottom: -2px;
    }
    
    /* Mobile stats bar */
    .mobile-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .mobile-stat-box {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 12px 8px;
        text-align: center;
    }
    
    .mobile-stat-label {
        font-size: 9px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        display: block;
        margin-bottom: 4px;
    }
    
    .mobile-stat-value {
        font-size: 14px;
        font-weight: 700;
        color: var(--accent-primary);
        font-family: var(--font-primary);
    }
    
    /* Hide desktop table on mobile */
    .table-container {
        display: none;
    }
    
    /* Show mobile cards */
    .mobile-cards {
        display: block;
    }
    
    .mobile-card {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-left: 3px solid var(--accent-primary);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 14px;
    }
    
    .mobile-card:active {
        background: var(--bg-hover);
    }
    
    .mobile-card-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
    }
    
    .mobile-card-token {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    
    .mobile-card-logo {
        width: 40px;
        height: 40px;
        border: 2px solid var(--border);
        border-radius: 4px;
        overflow: hidden;
        background: var(--bg-input);
        flex-shrink: 0;
    }
    
    .mobile-card-logo img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .mobile-card-info h3 {
        font-size: 14px;
        font-weight: 700;
        margin: 0;
        color: var(--text-primary);
    }
    
    .mobile-card-info span {
        font-size: 11px;
        color: var(--text-muted);
    }
    
    .mobile-card-rank {
        font-size: 18px;
        font-weight: 900;
        color: var(--accent-primary);
        opacity: 0.5;
    }
    
    .mobile-card-price {
        font-size: 20px;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 12px;
        font-family: var(--font-primary);
    }
    
    .mobile-card-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .mobile-card-stat {
        text-align: center;
        padding: 10px 6px;
        background: var(--bg-input);
        border-radius: 4px;
    }
    
    .mobile-card-stat-label {
        display: block;
        font-size: 9px;
        color: var(--text-muted);
        text-transform: uppercase;
        margin-bottom: 4px;
        letter-spacing: 0.5px;
    }
    
    .mobile-card-stat-value {
        display: block;
        font-size: 12px;
        font-weight: 700;
        color: var(--text-primary);
        font-family: var(--font-primary);
    }
    
    .mobile-card-change {
        font-size: 14px;
        font-weight: 700;
    }
    
    .mobile-card-change.positive {
        color: var(--accent-primary);
    }
    
    .mobile-card-change.negative {
        color: var(--danger);
    }
    
    .mobile-card-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }
    
    .mobile-card-dex {
        font-size: 10px;
        padding: 4px 8px;
        border-radius: 4px;
        background: var(--bg-input);
        border: 1px solid var(--border);
    }
    
    .mobile-card-actions {
        display: flex;
        gap: 8px;
    }
    
    .mobile-card-btn {
        width: 36px;
        height: 36px;
        border: 1px solid var(--border);
        background: var(--bg-input);
        color: var(--text-secondary);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
    }
    
    .mobile-card-btn:active {
        border-color: var(--accent-primary);
        color: var(--accent-primary);
    }
    
    /* Pagination */
    .pagination {
        padding: 16px 12px;
        gap: 12px;
    }
    
    .page-info {
        font-size: 11px;
    }
    
    /* Toast - better mobile positioning */
    .toast-container {
        top: 60px;
        right: 12px;
        left: 12px;
    }
    
    .toast {
        font-size: 12px;
        padding: 14px;
    }
    
    /* Refresh indicator */
    .refresh-indicator {
        bottom: 16px;
        right: 16px;
        padding: 10px 14px;
        font-size: 10px;
    }
    
    /* Modal */
    .modal {
        padding: 12px;
        align-items: flex-end;
    }
    
    .modal-content {
        max-height: 90vh;
        margin: 0;
        border-radius: 12px 12px 0 0;
        max-width: 100%;
    }
    
    .search-modal-content {
        max-width: 100%;
        border-radius: 12px 12px 0 0;
    }
    
    .search-header input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Empty state */
    .empty-state {
        padding: 60px 20px;
    }
    
    .empty-state > i {
        font-size: 48px;
    }
    
    /* Holdings tab */
    .holdings-summary {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 16px;
    }
    
    .summary-card {
        padding: 14px 8px;
    }
    
    .summary-card .label {
        font-size: 9px;
        letter-spacing: 0.5px;
    }
    
    .summary-card .value {
        font-size: 16px;
    }
    
    /* Info tab */
    .info-container {
        padding: 0;
    }
    
    .info-tweet {
        padding: 16px;
        border-radius: 8px;
        margin-bottom: 12px;
    }
    
    .tweet-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .tweet-name {
        font-size: 14px;
    }
    
    .tweet-content {
        font-size: 13px;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* ========== SMALL MOBILE (< 480px) ========== */
@media (max-width: 480px) {
    /* Header more compact */
    .btn-wallet {
        padding: 0 12px;
        font-size: 10px;
        height: 36px;
    }
    
    .btn-wallet i {
        font-size: 13px;
    }
    
    .mobile-menu-btn {
        width: 36px;
        height: 36px;
    }
    
    /* Search placeholder smaller */
    .search-box input::placeholder {
        font-size: 11px;
    }
    
    .mobile-card-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mobile-card-stat:last-child {
        grid-column: span 2;
    }
    
    .mobile-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mobile-stat-box:last-child {
        grid-column: span 2;
    }
    
    .holdings-summary {
        grid-template-columns: 1fr;
    }
    
    .summary-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 16px;
    }
    
    .summary-card .label {
        margin-bottom: 0;
    }
    
    /* Tabs - smaller */
    .tab-btn {
        padding: 12px 14px;
        font-size: 10px;
    }
    
    /* Header even more compact */
    .btn-wallet {
        padding: 0 12px;
        font-size: 10px;
        height: 36px;
    }
    
    .btn-wallet i {
        font-size: 13px;
    }
    
    .mobile-menu-btn {
        width: 36px;
        height: 36px;
    }
}

/* ========== VERY SMALL (< 360px) ========== */
@media (max-width: 360px) {
    .tab-btn {
        padding: 10px 12px;
        font-size: 10px;
    }
    
    /* Wallet button - icon only */
    .btn-wallet {
        width: 40px;
        padding: 0;
        justify-content: center;
    }
    
    .btn-wallet span {
        display: none;
    }
    
    .mobile-card {
        padding: 12px;
    }
    
    .mobile-card-logo {
        width: 36px;
        height: 36px;
    }
    
    .mobile-card-info h3 {
        font-size: 13px;
    }
    
    .mobile-card-price {
        font-size: 18px;
    }
    
    .mobile-card-stats {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========== TOUCH OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {
    .mobile-card {
        cursor: pointer;
    }
    
    .mobile-card-btn:active {
        background: var(--accent-primary);
        color: #000;
    }
    
    .tab-btn:active {
        background: var(--bg-tertiary);
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    /* Larger touch targets */
    .action-btn,
    .mobile-card-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ========== LANDSCAPE ========== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        height: 44px;
    }
    
    .nav {
        height: 44px;
    }
    
    .main-layout {
        margin-top: 44px;
    }
    
    .mobile-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .mobile-card {
        margin-bottom: 0;
    }
}

/* ========== SAFE AREA (iPhone X+) ========== */
@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .header {
            padding-top: env(safe-area-inset-top);
        }
        
        .main-layout {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* DEX Badge styles for mobile cards */
.mobile-card-dex {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 3px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* DEX-specific colors */
.mobile-card-dex.raydium {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--info);
    color: var(--info);
}

.mobile-card-dex.orca {
    background: rgba(139, 122, 181, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mobile-card-dex.jupiter {
    background: rgba(139, 122, 181, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mobile-card-dex.phoenix {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.mobile-card-dex.meteora {
    background: rgba(255, 165, 0, 0.1);
    border-color: #ffa500;
    color: #ffa500;
}

.mobile-card-dex.whirlpool {
    background: rgba(0, 255, 128, 0.1);
    border-color: #00ff80;
    color: #00ff80;
}

.mobile-card-dex.unknown {
    background: rgba(128, 128, 128, 0.1);
    border-color: #808080;
    color: #808080;
}

/* HEADER FIX - Override style.css */
@media (max-width: 768px) {
    body .nav {
        flex-wrap: nowrap !important;
        height: 52px !important;
        padding: 0 12px !important;
        justify-content: flex-start !important;
    }
    
    body .nav-actions {
        margin-left: auto !important;
        width: auto !important;
        order: 2;
    }
    
    body .mobile-menu-btn {
        order: 3;
        margin-left: 8px;
    }
}

@media (max-width: 480px) {
    body .nav {
        height: 48px !important;
        padding: 0 8px !important;
    }
}

/* ========== MOBILE TICKER ADJUSTMENTS ========== */
@media (max-width: 768px) {
    .main-page .ticker-bar {
        top: 52px;
        height: 28px;
    }
    
    .main-page .ticker-content {
        padding: 8px 12px;
        gap: 20px;
    }
    
    .main-page .ticker-item {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    /* Hide ticker on small screens */
    .main-page .ticker-bar {
        display: none;
    }
    
    /* Adjust layout without ticker */
    .main-layout {
        margin-top: 48px;
        min-height: calc(100vh - 48px);
    }
}

