/* Mobile-First Optimizations for GoatMouth Market */

/* Touch-friendly minimum sizes */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* Active touch feedback */
.active\:scale-98:active {
    transform: scale(0.98);
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1999;
    display: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    z-index: 2000;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

.mobile-menu.active {
    right: 0 !important;
}

/* Responsive breakpoints */
@media (max-width: 768px) {
    /* CRITICAL: Prevent horizontal overflow */
    html {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Show mobile navigation */
    .mobile-nav {
        display: block;
    }

    /* Hide desktop elements on mobile */
    .desktop-only {
        display: none !important;
    }

    /* Mobile header adjustments */
    .mobile-header {
        padding: 0.75rem 1rem;
    }

    .mobile-logo {
        height: 100px !important;
        width: 100px !important;
    }

    /* Mobile search */
    .mobile-search {
        width: 100%;
        padding: 0.75rem 1rem;
        padding-left: 2.5rem;
        font-size: 0.875rem;
    }

    /* Mobile buttons */
    .mobile-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
        min-height: 44px;
    }

    /* Mobile cards */
    .mobile-card {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }

/* Mobile Bottom Navigation - Show ONLY on mobile */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: block !important;
        position: fixed;
        bottom: 0; /* Flush with bottom */
        left: 0;
        right: 0;
        background: linear-gradient(180deg, rgba(17, 24, 39, 0.98) 0%, rgba(17, 24, 39, 1) 100%);
        backdrop-filter: blur(20px);
        border-top: 2px solid rgba(0, 203, 151, 0.2);
        padding: 0.375rem 0; /* More compact */
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4), 0 -1px 0 rgba(0, 203, 151, 0.1);
        opacity: 0;
        animation: fadeInNav 0.3s ease-in-out 0.1s forwards;
    }

    @keyframes fadeInNav {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .mobile-bottom-nav-container {
        display: flex;
        justify-content: space-evenly; /* Even spacing */
        align-items: center;
        max-width: 100%;
        margin: 0 auto;
        padding: 0;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.125rem; /* Tighter gap */
        padding: 0.375rem 0.5rem; /* More compact */
        flex: 1; /* Equal width for all items */
        max-width: 80px;
        color: #9ca3af;
        transition: all 0.2s ease;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        border: none;
        background: transparent;
        cursor: pointer;
    }

    .mobile-nav-item:active {
        transform: scale(0.95);
    }

    .mobile-nav-item svg,
    .mobile-nav-item img {
        width: 22px; /* Slightly smaller */
        height: 22px;
        stroke-width: 2;
        flex-shrink: 0;
    }

    .mobile-nav-item span {
        font-size: 0.625rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.025em;
        white-space: nowrap;
    }

    .mobile-nav-item.active {
        color: #00CB97;
    }

    .mobile-nav-item.active svg {
        filter: drop-shadow(0 0 8px rgba(0, 203, 151, 0.4));
    }

    /* Wallet balance styling - bigger text */
    #mobileWalletBalance,
    #mobileNavWallet span,
    #mobileNavWalletAdmin span {
        font-size: 0.75rem !important;
        font-weight: 700 !important;
        text-transform: none !important;
        color: #ffffff !important;
    }

    /* Mobile balance spinner */
    .mobile-wallet-text {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .mobile-balance-spinner {
        display: inline-block;
        animation: spin 1s linear infinite;
    }

    .mobile-balance-spinner.hidden {
        display: none;
    }

    .mobile-balance-spinner .spinner-circle {
        fill: none;
        stroke: currentColor;
        stroke-width: 3;
        stroke-dasharray: 50;
        stroke-dashoffset: 0;
        stroke-linecap: round;
        animation: dash 1.5s ease-in-out infinite;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }

    @keyframes dash {
        0% {
            stroke-dasharray: 1, 150;
            stroke-dashoffset: 0;
        }
        50% {
            stroke-dasharray: 90, 150;
            stroke-dashoffset: -35;
        }
        100% {
            stroke-dasharray: 90, 150;
            stroke-dashoffset: -124;
        }
    }

    .mobile-balance-text {
        display: inline;
    }
}

/* Hide on desktop */
@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}

