/**
 * Theme Integration CSS for MagzPress
 * Ensures proper display across different WordPress themes
 */

/* Magazine Archive Page */
.magzpress-archive {
    max-width: 100%;
    margin: 0 auto;
}

.magzpress-archive .magazine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.magzpress-archive .magazine-item {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.magzpress-archive .magazine-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.magzpress-archive .magazine-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.magzpress-archive .magazine-info {
    padding: 1.5rem;
}

.magzpress-archive .magazine-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.magzpress-archive .magazine-excerpt {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.magzpress-archive .magazine-meta {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 1rem;
}

.magzpress-archive .magazine-actions {
    display: flex;
    gap: 0.5rem;
}

.magzpress-archive .btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.magzpress-archive .btn-primary {
    background: #0073aa;
    color: white;
}

.magzpress-archive .btn-primary:hover {
    background: #005a87;
    color: white;
}

.magzpress-archive .btn-secondary {
    background: #e6e6e6;
    color: #333;
}

.magzpress-archive .btn-secondary:hover {
    background: #d4d4d4;
    color: #333;
}

/* ==========================================================================
   Enhanced Magazine Viewer Actions - Modern UI/UX Design
   ========================================================================== */

.magzpress-viewer-actions {
    /* Container Styling */
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
    border: 1px solid rgba(0, 115, 170, 0.08);
    border-radius: 16px;
    padding: 1.5rem;
    margin: 2rem 0;
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.04),
        0 1px 3px rgba(0, 0, 0, 0.02);

    /* Layout */
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;

    /* Animation */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.magzpress-viewer-actions:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.08),
        0 3px 10px rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 115, 170, 0.15);
}

/* Decorative Elements */
.magzpress-viewer-actions::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0073aa 0%, #46b450 50%, #ff6b35 100%);
    border-radius: 16px 16px 0 0;
}

.magzpress-viewer-actions::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(0, 115, 170, 0.03) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* Section Header */
.magzpress-viewer-actions-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 115, 170, 0.06);
}

.magzpress-viewer-actions-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.2);
}

.magzpress-viewer-actions-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    letter-spacing: -0.025em;
}

.magzpress-viewer-actions-subtitle {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0.25rem 0 0 0;
    line-height: 1.4;
}

/* Button Container */
.magzpress-viewer-actions-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
}

.magzpress-viewer-actions-buttons::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, transparent, rgba(0, 115, 170, 0.03), transparent);
    border-radius: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.magzpress-viewer-actions:hover .magzpress-viewer-actions-buttons::before {
    opacity: 1;
}

/* Primary Action Button - View PDF */
.magzpress-view-pdf-btn {
    /* Base Styling */
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    position: relative;
    overflow: hidden;

    /* Layout */
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 48px;
    min-width: 140px;
    justify-content: center;

    /* Shadows & Effects */
    box-shadow:
        0 4px 14px rgba(0, 115, 170, 0.25),
        0 2px 6px rgba(0, 115, 170, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);

    /* Animation */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    /* Force hardware acceleration */
}

.magzpress-view-pdf-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.6s ease;
}

.magzpress-view-pdf-btn:hover {
    background: linear-gradient(135deg, #005a87 0%, #004766 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 8px 25px rgba(0, 115, 170, 0.35),
        0 4px 12px rgba(0, 115, 170, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.magzpress-view-pdf-btn:hover::before {
    left: 100%;
}

.magzpress-view-pdf-btn:active {
    transform: translateY(-1px) scale(0.98);
    transition: all 0.1s ease;
}

.magzpress-view-pdf-btn:focus {
    outline: none;
    box-shadow:
        0 4px 14px rgba(0, 115, 170, 0.25),
        0 2px 6px rgba(0, 115, 170, 0.15),
        0 0 0 3px rgba(0, 115, 170, 0.3);
}

.magzpress-view-pdf-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Enhanced Loading States and Interactive Features */

/* Loading Spinner Component */
.magzpress-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: magzpress-spin 0.8s linear infinite;
    margin-right: 0.5rem;
}

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

/* Button Loading States */
.magzpress-view-pdf-btn.loading {
    pointer-events: none;
    opacity: 0.8;
    transform: none !important;
}

.magzpress-view-pdf-btn.loading .dashicons {
    display: none;
}

/* Progress Bar for PDF Loading */
.magzpress-progress-container {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(0, 115, 170, 0.08);
    border-radius: 2px;
    margin: 1rem 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.magzpress-progress-container.visible {
    opacity: 1;
}

.magzpress-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0073aa 0%, #46b450 100%);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.magzpress-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(-45deg,
            rgba(255, 255, 255, .2) 25%,
            transparent 25%,
            transparent 50%,
            rgba(255, 255, 255, .2) 50%,
            rgba(255, 255, 255, .2) 75%,
            transparent 75%,
            transparent);
    background-size: 50px 50px;
    animation: magzpress-progress-stripes 1s linear infinite;
}

@keyframes magzpress-progress-stripes {
    from {
        background-position: 40px 0;
    }

    to {
        background-position: 0 0;
    }
}

/* Improved Tooltip System */
.magzpress-tooltip {
    position: relative;
    display: inline-block;
}

.magzpress-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 500;
}

.magzpress-tooltip::before {
    content: '';
    position: absolute;
    bottom: 122%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.magzpress-tooltip:hover::after,
.magzpress-tooltip:hover::before,
.magzpress-tooltip:focus::after,
.magzpress-tooltip:focus::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

/* Improved Focus Management */
.magzpress-viewer-actions *:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    border-radius: 4px;
}

