/* Mobile-Friendly Farms Page Styles */

/* Mobile farm card styles */
.mobile-farm-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0;
}

.farm-card-mobile {
    transition: all 0.2s ease;
    background: white;
    border: 1px solid #e0e0e0;
    cursor: pointer;
}

.farm-card-mobile:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #059669;
    transform: translateY(-1px);
}

.farm-card-code {
    color: #059669;
    font-family: monospace;
}

.farm-card-farmer {
    color: #333;
    font-weight: 500;
}

/* Responsive design */
@media screen and (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
    
    .desktop-only {
        display: block !important;
    }
}

/* Mobile-first responsive design for farms */
@media screen and (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    /* Show mobile search, hide desktop filters */
    .farms-mobile-search-container {
        display: block !important;
    }
    
    /* Hide complex filter panels on mobile */
    .farms-advanced-filters {
        display: none !important;
    }
    
    /* Simplify search on mobile */
    .farms-mobile-search {
        margin-bottom: 1rem;
    }
    
    /* Hide unnecessary columns on mobile */
    .ag-header-cell[col-id="producteur_telephone"],
    .ag-cell[col-id="producteur_telephone"],
    .ag-header-cell[col-id="days_since_visit"],
    .ag-cell[col-id="days_since_visit"],
    .ag-header-cell[col-id="avg_rendement"],
    .ag-cell[col-id="avg_rendement"],
    .ag-header-cell[col-id="total_superficie"],
    .ag-cell[col-id="total_superficie"] {
        display: none !important;
    }
    
    /* Make remaining columns flexible */
    .ag-header-cell[col-id="exploitation_agricole_code"],
    .ag-cell[col-id="exploitation_agricole_code"] {
        min-width: 80px !important;
        width: 80px !important;
    }
    
    .ag-header-cell[col-id="producer_link"],
    .ag-cell[col-id="producer_link"] {
        min-width: 120px !important;
        flex: 1 !important;
    }
    
    .ag-header-cell[col-id="exploitation_agricole_localite"],
    .ag-cell[col-id="exploitation_agricole_localite"] {
        min-width: 100px !important;
        width: 100px !important;
    }
    
    .ag-header-cell[col-id="total_units"],
    .ag-cell[col-id="total_units"] {
        min-width: 60px !important;
        width: 60px !important;
    }
    
    /* Hide AG Grid row selection checkboxes on mobile */
    .ag-selection-checkbox,
    .ag-header-cell .ag-checkbox,
    .ag-cell .ag-checkbox {
        display: none !important;
    }
    
    /* Hide row selection column entirely on mobile */
    .ag-header-cell[col-id="ag-Grid-AutoColumn"],
    .ag-cell[col-id="ag-Grid-AutoColumn"] {
        display: none !important;
    }
    
    /* Compact AG Grid for mobile */
    .ag-theme-alpine {
        --ag-row-height: 40px;
        --ag-header-height: 36px;
        --ag-font-size: 13px;
    }
    
    /* Mobile card layout alternative */
    .farms-mobile-cards {
        display: block !important;
    }
    
    .farms-desktop-table {
        display: none !important;
    }
    
    /* Farm card styling */
    .farm-card {
        border: 1px solid #e9ecef;
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 12px;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .farm-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
        font-weight: 600;
    }
    
    .farm-card-code {
        color: #007bff;
        font-family: monospace;
    }
    
    .farm-card-status {
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 500;
    }
    
    .farm-card-status.active {
        background-color: #d4edda;
        color: #155724;
    }
    
    .farm-card-status.inactive {
        background-color: #f8d7da;
        color: #721c24;
    }
    
    .farm-card-body {
        font-size: 14px;
        line-height: 1.4;
    }
    
    .farm-card-field {
        display: flex;
        justify-content: space-between;
        margin-bottom: 4px;
    }
    
    .farm-card-label {
        color: #666;
        font-weight: 500;
        min-width: 80px;
    }
    
    .farm-card-value {
        color: #333;
        text-align: right;
        flex: 1;
    }
    
    /* Mobile pagination */
    .ag-paging-panel {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 8px !important;
    }
    
    .ag-paging-row-summary-panel {
        order: 2;
        text-align: center;
        margin-top: 8px;
        font-size: 12px;
    }
    
    .ag-paging-page-summary-panel {
        order: 1;
        justify-content: center;
    }
    
    /* Simplify pagination buttons on mobile */
    .ag-paging-button {
        min-width: 32px !important;
        height: 32px !important;
        margin: 0 2px !important;
    }
}

/* Tablet adjustments */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    /* Hide mobile search on tablet */
    .farms-mobile-search-container {
        display: none !important;
    }
    
    /* Show desktop table on tablet */
    .farms-mobile-cards {
        display: none !important;
    }
    
    .farms-desktop-table {
        display: block !important;
    }
    
    /* Compact some columns on tablet */
    .ag-header-cell[col-id="producteur_telephone"],
    .ag-cell[col-id="producteur_telephone"],
    .ag-header-cell[col-id="avg_rendement"],
    .ag-cell[col-id="avg_rendement"] {
        display: none !important;
    }
    
    /* Reduce row selection complexity on tablet */
    .ag-selection-checkbox {
        transform: scale(0.9);
    }
}

/* Desktop styles */
@media screen and (min-width: 1025px) {
    /* Hide mobile search on desktop */
    .farms-mobile-search-container {
        display: none !important;
    }
    
    /* Show full desktop table */
    .farms-mobile-cards {
        display: none !important;
    }
    
    .farms-desktop-table {
        display: block !important;
    }
    
    /* Full row selection on desktop */
    .ag-selection-checkbox {
        display: block !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .ag-cell, .ag-header-cell {
        min-height: 44px !important;
    }
    
    /* Better button sizing */
    .ag-paging-button {
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* Farm card touch improvements */
/* Mobile farmer list items */
.mobile-farmer-item {
    transition: background-color 0.2s ease;
}

.mobile-farmer-item:hover {
    background-color: #f8f9fa !important;
}

.mobile-farmer-item:active {
    background-color: #e9ecef !important;
}

/* Mobile farmer list links */
.farms-mobile-cards a {
    text-decoration: none !important;
    color: inherit !important;
    display: block;
}

.farms-mobile-cards a:hover {
    text-decoration: none !important;
}

.farms-mobile-cards a:hover .mobile-farmer-item {
    background-color: #f8f9fa !important;
}

.farms-mobile-cards a:active .mobile-farmer-item {
    background-color: #e9ecef !important;
}    .farm-card:active {
        background-color: #f8f9fa;
    }
}

/* Loading states */
.farms-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 16px;
    color: #666;
}

/* Error states */
.farms-error {
    text-align: center;
    padding: 20px;
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin: 10px 0;
}

/* Mobile search enhancements */
@media screen and (max-width: 768px) {
    .farms-search-container {
        position: sticky;
        top: 60px; /* Below mobile header */
        background: white;
        z-index: 10;
        padding: 12px;
        border-bottom: 1px solid #e9ecef;
        margin-bottom: 12px;
    }
    
    .farms-mobile-filters {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 4px 0;
        margin-top: 8px;
    }
    
    .farms-mobile-filter-chip {
        flex-shrink: 0;
        padding: 4px 12px;
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 16px;
        font-size: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .farms-mobile-filter-chip.active {
        background: #007bff;
        color: white;
        border-color: #007bff;
    }
    
    .farms-mobile-filter-chip:hover {
        background: #e9ecef;
    }
    
    .farms-mobile-filter-chip.active:hover {
        background: #0056b3;
    }
}