/* Hide desktop footer on mobile */
@media (max-width: 768px) {
    footer {
        display: none !important;
    }

    /* Fix loading spinner for mobile */
    .spinner-container {
        width: 100%;
        max-width: 100%;
        padding: 1rem;
        box-sizing: border-box;
        overflow: hidden;
    }

    .inline-loader {
        width: 100%;
        max-width: 100%;
        padding: 1rem !important;
        box-sizing: border-box;
        overflow: hidden;
    }

    .spinner-glow {
        width: 40px !important;
        height: 40px !important;
        border-width: 3px !important;
    }

    .spinner-text {
        font-size: 0.75rem !important;
        text-align: center;
        max-width: 90%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .page-loader {
        padding: 1rem;
        box-sizing: border-box;
    }

    .page-loader .spinner-container {
        max-width: 100%;
    }

    /* Mobile typography */
    h1 {
        font-size: 1.875rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.25rem !important;
    }

    /* Mobile spacing */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Mobile profile dropdown */
    .profile-menu {
        width: 100vw !important;
        max-width: 100vw !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }

    /* Mobile balance */
    .mobile-balance {
        padding: 0.5rem 0.75rem !important;
    }

    .mobile-balance span {
        font-size: 0.75rem !important;
    }

    .mobile-balance .text-lg {
        font-size: 1rem !important;
    }

    /* Mobile grid adjustments */
    .grid {
        grid-template-columns: 1fr !important;
    }

    /* Mobile how it works */
    .mobile-how-it-works .flex {
        flex-direction: column;
    }

    .mobile-how-it-works img {
        width: 40px !important;
        height: 40px !important;
    }

    /* Mobile modals */
    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 1rem !important;
    }

    /* Mobile forms */
    input, textarea, select {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }

    /* Mobile tables */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Add padding to main content to account for footer + bottom nav */
    main {
        padding-bottom: 140px !important; /* Space for both footer and bottom nav */
    }

    /* Mobile category nav */
    .category-nav-mobile {
        display: block !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        visibility: visible !important;
    }

    .category-nav-mobile::-webkit-scrollbar {
        display: none;
    }

    /* Ensure category nav is visible on mobile */
    #category-nav {
        display: block !important;
    }

    /* Swipe indicator */
    .swipe-indicator {
        position: relative;
    }

    .swipe-indicator::after {
        content: '→';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        color: rgba(0, 203, 151, 0.5);
        font-size: 1.5rem;
        animation: swipe-hint 2s infinite;
    }

    @keyframes swipe-hint {
        0%, 100% {
            opacity: 0;
        }
        50% {
            opacity: 1;
        }
    }
}

/* Landscape mobile */
@media (max-width: 896px) and (orientation: landscape) {
    .mobile-header {
        padding: 0.5rem 1rem;
    }

    .mobile-logo {
        height: 60px !important;
        width: 60px !important;
    }
}

/* Small phones */
@media (max-width: 375px) {
    html {
        font-size: 14px;
    }

    .mobile-menu {
        width: 90%;
    }

    footer.fixed {
        font-size: 0.75rem;
    }
}

/* Mobile scrollbar hiding */
.category-nav-mobile::-webkit-scrollbar {
    display: none;
}

.category-nav-mobile {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Smooth scrolling for mobile */
@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
    }
}

/* Prevent text selection on buttons */
button, .touch-target, a {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Better mobile inputs */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea {
        font-size: 16px !important;
        -webkit-appearance: none;
        border-radius: 0.5rem;
    }
}

/* Mobile-specific animations */
@media (max-width: 768px) {
    .mobile-card {
        transition: transform 0.1s ease;
    }

    .mobile-card:active {
        transform: scale(0.98);
    }
}

/* Loading states for mobile */
@media (max-width: 768px) {
    .animate-pulse {
        animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    }

    @keyframes pulse {
        0%, 100% {
            opacity: 1;
        }
        50% {
            opacity: 0.5;
        }
    }

    /* Voting page mobile optimizations */
    .vote-tab {
        font-size: 0.875rem;
        padding: 0.75rem 1rem !important;
        min-height: 44px;
    }

    /* Voting page hero */
    .voting-hero h1 {
        font-size: 2rem !important;
    }

    .voting-hero p {
        font-size: 1rem !important;
    }

    /* Proposal cards on mobile */
    .proposal-card {
        padding: 1rem !important;
    }

    /* Voting buttons on mobile */
    button[data-action="vote-yes"],
    button[data-action="vote-no"] {
        min-height: 44px;
        font-size: 0.875rem;
    }

    /* Modal optimizations for voting */
    .voting-modal {
        max-height: 95vh;
        overflow-y: auto;
    }
}

