/**
 * Magzen Plugin Base Styles
 * Main stylesheet for archive and viewer components
 */

/* ==========================================================================
   Base Layout & Grid System
   ========================================================================== */

.magzen-archive-wrapper,
.magzen-viewer-wrapper {
    margin: 20px 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.6;
}

.magzen-archive-wrapper {
    background: transparent;
}

.magzen-viewer-wrapper {
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
}

/* Archive Grid System */
.magzen-archive-grid {
    display: grid;
    gap: 30px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.magzen-columns-1 { grid-template-columns: 1fr; }
.magzen-columns-2 { grid-template-columns: repeat(2, 1fr); }
.magzen-columns-3 { grid-template-columns: repeat(3, 1fr); }
.magzen-columns-4 { grid-template-columns: repeat(4, 1fr); }
.magzen-columns-5 { grid-template-columns: repeat(5, 1fr); }
.magzen-columns-6 { grid-template-columns: repeat(6, 1fr); }

/* ==========================================================================
   Card Components
   ========================================================================== */

.magzen-issue-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.magzen-issue-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Card Cover */
.magzen-issue-cover {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
}

.magzen-issue-cover img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.magzen-issue-cover:hover img {
    transform: scale(1.05);
}

.magzen-no-cover {
    display: block;
    text-decoration: none;
    color: inherit;
}

.magzen-default-cover {
    height: 250px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
}

.magzen-cover-icon {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

.magzen-cover-text {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

/* Card Badge */
.magzen-issue-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}

.magzen-pdf-badge {
    background: #dc3545;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Card Content */
.magzen-issue-content {
    padding: 20px;
}

.magzen-issue-title {
    margin: 0 0 15px 0;
    font-size: 20px;
    line-height: 1.3;
    font-weight: 600;
}

.magzen-issue-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.magzen-issue-title a:hover {
    color: #007cba;
}

/* Card Meta */
.magzen-issue-meta {
    margin-bottom: 15px;
    font-size: 14px;
    color: #666;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.magzen-issue-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.magzen-meta-icon {
    font-size: 14px;
}

/* Card Excerpt */
.magzen-issue-excerpt {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.5;
    font-size: 14px;
}

/* Card Actions */
.magzen-issue-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ==========================================================================
   Button Components
   ========================================================================== */

.magzen-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    background: none;
    line-height: 1;
}

.magzen-btn-primary {
    background: #007cba;
    color: white;
}

.magzen-btn-primary:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
}

.magzen-btn-secondary {
    background: #6c757d;
    color: white;
}

.magzen-btn-secondary:hover {
    background: #545b62;
    color: white;
    text-decoration: none;
}

.magzen-btn-download {
    background: #28a745;
    color: white;
}

.magzen-btn-download:hover {
    background: #1e7e34;
    color: white;
    text-decoration: none;
}

.magzen-btn-fullscreen {
    background: #17a2b8;
    color: white;
}

.magzen-btn-fullscreen:hover {
    background: #117a8b;
    color: white;
    text-decoration: none;
}

.magzen-btn-outline {
    background: transparent;
    color: #007cba;
    border-color: #007cba;
}

.magzen-btn-outline:hover {
    background: #007cba;
    color: white;
    text-decoration: none;
}

/* ==========================================================================
   Viewer Components
   ========================================================================== */

.magzen-viewer-header {
    background: #fff;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.magzen-issue-info {
    flex: 1;
    min-width: 0;
}

.magzen-viewer-title {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: #333;
    font-weight: 600;
}

.magzen-viewer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 14px;
    color: #666;
}

.magzen-viewer-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* PDF Viewer */
.magzen-viewer-container {
    position: relative;
    background: #fff;
    margin: 0;
}

.magzen-pdf-viewer {
    position: relative;
    width: 100%;
}

.magzen-pdf-iframe {
    width: 100%;
    border: none;
    display: block;
    background: #f8f9fa;
}

.magzen-pdf-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: #f8f9fa;
}

.magzen-fallback-content {
    text-align: center;
    padding: 40px;
    max-width: 400px;
}

.magzen-fallback-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 20px;
}

.magzen-fallback-content h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 20px;
}

.magzen-fallback-content p {
    margin: 0 0 20px 0;
    color: #666;
}

