/**
 * WP AffLinks Mobile-Friendly Responsive Design
 * 
 * This file provides comprehensive mobile-responsive design for all WP AffLinks
 * frontend components including affiliate links, resource pages, and trending offers.
 */

/* ==========================================================================
   MOBILE-FIRST RESPONSIVE DESIGN
   ========================================================================== */

/* Base mobile styles (320px and up) */
.wp-afflinks-mobile-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

/* Typography for mobile */
.wp-afflinks-mobile-container h1 {
    font-size: 1.75rem;
    line-height: 1.3;
    margin-bottom: 1rem;
}

.wp-afflinks-mobile-container h2 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin-bottom: 0.875rem;
}

.wp-afflinks-mobile-container h3 {
    font-size: 1.25rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

.wp-afflinks-mobile-container p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* ==========================================================================
   AFFILIATE LINKS MOBILE STYLES
   ========================================================================== */

/* Mobile affiliate link buttons */
.wp-afflinks-button {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0.5rem auto;
    padding: 12px 20px;
    font-size: 16px; /* Prevents zoom on iOS */
    line-height: 1.4;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 44px; /* iOS minimum touch target */
    box-sizing: border-box;
}

.wp-afflinks-button:active {
    transform: scale(0.98);
}

/* Mobile tooltip adjustments */
.wp-afflinks-link {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 100%;
}

.wp-afflinks-link .wp-afflinks-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 300px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    z-index: 9999;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
}

.wp-afflinks-link .wp-afflinks-tooltip:after {
    display: none;
}

/* ==========================================================================
   RESOURCE PAGES MOBILE STYLES
   ========================================================================== */

/* Mobile resource page header */
.wp-afflinks-resource-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
}

.resource-page-title {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}

.resource-page-description {
    font-size: 1rem;
    padding: 0 1rem;
}

/* Mobile resource grid */
.wp-afflinks-resources-grid {
    display: block;
    margin: 1rem 0;
}

.wp-afflinks-resource-card {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 8px;
}

/* Mobile resource card header */
.resource-header {
    flex-direction: column;
    text-align: center;
    margin-bottom: 1rem;
}

.resource-icon {
    margin: 0 auto 0.75rem;
    width: 50px;
    height: 50px;
}

.resource-title h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.resource-category {
    display: inline-block;
    margin-top: 0.5rem;
}

.resource-status {
    margin: 0.75rem 0 0 0;
}

/* Mobile resource actions */
.resource-actions {
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.resource-actions .button {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
    flex: 1;
    min-width: 120px;
}

/* Mobile services list */
.wp-afflinks-services-list {
    margin-bottom: 2rem;
}

/* Grid layout mobile */
.wp-afflinks-services-list.layout-grid {
    display: block;
}

.wp-afflinks-services-list.layout-grid .wp-afflinks-service-item {
    margin-bottom: 1rem;
}

/* List layout mobile */
.wp-afflinks-services-list.layout-list .wp-afflinks-service-item {
    flex-direction: column;
    text-align: center;
    padding: 1rem;
}

.wp-afflinks-services-list.layout-list .service-icon {
    margin: 0 auto 0.75rem;
}

.wp-afflinks-services-list.layout-list .service-content {
    margin-bottom: 1rem;
}

.wp-afflinks-services-list.layout-list .service-url {
    margin: 0;
}

/* Cards layout mobile */
.wp-afflinks-services-list.layout-cards {
    display: block;
}

.wp-afflinks-services-list.layout-cards .wp-afflinks-service-item {
    margin-bottom: 1rem;
    padding: 1.5rem 1rem;
}

.wp-afflinks-services-list.layout-cards .service-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
}

.wp-afflinks-services-list.layout-cards .service-name a {
    font-size: 1.125rem;
}

.wp-afflinks-services-list.layout-cards .service-link {
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    display: block;
    text-align: center;
    min-height: 44px;
    line-height: 44px;
}

/* ==========================================================================
   TRENDING OFFERS MOBILE STYLES
   ========================================================================== */

/* Mobile trending offers container */
.wp-afflinks-trending-offers {
    margin: 1.5rem 0;
}

.wp-afflinks-trending-offer {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 8px;
}