/* Header Mobile Overflow Fix */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    .logo-header {
        overflow: visible !important;
        padding: 5px 8px !important;
        height: 48px !important;
        max-height: 48px !important;
    }

    .logo-header > div:first-child {
        overflow: hidden !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        margin-right: 4px !important;
    }

    .logo-header > div:last-child {
        overflow: visible !important;
        flex-shrink: 0 !important;
    }

    .user-info {
        gap: 4px !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        overflow: visible !important;
        max-width: fit-content !important;
    }

    .header-search-container {
        max-width: 110px !important;
        min-width: 90px !important;
        flex-shrink: 1 !important;
        margin-left: 6px !important;
    }

    .search-input {
        font-size: 12px !important;
        padding: 4px 6px 4px 28px !important;
        height: 30px !important;
        border-width: 1px !important;
    }

    .search-icon {
        font-size: 11px !important;
        left: 10px !important;
    }

    .logo-container {
        gap: 4px !important;
        flex-shrink: 1 !important;
        min-width: 0 !important;
    }

    .main-logo {
        width: 24px !important;
        height: 24px !important;
        flex-shrink: 0 !important;
    }

    .logo-text {
        font-size: 14px !important;
        white-space: nowrap !important;
    }

    .hamburger {
        width: 20px !important;
        height: 18px !important;
        margin-right: 4px !important;
        flex-shrink: 0 !important;
        padding: 2px !important;
        gap: 3px !important;
    }

    .hamburger span {
        height: 2px !important;
    }

    .auth-buttons {
        gap: 3px !important;
        flex-shrink: 0 !important;
    }

    .auth-btn {
        padding: 3px 10px !important;
        height: 26px !important;
        font-size: 11px !important;
        white-space: nowrap !important;
    }
}

/* Profile Dropdown Mobile Styles */
@media (max-width: 768px) {
    .user-profile-dropdown {
        flex-shrink: 0 !important;
        margin: 0 !important;
        padding: 0 14px 0 0 !important;
        overflow: visible !important;
        position: relative !important;
    }

    .profile-avatar-btn {
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        gap: 0 !important;
        border-radius: 50% !important;
        margin: 0 !important;
        border-width: 1.5px !important;
        overflow: visible !important;
        position: relative !important;
    }

    .avatar-img {
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
    }

    .online-indicator {
        width: 8px !important;
        height: 8px !important;
        right: 0px !important;
        bottom: 0px !important;
        left: auto !important;
        border-width: 2px !important;
    }

    .dropdown-chevron {
        position: absolute !important;
        right: -14px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        margin: 0 !important;
        pointer-events: none !important;
    }

    .dropdown-chevron svg {
        width: 12px !important;
        height: 12px !important;
    }

    .profile-dropdown-menu {
        position: fixed;
        top: 60px;
        right: 10px;
        left: auto;
        width: 280px;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 80px);
        margin: 0;
    }

}

@media (max-width: 375px) {
    .logo-header {
        padding: 6px 8px !important;
    }

    .user-info {
        gap: 4px !important;
        overflow: visible !important;
    }

    .header-search-container {
        max-width: 80px !important;
    }

    .search-input {
        font-size: 12px !important;
        padding: 5px 6px 5px 28px !important;
    }

    .search-icon {
        left: 8px !important;
        font-size: 12px !important;
    }

    .main-logo {
        width: 24px !important;
        height: 24px !important;
    }

    .logo-text {
        font-size: 14px !important;
    }

    .hamburger {
        width: 20px !important;
        height: 18px !important;
        margin-right: 6px !important;
    }

    .auth-buttons {
        gap: 3px !important;
    }

    .auth-btn {
        padding: 3px 10px !important;
        height: 26px !important;
        font-size: 11px !important;
    }

    .notification-bell-btn {
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
    }

    .notification-bell-btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    .notification-badge {
        min-width: 12px !important;
        height: 12px !important;
        font-size: 8px !important;
        padding: 0 2px !important;
    }

    .profile-avatar-btn {
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        gap: 0 !important;
        border-radius: 50% !important;
    }

    .avatar-img {
        width: 34px !important;
        height: 34px !important;
        border-radius: 50% !important;
    }

    .online-indicator {
        width: 7px !important;
        height: 7px !important;
        right: 0px !important;
        bottom: 0px !important;
        left: auto !important;
        border-width: 2px !important;
    }

    .dropdown-chevron {
        right: -13px !important;
    }

    .dropdown-chevron svg {
        width: 11px !important;
        height: 11px !important;
    }

    .profile-dropdown-menu {
        right: 8px;
        left: auto;
        max-width: calc(100vw - 16px);
    }
}

