/* 
 * Mobile Responsive Styles for AI Agriculture Platform
 * Optimized for mobile devices with 8-card horizontal layout
 */

/* Base mobile styles */
@media (max-width: 768px) {
    /* Page layout adjustments */
    .main-content {
        padding: 15px !important;
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .category-header {
        padding: 30px 20px !important;
        margin-bottom: 20px !important;
        border-radius: 15px !important;
    }
    
    .category-title {
        font-size: 1.8em !important;
    }
    
    .category-subtitle {
        font-size: 1em !important;
    }
    
    .category-icon {
        font-size: 3em !important;
        margin-bottom: 15px !important;
    }
    
    /* AI recommendation section mobile */
    .ai-recommendation-section {
        padding: 20px !important;
        margin-bottom: 20px !important;
        border-radius: 15px !important;
    }
    
    .ai-filters {
        padding: 20px !important;
        border-radius: 12px !important;
    }
    
    .filter-group {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .filter-select {
        padding: 12px !important;
        font-size: 16px !important;
    }
    
    /* Mobile product grid - 8 cards horizontal scroll */
    .products-grid {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        overflow-x: auto !important;
        padding: 15px 0 !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 20px 0 !important;
    }
    
    .product-card {
        min-width: calc((100vw - 120px) / 8) !important;
        width: calc((100vw - 120px) / 8) !important;
        max-width: 38px !important;
        height: 70px !important;
        flex-shrink: 0 !important;
        scroll-snap-align: start !important;
        border-radius: 6px !important;
        padding: 2px !important;
        margin: 0 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
    }
    
    .product-image {
        height: 16px !important;
        font-size: 11px !important;
        margin-bottom: 1px !important;
        border-radius: 4px 4px 0 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .ai-badge, .yield-badge, .efficiency-badge, .safety-badge {
        position: absolute !important;
        top: 1px !important;
        right: 1px !important;
        padding: 1px 3px !important;
        font-size: 6px !important;
        border-radius: 3px !important;
    }
    
    .product-info {
        padding: 2px !important;
        overflow: hidden !important;
    }
    
    .product-name {
        font-size: 5px !important;
        line-height: 0.9 !important;
        margin-bottom: 1px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-weight: 600 !important;
        max-height: 6px !important;
    }
    
    .product-description,
    .product-features,
    .product-specs {
        display: none !important;
    }
    
    .product-price {
        font-size: 5px !important;
        margin: 0.5px 0 !important;
        font-weight: bold !important;
    }
    
    .product-actions {
        flex-direction: column !important;
        gap: 0.5px !important;
    }
    
    .btn {
        padding: 0.5px 1px !important;
        font-size: 4px !important;
        border-radius: 1px !important;
        min-height: 7px !important;
    }
    
    /* Grid view alternative */
    .products-grid.grid-view {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
        overflow-x: visible !important;
        padding: 15px !important;
    }
    
    .products-grid.grid-view .product-card {
        width: auto !important;
        min-width: auto !important;
        height: 85px !important;
    }
    
    .products-grid.grid-view .product-image {
        height: 25px !important;
        font-size: 16px !important;
    }
    
    .products-grid.grid-view .product-name {
        font-size: 8px !important;
    }
    
    .products-grid.grid-view .product-price {
        font-size: 7px !important;
    }
    
    .products-grid.grid-view .btn {
        font-size: 6px !important;
        padding: 2px 3px !important;
    }
    
    /* Section headers mobile */
    h2 {
        font-size: 1.5em !important;
        margin-bottom: 15px !important;
    }
    
    /* Mobile notifications and warnings */
    .climate-info, .tech-info, .safety-warning {
        padding: 15px !important;
        margin: 15px 0 !important;
        border-radius: 10px !important;
    }
    
    .climate-info h3, .tech-info h3, .safety-warning h3 {
        font-size: 1.1em !important;
        margin-bottom: 10px !important;
    }
    
    .climate-info p, .tech-info p, .safety-warning p {
        font-size: 0.9em !important;
        line-height: 1.4 !important;
    }
    
    /* AI insights mobile */
    .ai-insights {
        padding: 15px !important;
        margin: 15px 0 !important;
        border-radius: 10px !important;
    }
    
    .ai-insights h4 {
        font-size: 1.1em !important;
        margin-bottom: 10px !important;
    }
    
    /* Category tabs mobile */
    .category-tabs {
        gap: 5px !important;
        margin-bottom: 20px !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        padding-bottom: 5px !important;
    }
    
    .tab-btn {
        padding: 8px 15px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
    
    /* Mobile scrollbar styling */
    .products-grid::-webkit-scrollbar,
    .category-tabs::-webkit-scrollbar {
        height: 3px !important;
    }
    
    .products-grid::-webkit-scrollbar-track,
    .category-tabs::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.1) !important;
        border-radius: 2px !important;
    }
    
    .products-grid::-webkit-scrollbar-thumb,
    .category-tabs::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,0.3) !important;
        border-radius: 2px !important;
    }
}

/* Extra small devices (phones < 480px) */
@media (max-width: 480px) {
    .main-content {
        padding: 10px !important;
    }
    
    .category-header {
        padding: 20px 15px !important;
    }
    
    .category-title {
        font-size: 1.5em !important;
    }
    
    .category-subtitle {
        font-size: 0.9em !important;
    }
    
    .product-card {
        min-width: 38px !important;
        width: 38px !important;
        height: 70px !important;
    }
    
    .product-image {
        height: 18px !important;
        font-size: 12px !important;
    }
    
    .product-name {
        font-size: 6px !important;
    }
    
    .product-price {
        font-size: 5px !important;
    }
    
    .btn {
        font-size: 4px !important;
        padding: 1px !important;
    }
}

/* Landscape mobile optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .category-header {
        padding: 20px !important;
    }
    
    .category-title {
        font-size: 1.6em !important;
    }
    
    .product-card {
        width: 35px !important;
        min-width: 35px !important;
        height: 65px !important;
    }
    
    .products-grid.grid-view {
        grid-template-columns: repeat(6, 1fr) !important;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .product-card {
        transition: transform 0.2s ease !important;
    }
    
    .product-card:active {
        transform: scale(0.95) !important;
    }
    
    .btn {
        padding: 3px 5px !important;
        min-height: 20px !important;
        min-width: 25px !important;
    }
    
    .tab-btn {
        min-height: 35px !important;
    }
}

/* Loading animations for mobile */
@keyframes mobileCardLoad {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .product-card {
        animation: mobileCardLoad 0.3s ease forwards !important;
    }
    
    .product-card:nth-child(1) { animation-delay: 0.1s; }
    .product-card:nth-child(2) { animation-delay: 0.2s; }
    .product-card:nth-child(3) { animation-delay: 0.3s; }
    .product-card:nth-child(4) { animation-delay: 0.4s; }
    .product-card:nth-child(5) { animation-delay: 0.5s; }
    .product-card:nth-child(6) { animation-delay: 0.6s; }
    .product-card:nth-child(7) { animation-delay: 0.7s; }
    .product-card:nth-child(8) { animation-delay: 0.8s; }
}

/* Mobile grid toggle indicator */
.mobile-grid-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 1000;
    display: none;
    animation: fadeInOut 2s ease;
}

@media (max-width: 768px) {
    .mobile-grid-indicator.show {
        display: block;
    }
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}