.magzpress-viewer-actions button:focus,
.magzpress-viewer-actions a:focus {
    outline: none;
    box-shadow:
        0 0 0 2px white,
        0 0 0 4px #0073aa,
        0 4px 14px rgba(0, 115, 170, 0.25);
}

/* Skip Links for Accessibility */
.magzpress-skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1001;
    transition: top 0.3s ease;
}

.magzpress-skip-link:focus {
    top: 6px;
}

/* Enhanced Animation Performance */
.magzpress-viewer-actions,
.magzpress-view-pdf-btn {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {

    .magzpress-viewer-actions *,
    .magzpress-viewer-actions *::before,
    .magzpress-viewer-actions *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .magzpress-viewer-actions:hover {
        transform: none;
    }

    .magzpress-view-pdf-btn:hover {
        transform: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .magzpress-viewer-actions {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        border-color: rgba(148, 163, 184, 0.1);
        color: #e2e8f0;
    }

    .magzpress-viewer-actions-title {
        color: #f1f5f9;
    }

    .magzpress-viewer-actions-subtitle {
        color: #94a3b8;
    }
}

/* Print Styles */
@media print {
    .magzpress-viewer-actions {
        box-shadow: none;
        border: 1px solid #ccc;
        background: white;
    }

    .magzpress-viewer-actions::before,
    .magzpress-viewer-actions::after {
        display: none;
    }
}

/* Enhanced Interactive Features CSS */

/* Error Message Styling */
.magzpress-error-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fca5a5;
    border-left: 4px solid #dc2626;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #991b1b;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.1);
    animation: magzpress-slide-in 0.3s ease-out;
}

@keyframes magzpress-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.magzpress-error-message .dashicons {
    color: #dc2626;
    font-size: 18px;
    flex-shrink: 0;
}

.magzpress-error-message .error-text {
    flex: 1;
    line-height: 1.4;
}

.magzpress-retry-btn,
.magzpress-error-close {
    background: #dc2626;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
    min-height: 32px;
}

.magzpress-retry-btn:hover,
.magzpress-error-close:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

.magzpress-error-close {
    background: #6b7280;
    padding: 0.5rem;
    min-width: 32px;
    justify-content: center;
}

.magzpress-error-close:hover {
    background: #4b5563;
}

/* Status Popup Styling */
.magzpress-status-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.status-popup-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    margin: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: magzpress-popup-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes magzpress-popup-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.status-popup-content h4 {
    margin: 0 0 1rem 0;
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
}

.status-popup-content p {
    margin: 0 0 1.5rem 0;
    color: #4b5563;
    line-height: 1.5;
}

.status-popup-close {
    background: #0073aa;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.status-popup-close:hover {
    background: #005a87;
    transform: translateY(-1px);
}

/* Enhanced Focus States */
.magzpress-viewer-actions.has-focus {
    border-color: rgba(0, 115, 170, 0.2);
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.04),
        0 1px 3px rgba(0, 0, 0, 0.02),
        0 0 0 3px rgba(0, 115, 170, 0.1);
}

.magzpress-viewer-actions button.is-focused,
.magzpress-viewer-actions a.is-focused {
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 8px 25px rgba(0, 115, 170, 0.35),
        0 4px 12px rgba(0, 115, 170, 0.25),
        0 0 0 3px rgba(0, 115, 170, 0.3);
}

/* Enhanced Tooltip System */
.magzpress-tooltip.tooltip-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
    transition-delay: 0s;
}

.magzpress-tooltip.tooltip-visible::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
    transition-delay: 0s;
}

/* Improved Status Indicators */
.magzpress-viewer-actions-status:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    cursor: pointer;
}

.magzpress-viewer-actions-status[tabindex="0"] {
    cursor: pointer;
}

.magzpress-viewer-actions-status[tabindex="0"]:hover {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
}

.magzpress-viewer-actions-status[data-status="preview"][tabindex="0"]:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
}

/* Screen Reader Only Text */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    background: #f1f1f1;
    border-radius: 3px;
    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
    clip: auto !important;
    color: #21759b;
    display: block;
    font-size: 14px;
    font-weight: bold;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .magzpress-viewer-actions {
        border: 2px solid #000;
    }

    .magzpress-view-pdf-btn,
    .magzpress-download-btn {
        border: 2px solid #000;
    }

    .magzpress-viewer-actions-status {
        border: 2px solid #000;
    }
}

/* Reduced Motion Animations */
@media (prefers-reduced-motion: reduce) {

    .magzpress-error-message,
    .status-popup-content {
        animation: none;
    }

    .magzpress-viewer-actions.has-focus,
    .magzpress-viewer-actions button.is-focused,
    .magzpress-viewer-actions a.is-focused {
        transform: none;
        transition: none;
    }
}

/* Print Styles for Error Messages */
@media print {

    .magzpress-error-message,
    .magzpress-status-popup {
        display: none;
    }
}

/* Dark Mode Enhancements */
@media (prefers-color-scheme: dark) {
    .magzpress-error-message {
        background: linear-gradient(135deg, #2d1b1b 0%, #3f1f1f 100%);
        border-color: #7f1d1d;
        color: #fca5a5;
    }

    .status-popup-content {
        background: #1f2937;
        color: #f9fafb;
    }

    .status-popup-content h4 {
        color: #f9fafb;
    }

    .status-popup-content p {
        color: #d1d5db;
    }
}