/* ============================================
   BLORPS App - Responsive Styles
   Media Queries for All Screen Sizes
   ============================================ */

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    padding: 16px 20px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 3px solid var(--green-main); }
.toast.error { border-left: 3px solid #ef4444; }
.toast.warning { border-left: 3px solid var(--yellow-main); }

.toast-icon {
    width: 24px;
    height: 24px;
}

.toast-message {
    flex: 1;
    font-size: 14px;
}

/* ============================================
   Responsive - New Components
   ============================================ */
@media (max-width: 1200px) {
    .marketplace-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .my-listing-card {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }

    .listing-price-info,
    .listing-actions {
        grid-column: 2;
    }

    .expand-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .marketplace-tabs {
        flex-wrap: wrap;
    }

    .marketplace-filters {
        flex-direction: column;
        align-items: stretch;
    }

    /* Currency pills (All/AVAX/ROE/BANDS): 2x2 instead of a 4-tall stack. */
    .marketplace-toolbar .marketplace-filters {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    .marketplace-toolbar .marketplace-filter {
        justify-content: center;
    }

    .filter-group {
        flex-direction: column;
    }

    .marketplace-grid {
        grid-template-columns: 1fr;
    }

    .history-header,
    .history-row {
        grid-template-columns: 80px 1fr 100px;
    }

    .history-date,
    .history-row .history-date {
        display: none;
    }

    .wallet-blorps-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .battle-status {
        flex-direction: column;
        gap: 16px;
    }

    .vs-badge {
        transform: rotate(90deg);
    }
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .raid-layout {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }

    .raid-team-selector {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    #raidingTab > h2 {
        font-size: 32px !important;
        letter-spacing: 2px !important;
    }

    .history-card {
        flex: 0 0 300px !important;
    }

    .raid-target-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
    }

    .target-loot {
        text-align: left !important;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .attack-btn {
        width: 100%;
        margin-top: 8px;
    }
}

/* The old "Premium Arena" battle-card theme (350 lines of !important
   purple/pink overrides) lived here and silently bulldozed the on-brand
   battle-card styles in raiding.css. Removed - raiding.css owns the
   battle card now. */

/* ============================================
   Network Warning Responsive
   ============================================ */
@media (max-width: 768px) {
    .network-warning {
        left: 0;
        flex-direction: column;
        padding: 16px;
        padding-right: 48px;
        gap: 12px;
    }

    .network-warning-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .switch-network-btn {
        width: 100%;
        justify-content: center;
    }

    .network-warning-close {
        top: 12px;
        right: 12px;
    }
}

/* ============================================
   Mobile Hamburger Menu
   ============================================ */

/* Hide hamburger by default on desktop */
.mobile-menu-btn {
    display: none;
}

/* Mobile overlay when menu is open */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Canonical focus + disabled for header / responsive buttons.
   Mirrors the shared .btn treatment in components.css - universal-safe props
   only, so each button keeps its own size, shape and color. */
.mobile-menu-btn:focus-visible,
.header-action-btn:focus-visible,
.switch-network-btn:focus-visible,
.attack-btn:focus-visible {
    outline: 2px solid var(--green-main);
    outline-offset: 2px;
}

.mobile-menu-btn:disabled,
.mobile-menu-btn[aria-disabled="true"],
.header-action-btn:disabled,
.header-action-btn[aria-disabled="true"],
.switch-network-btn:disabled,
.switch-network-btn[aria-disabled="true"],
.attack-btn:disabled,
.attack-btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}

@media (max-width: 768px) {
    /* Show hamburger button on mobile */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        color: var(--text-main);
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-menu-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.2);
    }

    .mobile-menu-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Hide sidebar by default on mobile - use !important to override other CSS */
    .sidebar {
        display: flex !important;
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 999 !important;
        transition: left 0.3s ease !important;
        background: var(--bg-sidebar) !important;
    }

    /* Show sidebar when active */
    .sidebar.mobile-open {
        left: 0 !important;
    }

    /* Show overlay when menu is open */
    .mobile-menu-overlay.active {
        display: block;
    }

    /* Adjust main content to take full width */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Adjust header */
    .app-header {
        padding: 12px 16px;
    }

    /* Hide some header elements on mobile */
    .header-divider {
        display: none;
    }

    /* Hide token balances on mobile, show deposit/withdraw buttons instead */
    .token-balances {
        display: none !important;
    }

    /* Mobile header layout - balanced spacing */
    .header-right {
        gap: 8px !important;
    }

    .header-actions {
        display: flex !important;
        gap: 6px;
    }

    /* Compact mobile action buttons - more breathing room */
    .header-actions .header-action-btn {
        padding: 9px 12px;
        font-size: 10px;
        font-weight: 700;
        gap: 5px;
        border-radius: 8px;
        letter-spacing: 0.03em;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    }

    .header-actions .header-action-btn svg {
        width: 12px;
        height: 12px;
        flex-shrink: 0;
    }

    /* Slightly smaller notification and wallet on mobile */
    .notification-bell {
        width: 38px !important;
        height: 38px !important;
    }

    .connect-wallet {
        padding: 8px 12px !important;
    }

    /* ============================================
       Deposit/Withdraw Modal - the old mobile-optimized shell overrides
       (edge-to-edge width, 14px body, 42vh grid) were removed 2026-07-06
       so these modals inherit the SAME shell as the Transfer modal,
       which reads far better on phones.
       ============================================ */
    /* Info banner - compact but readable */
    .deposit-info-banner {
        padding: 12px 14px;
        font-size: 12px;
        line-height: 1.4;
        gap: 10px;
        border-radius: 10px;
        margin-bottom: 16px;
    }

    .deposit-info-banner svg {
        width: 16px;
        height: 16px;
        margin-top: 1px;
    }

    .deposit-section h4 {
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 12px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-secondary);
    }

    /* Blorp grid - 2 columns that actually fit. (The old per-element
       "compression" overrides that shrank showcase/svg/name/stats were
       removed 2026-07-06 - deposit/withdraw now render the same mini
       cards as the transfer modal.) */
    #depositModal .wallet-blorps-grid,
    #withdrawModal .wallet-blorps-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        overflow-x: hidden;
    }

    /* Card wrappers - prevent any overflow */
    #depositModal .blorp-card-wrapper.mini,
    #withdrawModal .blorp-card-wrapper.mini {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* Selection checkmark - smaller */
    #depositModal .blorp-card-wrapper.mini.selected::after,
    #withdrawModal .blorp-card-wrapper.mini.selected::after {
        width: 18px;
        height: 18px;
        font-size: 10px;
        top: 6px;
        right: 6px;
    }

    /* Actions footer - stacked for thumb reach */
    .deposit-actions {
        flex-direction: column;
        gap: 10px;
        padding-top: 14px;
        margin-top: 14px;
    }

    .deposit-actions .selected-count {
        text-align: center;
        font-size: 12px;
        color: var(--text-secondary);
    }

    .deposit-actions .deposit-btn,
    .deposit-actions .withdraw-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 13px;
        font-weight: 700;
        border-radius: 10px;
    }

    /* ============================================
       Notification Panel - Mobile Fix
       ============================================ */
    .notification-panel {
        position: fixed !important;
        top: 70px !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 90px) !important;
        border-radius: 14px;
    }

    .notification-panel-header {
        padding: 14px 16px;
    }

    .notification-panel-header h3 {
        font-size: 16px;
    }

    .notification-list {
        max-height: calc(100vh - 180px);
    }

    .notification-item {
        padding: 12px 14px;
    }

    .notification-item .notification-icon {
        width: 32px;
        height: 32px;
    }

    .notification-item .notification-title {
        font-size: 13px;
    }

    .notification-item .notification-message {
        font-size: 12px;
    }

    /* ============================================
       Dashboard Stat Cards - Mobile Optimization
       ============================================ */
    .stat-card {
        overflow: hidden;
    }

    .stat-card-inner {
        grid-template-columns: auto 1fr auto;
        gap: 4px 10px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .stat-icon svg {
        width: 22px;
        height: 22px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-label {
        font-size: 10px;
    }

    /* Hide time badge on mobile - cleaner layout */
    #activeMinesTimeBadge {
        display: none !important;
    }

    /* Other stat badges - keep compact */
    .stat-change {
        padding: 4px 8px;
        font-size: 9px;
    }

    /* Wallet button compact */
    .connect-wallet span:not(.wallet-address) {
        display: none;
    }

    .wallet-connected .connect-wallet {
        padding: 8px 12px;
    }
}