/* Notifications Mobile Styles */
@media (max-width: 768px) {
    .notifications-container {
        flex-shrink: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    .notification-bell-btn {
        width: 36px !important;
        height: 36px !important;
        border-radius: 8px !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    .notification-bell-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    .notification-badge {
        min-width: 12px !important;
        height: 12px !important;
        font-size: 8px !important;
        padding: 0 2px !important;
        top: 0px !important;
        right: 0px !important;
        border-width: 1px !important;
    }

    .notifications-dropdown {
        position: fixed;
        top: 60px;
        right: 10px;
        left: auto;
        width: 420px;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 80px);
        margin: 0;
    }
}

@media (max-width: 375px) {
    .notifications-dropdown {
        right: 8px;
        left: auto;
        max-width: calc(100vw - 16px);
    }
}

/* ============================================ */
/* MOBILE SKELETON LOADER OPTIMIZATIONS */
/* ============================================ */

/* Mobile skeleton adjustments */
@media (max-width: 768px) {
    /* Skeleton grid - single column on mobile */
    .skeleton-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.5rem 0;
    }

    /* Skeleton market cards - smaller on mobile */
    .skeleton-market-card {
        padding: 1rem;
        min-height: 180px;
    }

    /* Skeleton chart - smaller height on mobile */
    .skeleton-chart {
        height: 200px;
    }

    /* Skeleton stats - 2 columns on mobile */
    .skeleton-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* Skeleton stat cards - smaller on mobile */
    .skeleton-stat-card {
        padding: 0.75rem;
        min-height: 60px;
    }

    /* Skeleton text - smaller on mobile */
    .skeleton-text {
        height: 0.75rem;
        margin-bottom: 0.375rem;
    }

    .skeleton-text-lg {
        height: 1rem;
        margin-bottom: 0.5rem;
    }

    .skeleton-text-sm {
        height: 0.625rem;
        margin-bottom: 0.25rem;
    }

    /* Skeleton heading - smaller on mobile */
    .skeleton-heading {
        height: 1.25rem;
        margin-bottom: 0.75rem;
    }

    /* Skeleton avatars - slightly smaller on mobile */
    .skeleton-avatar-sm {
        width: 1.5rem;
        height: 1.5rem;
    }

    .skeleton-avatar-md {
        width: 2.5rem;
        height: 2.5rem;
    }

    .skeleton-avatar-lg {
        width: 3.5rem;
        height: 3.5rem;
    }

    /* Skeleton profile - stack on mobile */
    .skeleton-profile {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }

    /* Skeleton comment - smaller padding on mobile */
    .skeleton-comment {
        gap: 0.5rem;
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    /* Skeleton card - smaller padding on mobile */
    .skeleton-card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    /* Skeleton container - smaller padding on mobile */
    .skeleton-container {
        padding: 0.5rem;
    }

    /* Skeleton banner - smaller on mobile */
    .skeleton-banner {
        height: 150px;
        border-radius: 0.75rem;
        margin-bottom: 1rem;
    }

    /* Skeleton list - smaller gap on mobile */
    .skeleton-list {
        gap: 0.75rem;
    }

    /* Skeleton inline elements - smaller on mobile */
    .skeleton-inline {
        width: 3rem;
        height: 0.875rem;
    }

    .skeleton-inline-sm {
        width: 2.5rem;
        height: 0.625rem;
    }

    .skeleton-inline-lg {
        width: 5rem;
        height: 1rem;
    }

    /* Skeleton button - smaller on mobile */
    .skeleton-button {
        height: 2.25rem;
    }

    .skeleton-button-sm {
        height: 1.75rem;
    }

    /* Skeleton box sizes - smaller on mobile */
    .skeleton-box-sm {
        height: 3rem;
    }

    .skeleton-box-md {
        height: 6rem;
    }

    .skeleton-box-lg {
        height: 10rem;
    }
}

}

/* Extra small mobile devices */
@media (max-width: 375px) {
    .skeleton-market-card {
        padding: 0.875rem;
        min-height: 160px;
    }

    .skeleton-chart {
        height: 180px;
    }

    .skeleton-stats {
        grid-template-columns: 1fr;
    }

    .skeleton-banner {
        height: 120px;
    }
}
