/**
 * E-Paper Flipbook Frontend Styles
 * Modern, responsive design for newspaper e-papers
 */

/* =============================================================================
   FRONTEND GALLERY STYLES
   ========================================================================== */

.epaper-gallery {
    display: grid;
    gap: 30px;
    margin: 40px 0;
    padding: 20px;
}

.epaper-gallery.columns-2 {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.epaper-gallery.columns-3 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.epaper-gallery.columns-4 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.epaper-gallery-item {
    background: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    cursor: pointer;
}

.epaper-gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 16px;
    z-index: 1;
}

.epaper-gallery-item:hover::before {
    opacity: 1;
}

.epaper-gallery-item:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 20px 40px rgba(31, 38, 135, 0.25);
    border-color: rgba(102, 126, 234, 0.3);
}

.epaper-gallery-item .epaper-thumbnail {
    position: relative;
    height: 320px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.epaper-gallery-item .epaper-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    filter: brightness(0.9);
}

.epaper-gallery-item:hover .epaper-thumbnail img {
    transform: scale(1.1);
    filter: brightness(1);
}

.epaper-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
    z-index: 2;
}

.epaper-gallery-item:hover .epaper-overlay {
    opacity: 1;
}

.view-button {
    background: rgba(255, 255, 255, 0.95);
    color: #2c3e50;
    padding: 16px 28px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.view-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform: translate(-50%, -50%);
    z-index: -1;
}

.view-button:hover::before {
    width: 300px;
    height: 300px;
}

.view-button:hover {
    color: white;
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
    text-decoration: none;
}

.view-button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 14px;
    transition: transform 0.3s ease;
}

.view-button:hover .view-button-icon {
    transform: rotate(360deg);
}

.epaper-meta {
    padding: 25px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    position: relative;
}

.epaper-meta::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 0 0 8px 8px;
}

.epaper-meta h3 {
    margin: 0 0 15px 0;
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.3;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.epaper-date {
    color: #667eea;
    font-weight: 600;
    font-size: 15px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.epaper-date::before {
    content: "📅";
    font-size: 16px;
    filter: grayscale(0.3);
}

.epaper-pages {
    color: #6c757d;
    font-size: 14px;
    margin: 8px 0 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.epaper-pages::before {
    content: "📖";
    font-size: 14px;
    filter: grayscale(0.5);
}

/* No Thumbnail State */
.no-thumbnail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #6c757d;
    font-size: 16px;
    font-weight: 500;
    position: relative;
}

.no-thumbnail::before {
    content: "📰";
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.6;
    display: block;
}

.no-thumbnail::after {
    content: "PDF Preview";
    font-size: 14px;
    opacity: 0.7;
    margin-top: 8px;
}

/* Loading State */
.epaper-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

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

/* Empty Gallery State */
.epaper-gallery:empty::after {
    content: "📰 No e-papers available yet. Start by uploading your first PDF!";
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 40px;
    color: #6c757d;
    font-size: 18px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 20px;
    border: 2px dashed #dee2e6;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
}

/* =============================================================================
   FLIPBOOK VIEWER STYLES
   ========================================================================== */

.epaper-viewer-body {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    height: 100vh;
}

.viewer-container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.viewer-header {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.viewer-title {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: Georgia, serif;
}

.viewer-title::before {
    content: "📰";
    font-size: 24px;
    filter: grayscale(0);
}

.viewer-subtitle {
    font-size: 14px;
    opacity: 0.7;
    margin-left: 8px;
    font-weight: 400;
}

.viewer-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.viewer-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 18px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.viewer-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.viewer-btn:hover::before {
    left: 100%;
}

.viewer-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

.viewer-btn-download {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
    border-color: rgba(86, 171, 47, 0.3);
}

.viewer-btn-download:hover {
    background: linear-gradient(135deg, #4a9929 0%, #96d4b8 100%);
    box-shadow: 0 8px 25px rgba(86, 171, 47, 0.4);
}

.viewer-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.flipbook-container {
    width: 100%;
    height: 100%;
    max-width: 1400px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
    transform-origin: center center;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.flipbook-container.zoomed {
    cursor: grab;
    overflow: auto;
}

.flipbook-container.zoomed:active {
    cursor: grabbing;
}

.flipbook-container::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #667eea, #764ba2, #667eea);
    border-radius: 20px;
    z-index: -1;
    animation: borderAnimation 3s ease-in-out infinite;
}

@keyframes borderAnimation {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

#flipbook {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    border: none;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
    color: white;
}

.loading-spinner .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-spinner p {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

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

.zoom-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    z-index: 100;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.zoom-indicator::before {
    content: "🔍 ";
    margin-right: 4px;
}

/* =============================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 1200px) {
    .epaper-gallery.columns-4 {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 992px) {
    .epaper-gallery {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 25px;
        padding: 15px;
    }
    
    .epaper-gallery-item .epaper-thumbnail {
        height: 280px;
    }
}

@media (max-width: 768px) {
    .epaper-gallery {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 10px;
        margin: 20px 0;
    }
    
    .epaper-gallery-item .epaper-thumbnail {
        height: 250px;
    }
    
    .epaper-meta {
        padding: 20px;
    }
    
    .epaper-meta h3 {
        font-size: 18px;
    }
    
    .view-button {
        padding: 14px 24px;
        font-size: 15px;
    }
    
    /* Viewer Responsive */
    .viewer-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .viewer-title {
        font-size: 18px;
        text-align: center;
    }
    
    .viewer-controls {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .viewer-btn {
        padding: 8px 14px;
        font-size: 13px;
        min-width: auto;
    }
    
    .viewer-main {
        padding: 10px;
    }
    
    .flipbook-container {
        border-radius: 15px;
    }
    
    .zoom-indicator {
        top: 10px;
        right: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .epaper-gallery-item .epaper-thumbnail {
        height: 220px;
    }
    
    .epaper-meta {
        padding: 15px;
    }
    
    .epaper-meta h3 {
        font-size: 16px;
    }
    
    .view-button {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .viewer-controls {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .viewer-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* =============================================================================
   ACCESSIBILITY & INTERACTIONS
   ========================================================================== */

.epaper-gallery-item:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 3px;
}

.viewer-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .epaper-gallery-item {
        border: 2px solid #000;
    }
    
    .view-button {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .epaper-gallery-item:hover {
        transform: none;
    }
    
    .view-button:hover {
        transform: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .epaper-gallery-item {
        background: #2c3e50;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .epaper-meta {
        background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    }
    
    .epaper-meta h3 {
        color: #ecf0f1;
    }
    
    .epaper-date {
        color: #3498db;
    }
    
    .epaper-pages {
        color: #95a5a6;
    }
    
    .no-thumbnail {
        background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
        color: #95a5a6;
    }
}

/* Print styles */
@media print {
    .epaper-gallery-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .epaper-overlay,
    .view-button {
        display: none;
    }
}