/**
 * Frontend Global Styles
 * Common styles for all Amazon product blocks
 */

/* Global Variables */
:root {
    --apb-primary-color: #FF9900;
    --apb-secondary-color: #232F3E;
    --apb-accent-color: #B12704;
    --apb-text-color: #333333;
    --apb-border-radius: 8px;
    --apb-padding: 20px;
    --apb-margin: 20px;
    --apb-font-size: 16px;
    --apb-transition: all 0.3s ease;
}

/* Global Block Styles */
.apb-single-product-block,
.apb-comparison-block,
.apb-grid-block {
    font-family: inherit;
    font-size: var(--apb-font-size);
    color: var(--apb-text-color);
    line-height: 1.6;
}

/* Links */
.apb-single-product-block a,
.apb-comparison-block a,
.apb-grid-block a {
    transition: var(--apb-transition);
}

/* Buttons */
.apb-buy-button,
.apb-comparison-button,
.apb-grid-button,
.apb-add-to-cart {
    display: inline-block;
    padding: 12px 30px;
    background-color: var(--apb-primary-color);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--apb-transition);
    text-align: center;
}

.apb-buy-button:hover,
.apb-comparison-button:hover,
.apb-grid-button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.apb-buy-button.loading,
.apb-add-to-cart.loading {
    opacity: 0.6;
    cursor: wait;
}

.apb-buy-button.added,
.apb-add-to-cart.added {
    background-color: #10b981;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.apb-fade-in {
    animation: fadeIn 0.6s ease-out;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse-animation {
    animation: pulse 0.5s ease-in-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Star Rating Animation */
.animate-star {
    animation: starPop 0.3s ease-out;
}

@keyframes starPop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Image Transitions */
.apb-product-image img,
.apb-card-image img {
    transition: transform 0.3s ease;
}

.apb-product-image:hover img,
.apb-card-image:hover img {
    transform: scale(1.05);
}

/* Lazy Loading */
img.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

img.lazy.loaded {
    opacity: 1;
}

/* Disclosure Styles */
.apb-affiliate-disclosure {
    margin-top: 20px;
    padding: 12px;
    background: #f3f4f6;
    border-left: 4px solid #fbbf24;
    font-size: 0.85em;
    color: #6b7280;
}

.apb-disclosure-toggle {
    cursor: pointer;
    user-select: none;
}

.apb-disclosure-toggle:hover {
    text-decoration: underline;
}

.apb-disclosure-content {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
}

/* Tooltip */
.apb-tooltip {
    position: relative;
    cursor: help;
}

.apb-tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: #1f2937;
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
    border-radius: 4px;
    z-index: 1000;
    margin-bottom: 5px;
}

.apb-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

/* Loading Spinner */
.apb-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Print Styles */
@media print {
    .apb-buy-button,
    .apb-comparison-button,
    .apb-grid-button,
    .apb-share-product,
    .apb-print-product {
        display: none;
    }

    .apb-affiliate-disclosure {
        page-break-inside: avoid;
    }
}

/* Accessibility */
.apb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Styles */
.apb-buy-button:focus,
.apb-comparison-button:focus,
.apb-grid-button:focus {
    outline: 2px solid var(--apb-primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .apb-single-product-block,
    .apb-comparison-block,
    .apb-grid-block {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .apb-single-product-block,
    .apb-comparison-block,
    .apb-grid-block {
        background: #1f2937;
        color: #f3f4f6;
    }

    .apb-product-card {
        background: #374151;
        border-color: #4b5563;
    }

    .apb-affiliate-disclosure {
        background: #374151;
        border-left-color: #fbbf24;
        color: #d1d5db;
    }

    .apb-comparison-table {
        background: #1f2937;
    }

    .apb-comparison-table th,
    .apb-comparison-table td {
        border-color: #4b5563;
    }
}

/* Utility Classes */
.apb-text-center {
    text-align: center;
}

.apb-text-left {
    text-align: left;
}

.apb-text-right {
    text-align: right;
}

.apb-hidden {
    display: none;
}

.apb-visible {
    display: block;
}

.apb-mt-0 { margin-top: 0; }
.apb-mt-1 { margin-top: 10px; }
.apb-mt-2 { margin-top: 20px; }
.apb-mt-3 { margin-top: 30px; }

.apb-mb-0 { margin-bottom: 0; }
.apb-mb-1 { margin-bottom: 10px; }
.apb-mb-2 { margin-bottom: 20px; }
.apb-mb-3 { margin-bottom: 30px; }

/* Responsive Helpers */
@media (max-width: 640px) {
    .apb-hide-mobile {
        display: none !important;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .apb-hide-tablet {
        display: none !important;
    }
}

@media (min-width: 1025px) {
    .apb-hide-desktop {
        display: none !important;
    }
}

/* Scrollbar Customization */
.apb-comparison-table-wrapper::-webkit-scrollbar {
    height: 10px;
}

.apb-comparison-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.apb-comparison-table-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

.apb-comparison-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Scroll Indicator */
.apb-comparison-table-wrapper.has-scroll::after {
    content: '→';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(to right, transparent, #fff);
    padding: 10px 20px;
    pointer-events: none;
    font-size: 24px;
    color: var(--apb-primary-color);
}