/* Loading States */
.magzen-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.magzen-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: magzen-spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* Navigation */
.magzen-viewer-navigation {
    background: #fff;
    padding: 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.magzen-other-issues {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.magzen-nav-label {
    font-weight: 600;
    color: #333;
    margin-right: 10px;
}

/* ==========================================================================
   Upgrade Notice
   ========================================================================== */

.magzen-upgrade-notice {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.magzen-upgrade-content h4 {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
}

.magzen-upgrade-content p {
    margin: 0 0 15px 0;
    opacity: 0.9;
    line-height: 1.5;
}

.magzen-btn-upgrade {
    background: #e74c3c;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.magzen-btn-upgrade:hover {
    background: #c0392b;
    color: white;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Issue Type and Edition Styling
   ========================================================================== */

.magzen-issue-type {
    margin-bottom: 10px;
}

.magzen-type-badge {
    display: inline-block;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.magzen-type-badge-large {
    display: inline-block;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    margin-bottom: 15px;
}

.magzen-issue-type-header {
    text-align: center;
    margin-bottom: 20px;
}

.magzen-viewer-type {
    text-align: center;
    margin-bottom: 15px;
}

.magzen-issue-number,
.magzen-viewer-number {
    color: #8e44ad;
    font-weight: 600;
}

.magzen-issue-number-info {
    color: #8e44ad;
}

/* Archive specific styling */
.magzen-archive .magzen-issue-title {
    margin-bottom: 8px;
}

.magzen-archive .magzen-type-badge {
    margin-bottom: 10px;
}

/* Viewer specific styling */
.magzen-viewer-title {
    font-size: 2.2em;
    margin-bottom: 10px;
    text-align: center;
}

.magzen-viewer-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.magzen-viewer-meta > span {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #666;
}

/* RTL Support for new elements */
.magzen-rtl .magzen-type-badge,
.magzen-rtl .magzen-type-badge-large {
    direction: rtl;
}

.magzen-rtl .magzen-viewer-meta {
    direction: rtl;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .magzen-viewer-title {
        font-size: 1.8em;
    }

    .magzen-type-badge-large {
        font-size: 12px;
        padding: 6px 12px;
    }

    .magzen-viewer-meta {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}

/* ==========================================================================
   Error States
   ========================================================================== */

.magzen-archive-empty,
.magzen-viewer-error {
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    color: #6c757d;
    margin: 20px 0;
}

.magzen-error-content {
    max-width: 400px;
    margin: 0 auto;
}

.magzen-error-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 20px;
}

.magzen-error-content h3 {
    margin: 0 0 15px 0;
    color: #dc3545;
    font-size: 20px;
}

.magzen-error-content p {
    margin: 0 0 20px 0;
    color: #666;
}

/* ==========================================================================
   Fullscreen Support
   ========================================================================== */

.magzen-pdf-viewer:fullscreen {
    background: #000;
}

.magzen-pdf-viewer:fullscreen .magzen-pdf-iframe {
    width: 100vw !important;
    height: 100vh !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .magzen-columns-3,
    .magzen-columns-4,
    .magzen-columns-5,
    .magzen-columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .magzen-archive-grid {
        gap: 20px;
    }
    
    .magzen-issue-actions {
        flex-direction: column;
    }
    
    .magzen-viewer-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .magzen-viewer-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .magzen-viewer-navigation {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .magzen-other-issues {
        width: 100%;
        justify-content: flex-start;
    }
    
    .magzen-nav-label {
        width: 100%;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .magzen-archive-wrapper,
    .magzen-viewer-wrapper {
        margin: 10px 0;
    }
    
    .magzen-columns-2,
    .magzen-columns-3,
    .magzen-columns-4,
    .magzen-columns-5,
    .magzen-columns-6 {
        grid-template-columns: 1fr;
    }
    
    .magzen-issue-meta {
        flex-direction: column;
        gap: 5px;
    }
    
    .magzen-viewer-header,
    .magzen-viewer-navigation {
        padding: 15px;
    }
    
    .magzen-viewer-title {
        font-size: 20px;
    }
    
    .magzen-viewer-actions,
    .magzen-other-issues {
        flex-direction: column;
        width: 100%;
    }
    
    .magzen-btn {
        width: 100%;
        justify-content: center;
    }
}
