/* Amazon Affiliate Ads Styling for Newspaper Layout */
/* Integrates seamlessly with existing newspaper-styles.css */

/* Amazon Ad Base Styles */
.amazon-ad {
    background: var(--newspaper-paper);
    border: 1px solid var(--newspaper-border);
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.amazon-ad:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--newspaper-shadow-heavy);
    border-color: var(--newspaper-accent);
}

/* Dark theme specific adjustments */
[data-theme="dark"] .amazon-ad {
    background: var(--newspaper-paper);
    border-color: var(--newspaper-border);
}

[data-theme="dark"] .amazon-ad:hover {
    box-shadow: 0 4px 12px var(--newspaper-shadow-heavy);
    border-color: var(--newspaper-accent);
}

/* Ad Placeholder (Loading State) */
.ad-placeholder {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
}

/* Fallback Ad Styling */
.ad-fallback {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    text-align: center;
}

.ad-product-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--newspaper-paper);
    border-radius: 4px;
    border: 1px dashed var(--newspaper-border);
    width: 100%;
}

.ad-product-placeholder h4 {
    margin: 0.5rem 0;
    color: var(--newspaper-text);
    font-size: 1rem;
    font-weight: 600;
}

.ad-product-placeholder p {
    margin: 0.5rem 0 1rem 0;
    color: var(--newspaper-meta);
    font-size: 0.9rem;
    line-height: 1.4;
}

.ad-cta-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.ad-cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #FF9900;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.ad-cta-button:hover {
    background: #E88B00;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 153, 0, 0.3);
    color: white;
    text-decoration: none;
}

.ad-cta-button i {
    font-size: 1rem;
}

.ad-price-note {
    color: var(--newspaper-meta);
    font-size: 0.75rem;
    font-style: italic;
}

.ad-fallback-active {
    border: 1px solid #FF9900;
    box-shadow: 0 2px 8px rgba(255, 153, 0, 0.1);
}

/* Refreshing Animation */
.ad-refreshing {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.ad-refreshing .ad-placeholder {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

[data-theme="dark"] .ad-refreshing .ad-placeholder {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    background-size: 200% 100%;
}

.ad-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--newspaper-text-muted);
}

.ad-header i {
    color: var(--newspaper-accent);
}

.ad-label {
    background: var(--newspaper-accent);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ad-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--newspaper-text);
    margin-bottom: 1rem;
}

.ad-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--newspaper-text-muted);
    font-size: 0.875rem;
}

.ad-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--newspaper-border);
    border-top: 2px solid var(--newspaper-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Amazon Widget Styling */
.ad-amazon-widget {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    min-height: 150px;
}

.ad-amazon-widget iframe {
    max-width: 100%;
    border: none !important;
    background: transparent;
}

/* Widget responsive adjustments */
.amazon-ad.size-small .ad-amazon-widget {
    min-height: 150px;
}

.amazon-ad.size-medium .ad-amazon-widget {
    min-height: 200px;
}

/* Error state styling */
.ad-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    color: var(--newspaper-text-muted);
    text-align: center;
}

.ad-error i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.ad-error-state {
    min-height: 120px;
}
.ad-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ad-product {
    display: flex;
    gap: 1rem;
    flex: 1;
    margin: 0.5rem 0;
}

.ad-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--newspaper-bg);
}

.ad-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.amazon-ad:hover .ad-image img {
    transform: scale(1.05);
}

.ad-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ad-product-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--newspaper-text);
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ad-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.ad-stars {
    color: #ffa500;
    display: flex;
    gap: 1px;
}

.ad-rating-text {
    color: var(--newspaper-text-muted);
    font-size: 0.75rem;
}

.ad-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--newspaper-accent);
}

.ad-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #ff9900;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: auto;
    align-self: flex-start;
}

.ad-cta:hover {
    background: #e68900;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 153, 0, 0.3);
}

.ad-cta i {
    font-size: 1rem;
}

.ad-disclaimer {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--newspaper-border);
    color: var(--newspaper-text-muted);
    font-size: 0.7rem;
    text-align: center;
}

/* Error State */
.ad-error {
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--newspaper-text-muted);
    font-size: 0.875rem;
}

.ad-error i {
    font-size: 1.5rem;
    color: #ffa500;
}

.ad-error-state {
    opacity: 0.6;
}

/* Size Variants */
.amazon-ad.size-small {
    min-height: 180px;
}

.amazon-ad.size-small .ad-product {
    flex-direction: column;
    text-align: center;
}

.amazon-ad.size-small .ad-image {
    width: 60px;
    height: 60px;
    align-self: center;
}