/* Mobile text show/hide helpers */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-hide {
        display: none !important;
    }

    .mobile-only {
        display: inline !important;
    }
}

@media (max-width: 480px) {
    /* Even more compact on very small screens */
    .token-balance {
        padding: 4px 8px;
    }

    .token-icon {
        width: 20px;
        height: 20px;
    }

    .token-amount {
        font-size: 12px;
    }

    .mobile-menu-btn {
        width: 36px;
        height: 36px;
    }
}

/* ============================================
   Mining Page Mobile Fixes
   ============================================ */
@media (max-width: 768px) {
    /* Mining layout - single column on mobile */
    .mining-layout {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }

    /* Team selector - allow horizontal scroll */
    .team-selector {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    /* Team slots - slightly smaller on mobile */
    .team-slot {
        width: 80px;
        height: 80px;
        min-width: 80px;
        flex-shrink: 0;
    }

    /* Start mining card - reduce padding */
    .start-mining-card {
        padding: 20px;
    }

    /* Mining step - stack on small screens */
    .mining-step {
        gap: 12px;
    }

    .step-number {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .step-content h4 {
        font-size: 14px;
    }

    .step-content p {
        font-size: 12px;
    }

    /* Content area - reduce padding on mobile */
    .content-area {
        padding: 16px !important;
    }

    /* Page header adjustments */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .page-title h1 {
        font-size: 28px;
    }

    .page-title p {
        font-size: 13px;
    }
}

/* ============================================
   My Blorps Page Mobile Fixes
   ============================================ */
@media (max-width: 768px) {
    /* Ensure page containers don't overflow */
    .content-area,
    .blorps-page,
    .my-blorps-page {
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Filter bar - flex wrap with toggle on top */
    .filter-bar {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }

    /* Overlay toggle - full width, move to top */
    .filter-bar .overlay-toggle {
        order: -1;
        width: 100%;
        margin-left: 0;
        padding-left: 0;
        padding-bottom: 12px;
        margin-bottom: 4px;
        border-left: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .overlay-toggle .toggle-label {
        font-size: 13px;
    }

    /* Filter selects - 2 per row */
    .filter-bar .filter-select {
        flex: 1 1 calc(50% - 4px);
        min-width: calc(50% - 4px);
        max-width: calc(50% - 4px);
        padding: 10px 12px;
        font-size: 12px;
    }

    /* Blorps grid - proper containment */
    .blorps-grid,
    .wallet-blorps-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Blorp cards - ensure they stay within grid cells */
    .blorp-card-wrapper {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Blorp card mobile sizing: mobile 2-col cards are WIDE (~half the
       viewport), so the old 80px showcase/svg override made the salmon
       tiny and the card look squished. Give the image MORE room instead. */
    .blorp-card-inner {
        padding: 12px;
    }

    .blorp-showcase {
        height: 150px;
    }

    .blorp-card-name {
        font-size: 13px;
    }

    .blorp-card-stats {
        padding: 8px 10px;
    }

    .stat-value {
        font-size: 18px;
    }
}

@media (max-width: 400px) {
    /* Single column on very small screens */
    .blorps-grid,
    .wallet-blorps-grid {
        grid-template-columns: 1fr !important;
    }

    /* Deposit/withdraw modal single column on very small screens */
    #depositModal .wallet-blorps-grid,
    #withdrawModal .wallet-blorps-grid {
        grid-template-columns: 1fr !important;
        max-height: 50vh;
    }

    /* Even smaller filter selects */
    .filter-select {
        min-width: 100px;
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Team slots smaller */
    .team-slot {
        width: 70px;
        height: 70px;
        min-width: 70px;
    }
}

/* ============================================
   Mobile touch targets
   ============================================
   The default 36×36 modal-close button hits Apple's 44×44 HIG / Material's
   48×48 touch-target minimum only on a perfect tap. Bumping to 44×44 on
   touch-sized viewports gives mobile users a comfortable target. (Backdrop
   tap-to-close from app.js is the primary close affordance on mobile, but
   the X button still needs to be reliably tappable as the secondary path.) */
@media (max-width: 768px) {
    .modal-close {
        width: 44px;
        height: 44px;
    }
    .modal-close svg {
        width: 24px;
        height: 24px;
    }
}

/* ============================================
   Small phones (~iPhone width): the header's three labeled action
   buttons need ~300px, which doesn't fit beside the burger, bell, and
   wallet chip - the whole app panned sideways. Go icon-only (labels
   live in title attributes) and clip any residual horizontal overflow
   so nothing can drag the viewport again.
   ============================================ */
@media (max-width: 480px) {
    .header-actions .header-action-btn {
        font-size: 0;      /* hides the bare text node, keeps the svg */
        gap: 0;
        padding: 10px 12px;
    }

    .header-actions .header-action-btn svg {
        width: 18px;
        height: 18px;
        margin: 0;
    }

    .app-header {
        overflow-x: clip;
    }

    /* Marketplace sub-tabs: five labels don't fit a phone at desktop
       size - share the row evenly at a smaller size so ALL stay visible
       (no swiping). */
    .marketplace-section-tabs {
        gap: 0;
    }
    .marketplace-section-tab {
        flex: 1;
        min-width: 0;
        padding: 8px 2px;
        font-size: 12.5px;
        text-align: center;
        justify-content: center;
    }
    .marketplace-section-tab .marketplace-section-tab-count {
        font-size: 9px;
        padding: 1px 4px;
        margin-left: 2px;
    }

    body {
        overflow-x: clip;  /* safety net for the whole app */
    }
}
