/* ==========================================
   MangaStudio - Image Viewer Modal
   Apple Minimalist Design
   ========================================== */

/* Modal Container */
.image-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Backdrop Overlay */
.image-viewer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Content Container */
.image-viewer-content {
    position: relative;
    width: 90vw;
    max-width: 900px;
    height: 85vh;
    max-height: 85vh;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

/* Close Button */
.viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* Navigation Arrows */
.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-nav:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.viewer-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.viewer-nav:disabled:hover {
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
}

.viewer-nav-prev {
    left: 16px;
}

.viewer-nav-next {
    right: 16px;
}

.viewer-nav svg {
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Image Counter */
.viewer-counter {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10;
    letter-spacing: 0.02em;
}

/* Image Container */
.viewer-image-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    padding: 20px;
    overflow: hidden;
}

.viewer-image-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-md);
}

/* Text Container */
.viewer-text-container {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
    max-height: 25vh;
    overflow-y: auto;
}

.viewer-text-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.viewer-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
    white-space: pre-wrap;
}

/* ==========================================
   Sidebar Images Grid Styles
   ========================================== */

.images-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.images-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 12px;
    color: var(--text-tertiary);
    text-align: center;
}

.images-empty svg {
    opacity: 0.5;
}

.images-empty span {
    font-size: 12px;
}

.images-loading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--text-tertiary);
}

.image-thumb {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.image-thumb:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-thumb .image-number {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Spinner Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* ==========================================
   Responsive Adjustments
   ========================================== */

@media (max-width: 768px) {
    .image-viewer-modal {
        padding: 10px;
    }

    .image-viewer-content {
        width: 100%;
        max-width: 100%;
        height: 90vh;
        max-height: 90vh;
        border-radius: var(--radius-lg);
    }

    .viewer-image-container {
        flex: 1;
        min-height: 0;
    }

    .viewer-image-container img {
        max-width: 100%;
        max-height: 100%;
    }

    .viewer-text-container {
        max-height: 35vh;
        padding: 16px;
    }

    .viewer-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }

    .viewer-nav {
        width: 36px;
        height: 36px;
    }

    .viewer-nav-prev {
        left: 8px;
    }

    .viewer-nav-next {
        right: 8px;
    }

    .viewer-counter {
        font-size: 12px;
        padding: 5px 10px;
    }
}