.trending-offer-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.trending-offer-category {
    display: inline-block;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.trending-offer-description {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.trending-offer-details {
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.trending-offer-price {
    font-size: 1rem;
}

.trending-offer-discount {
    align-self: flex-start;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

.trending-offer-button {
    width: 100%;
    max-width: 250px;
    margin: 0 auto;
    display: block;
    padding: 12px 20px;
    font-size: 16px;
    min-height: 44px;
    line-height: 1.4;
}

.trending-offer-image {
    margin-bottom: 0.75rem;
}

.trending-offer-image img {
    max-height: 150px;
    width: 100%;
    object-fit: cover;
}

/* Mobile layout adjustments */
.wp-afflinks-layout-grid,
.wp-afflinks-layout-cards {
    display: block;
}

.wp-afflinks-layout-grid .wp-afflinks-trending-offer,
.wp-afflinks-layout-cards .wp-afflinks-trending-offer {
    margin-bottom: 1.5rem;
}

.wp-afflinks-layout-list .wp-afflinks-trending-offer {
    flex-direction: column;
}

.wp-afflinks-layout-list .trending-offer-image {
    flex: none;
    width: 100%;
    margin-bottom: 0.75rem;
}

.wp-afflinks-layout-list .trending-offer-content {
    flex: none;
}

/* ==========================================================================
   MOBILE NAVIGATION AND CONTROLS
   ========================================================================== */

/* Mobile filter controls */
.wp-afflinks-mobile-filters {
    position: sticky;
    top: 0;
    background: #fff;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
    z-index: 100;
    margin-bottom: 1rem;
}

.wp-afflinks-mobile-filters select,
.wp-afflinks-mobile-filters input {
    width: 100%;
    font-size: 16px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

/* Mobile search */
.wp-afflinks-mobile-search {
    position: relative;
    margin-bottom: 1rem;
}

.wp-afflinks-mobile-search input {
    width: 100%;
    padding: 12px 40px 12px 12px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.wp-afflinks-mobile-search button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
}

/* Mobile pagination */
.wp-afflinks-mobile-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.wp-afflinks-mobile-pagination .page-numbers {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    background: #fff;
    color: #333;
}

.wp-afflinks-mobile-pagination .current {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* ==========================================================================
   TABLET STYLES (768px and up)
   ========================================================================== */

@media (min-width: 768px) {
    .wp-afflinks-mobile-container {
        padding: 0 20px;
    }
    
    .wp-afflinks-mobile-container h1 {
        font-size: 2rem;
    }
    
    .wp-afflinks-mobile-container h2 {
        font-size: 1.75rem;
    }
    
    .wp-afflinks-mobile-container h3 {
        font-size: 1.5rem;
    }
    
    /* Tablet affiliate links */
    .wp-afflinks-button {
        width: auto;
        max-width: none;
        display: inline-block;
    }
    
    /* Tablet resource grid */
    .wp-afflinks-resources-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .resource-header {
        flex-direction: row;
        text-align: left;
    }
    
    .resource-icon {
        margin: 0 0.75rem 0 0;
    }
    
    .resource-status {
        margin: 0 0 0 auto;
    }
    
    /* Tablet services list */
    .wp-afflinks-services-list.layout-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .wp-afflinks-services-list.layout-list .wp-afflinks-service-item {
        flex-direction: row;
        text-align: left;
    }
    
    .wp-afflinks-services-list.layout-list .service-icon {
        margin: 0 0.75rem 0 0;
    }
    
    .wp-afflinks-services-list.layout-list .service-content {
        margin-bottom: 0;
    }
    
    .wp-afflinks-services-list.layout-list .service-url {
        margin: 0 0 0 auto;
    }
    
    .wp-afflinks-services-list.layout-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Tablet trending offers */
    .wp-afflinks-layout-grid,
    .wp-afflinks-layout-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .wp-afflinks-layout-list .wp-afflinks-trending-offer {
        flex-direction: row;
    }
    
    .wp-afflinks-layout-list .trending-offer-image {
        flex: 0 0 150px;
        margin-bottom: 0;
    }
    
    .trending-offer-details {
        flex-direction: row;
        gap: 1rem;
    }
    
    .trending-offer-button {
        width: auto;
        display: inline-block;
    }
}

/* ==========================================================================
   DESKTOP STYLES (1024px and up)
   ========================================================================== */

@media (min-width: 1024px) {
    .wp-afflinks-mobile-container {
        max-width: 1200px;
        padding: 0 30px;
    }
    
    .wp-afflinks-mobile-container h1 {
        font-size: 2.5rem;
    }
    
    .wp-afflinks-mobile-container h2 {
        font-size: 2rem;
    }
    
    .wp-afflinks-mobile-container h3 {
        font-size: 1.75rem;
    }
    
    /* Desktop resource grid */
    .wp-afflinks-resources-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    /* Desktop services list */
    .wp-afflinks-services-list.layout-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    .wp-afflinks-services-list.layout-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    /* Desktop trending offers */
    .wp-afflinks-layout-grid,
    .wp-afflinks-layout-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* ==========================================================================
   LARGE DESKTOP STYLES (1440px and up)
   ========================================================================== */

@media (min-width: 1440px) {
    .wp-afflinks-mobile-container {
        max-width: 1400px;
    }
    
    /* Large desktop resource grid */
    .wp-afflinks-resources-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
    
    /* Large desktop services list */
    .wp-afflinks-services-list.layout-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
    
    .wp-afflinks-services-list.layout-cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
    
    /* Large desktop trending offers */
    .wp-afflinks-layout-grid,
    .wp-afflinks-layout-cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
}

/* ==========================================================================
   ACCESSIBILITY AND TOUCH IMPROVEMENTS
   ========================================================================== */

/* Focus styles for accessibility */
.wp-afflinks-button:focus,
.wp-afflinks-link:focus,
.service-link:focus,
.trending-offer-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Touch-friendly hover states */
@media (hover: hover) {
    .wp-afflinks-button:hover,
    .service-link:hover,
    .trending-offer-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
    }
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .wp-afflinks-button,
    .service-link,
    .trending-offer-button,
    .wp-afflinks-service-item,
    .wp-afflinks-trending-offer {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wp-afflinks-button,
    .service-link,
    .trending-offer-button {
        border: 2px solid currentColor;
    }
    
    .wp-afflinks-service-item,
    .wp-afflinks-trending-offer {
        border: 2px solid currentColor;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .wp-afflinks-mobile-container {
        max-width: none;
        padding: 0;
    }
    
    .wp-afflinks-button,
    .service-link,
    .trending-offer-button {
        border: 1px solid #000;
        background: #fff !important;
        color: #000 !important;
        text-decoration: none;
    }
    
    .wp-afflinks-service-item,
    .wp-afflinks-trending-offer {
        break-inside: avoid;
        border: 1px solid #000;
        background: #fff !important;
    }
}