.amazon-ad.size-small .ad-product-title {
    font-size: 0.85rem;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.amazon-ad.size-small .ad-cta {
    align-self: center;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.amazon-ad.size-medium {
    min-height: 220px;
}

.amazon-ad.size-medium .ad-image {
    width: 100px;
    height: 100px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .amazon-ad {
        min-height: 160px;
    }
    
    .ad-product {
        flex-direction: column;
        text-align: center;
        gap: 0.8rem;
    }
    
    .ad-image {
        width: 70px !important;
        height: 70px !important;
        align-self: center;
    }
    
    .ad-product-title {
        font-size: 0.9rem;
    }
    
    .ad-cta {
        align-self: center;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

/* Integration with Grid Layout */
.newspaper-main-grid .amazon-ad {
    /* Inherits grid positioning from newspaper-article class */
    grid-column: span 1;
}

.newspaper-sidebar .amazon-ad {
    /* Fits within sidebar layout */
    margin-bottom: 1rem;
}

.newspaper-sidebar .amazon-ad .ad-product {
    flex-direction: column;
    text-align: center;
}

.newspaper-sidebar .amazon-ad .ad-image {
    width: 60px;
    height: 60px;
    align-self: center;
}

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

/* Fade-in Animation for Loaded Ads */
.amazon-ad.ad-loaded {
    animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Accessibility Improvements */
.amazon-ad:focus-within {
    outline: 2px solid var(--newspaper-accent);
    outline-offset: 2px;
}

.ad-cta:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .amazon-ad {
        border-width: 2px;
    }
    
    .ad-label {
        border: 1px solid white;
    }
    
    .ad-cta {
        border: 2px solid #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .amazon-ad,
    .ad-cta,
    .ad-image img {
        transition: none;
    }
    
    .amazon-ad:hover {
        transform: none;
    }
    
    .ad-loading-spinner {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .amazon-ad {
        display: none;
    }
}

/* Cookie Consent Banner */
.consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--newspaper-paper);
    border-top: 3px solid var(--newspaper-accent);
    box-shadow: 0 -4px 20px var(--newspaper-shadow-heavy);
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    padding: 1.5rem;
}

.consent-banner.show {
    transform: translateY(0);
}

.consent-banner.hide {
    transform: translateY(100%);
}

.consent-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.consent-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--newspaper-accent);
}

.consent-header i {
    font-size: 1.5rem;
}

.consent-header h4 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--newspaper-text);
}

.consent-content p {
    margin: 0;
    color: var(--newspaper-text-light);
    line-height: 1.5;
}

.consent-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.consent-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 0.9rem;
}

.consent-btn.accept {
    background: var(--newspaper-accent);
    color: white;
}

.consent-btn.accept:hover {
    background: color-mix(in srgb, var(--newspaper-accent) 85%, black);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--newspaper-shadow);
}

.consent-btn.decline {
    background: var(--newspaper-border);
    color: var(--newspaper-text);
    border: 1px solid var(--newspaper-border-thick);
}

.consent-btn.decline:hover {
    background: var(--newspaper-border-thick);
    color: white;
}

.consent-note {
    color: var(--newspaper-text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.consent-note a {
    color: var(--newspaper-accent);
    text-decoration: none;
}

.consent-note a:hover {
    text-decoration: underline;
}

/* Ad Info Modal */
.ad-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.ad-modal.show {
    opacity: 1;
}

.ad-modal-content {
    background: var(--newspaper-paper);
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px var(--newspaper-shadow-heavy);
}

.ad-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--newspaper-border);
}

.ad-modal-header h3 {
    margin: 0;
    color: var(--newspaper-text);
}

.ad-modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--newspaper-text-muted);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.ad-modal-close:hover {
    background: var(--newspaper-border);
    color: var(--newspaper-text);
}

.ad-modal-body {
    padding: 1.5rem;
    color: var(--newspaper-text-light);
    line-height: 1.6;
}

.ad-modal-body h4 {
    color: var(--newspaper-text);
    margin: 1.5rem 0 0.75rem 0;
}

.ad-modal-body h4:first-child {
    margin-top: 0;
}

.ad-modal-body ul {
    padding-left: 1.5rem;
}

.ad-modal-body li {
    margin-bottom: 0.5rem;
}

.ad-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--newspaper-border);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Personalized/Contextual Ad Indicators */
.ad-personalized,
.ad-contextual {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    margin-left: 0.5rem;
}

.ad-personalized {
    background: var(--newspaper-accent);
    color: white;
}

.ad-contextual {
    background: var(--newspaper-border-thick);
    color: white;
}

/* Amazon Widget Styles */
.ad-amazon-widget {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0;
}

.amazon-widget-compact,
.amazon-widget-standard {
    display: flex;
    justify-content: center;
    width: 100%;
}

.amazon-widget-compact iframe,
.amazon-widget-standard iframe {
    border: none;
    border-radius: 4px;
    background: var(--newspaper-paper);
}

/* Fallback product display */
.ad-product-fallback {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
}

.ad-product-fallback .ad-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--newspaper-bg);
}

.ad-product-fallback .ad-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ad-product-fallback .ad-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ad-product-fallback .ad-product-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--newspaper-text);
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ad-product-fallback .ad-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.ad-product-fallback .ad-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--newspaper-accent);
}

.ad-product-fallback .ad-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #ff9900;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s ease;
    align-self: flex-start;
}

.ad-product-fallback .ad-cta:hover {
    background: #e68900;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 153, 0, 0.3);
}

/* Responsive adjustments for widgets */
@media (max-width: 768px) {
    .amazon-widget-compact iframe {
        width: 100px;
        height: 120px;
    }
    
    .amazon-widget-standard iframe {
        width: 140px;
        height: 160px;
    }
    
    .ad-product-fallback {
        flex-direction: column;
        text-align: center;
        gap: 0.8rem;
    }
    
    .ad-product-fallback .ad-image {
        width: 70px;
        height: 70px;
        align-self: center;
    }
    
    .ad-product-fallback .ad-cta {
        align-self: center;
    }
}

/* Responsive Design for Consent Banner */
@media (max-width: 768px) {
    .consent-banner {
        padding: 1rem;
    }
    
    .consent-content {
        gap: 0.75rem;
    }
    
    .consent-buttons {
        flex-direction: column;
    }
    
    .consent-btn {
        justify-content: center;
        width: 100%;
    }
    
    .ad-modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .ad-modal-footer {
        flex-direction: column;
    }
    
    .ad-modal-footer .consent-btn {
        width: 100%;
        justify-content: center;
    }
}
