/* ============================================================================
   Collection Viewer Modal - Premium Design System
   Elegant modal for viewing and managing collection poems
   ============================================================================ */

/* Base Modal */
.collection-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.collection-viewer-modal.active {
    opacity: 1;
    visibility: visible;
}

/* Overlay with animated gradient */
.collection-viewer-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        rgba(10, 10, 12, 0.95) 0%, 
        rgba(20, 18, 15, 0.95) 50%,
        rgba(10, 10, 12, 0.95) 100%
    );
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Content Container */
.collection-viewer-content {
    position: relative;
    width: 100%;
    max-width: 1000px;
    max-height: 85vh;
    background: linear-gradient(165deg, 
        rgba(28, 26, 24, 0.98) 0%, 
        rgba(22, 20, 18, 0.99) 100%
    );
    border-radius: 24px;
    box-shadow: 
        0 0 0 1px rgba(212, 165, 116, 0.15),
        0 24px 80px rgba(0, 0, 0, 0.6),
        0 0 100px rgba(212, 165, 116, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.collection-viewer-modal.active .collection-viewer-content {
    transform: translateY(0) scale(1);
}

/* ============================================================================
   HEADER
   ============================================================================ */

.collection-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    background: linear-gradient(180deg, 
        rgba(212, 165, 116, 0.08) 0%, 
        rgba(212, 165, 116, 0.02) 100%
    );
    border-bottom: 1px solid rgba(212, 165, 116, 0.12);
    flex-shrink: 0;
    gap: 16px;
}

.collection-viewer-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

/* Close Button */
.collection-viewer-close {
    background: transparent;
    border: 1px solid rgba(212, 165, 116, 0.2);
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
    color: #A89B8D;
}

.collection-viewer-close:hover {
    background: rgba(212, 165, 116, 0.1);
    border-color: rgba(212, 165, 116, 0.3);
    color: #D4A574;
    transform: rotate(90deg);
}

/* Collection Icon */
.collection-viewer-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, 
        rgba(212, 165, 116, 0.2) 0%, 
        rgba(212, 165, 116, 0.08) 100%
    );
    border: 1px solid rgba(212, 165, 116, 0.25);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.collection-viewer-icon svg {
    width: 26px;
    height: 26px;
    color: #D4A574;
}

/* Header Info */
.collection-viewer-header-info {
    flex: 1;
    min-width: 0;
}

.collection-viewer-title {
    font-family: 'Scheherazade New', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #F5EDE4;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.collection-viewer-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #8A7F74;
}

.collection-viewer-count {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.9rem;
    color: #8A7F74;
}

.collection-viewer-count svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* Header Actions */
.collection-viewer-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search Box */
.collection-viewer-search {
    position: relative;
    width: 200px;
}

.collection-viewer-search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 10px;
    color: #F5EDE4;
    font-size: 0.9rem;
    font-family: 'Markazi Text', serif;
    transition: all 0.25s ease;
}

.collection-viewer-search-input:focus {
    outline: none;
    border-color: rgba(212, 165, 116, 0.4);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

.collection-viewer-search-input::placeholder {
    color: #6B5F54;
}

.collection-viewer-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6B5F54;
    pointer-events: none;
    width: 18px;
    height: 18px;
    transition: color 0.25s ease;
}

.collection-viewer-search-input:focus + .collection-viewer-search-icon {
    color: #D4A574;
}

/* ============================================================================
   DESCRIPTION (if exists)
   ============================================================================ */

.collection-viewer-description {
    padding: 14px 28px;
    background: rgba(212, 165, 116, 0.03);
    border-bottom: 1px solid rgba(212, 165, 116, 0.08);
    flex-shrink: 0;
}

.collection-viewer-description p {
    margin: 0;
    color: #9A8E82;
    line-height: 1.6;
    font-size: 0.95rem;
    font-style: italic;
}

/* ============================================================================
   BODY / POEMS GRID
   ============================================================================ */

.collection-viewer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 165, 116, 0.25) transparent;
}

.collection-viewer-body::-webkit-scrollbar {
    width: 6px;
}

.collection-viewer-body::-webkit-scrollbar-track {
    background: transparent;
}

.collection-viewer-body::-webkit-scrollbar-thumb {
    background: rgba(212, 165, 116, 0.25);
    border-radius: 3px;
}

.collection-viewer-body::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 165, 116, 0.4);
}

/* Poems Grid */
.collection-viewer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

/* ============================================================================
   POEM CARD
   ============================================================================ */

.collection-poem-card {
    background: linear-gradient(160deg, 
        rgba(35, 32, 28, 0.8) 0%, 
        rgba(28, 25, 22, 0.9) 100%
    );
    border: 1px solid rgba(212, 165, 116, 0.1);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.collection-poem-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        rgba(212, 165, 116, 0.08) 0%, 
        transparent 50%
    );
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.collection-poem-card:hover {
    transform: translateY(-6px);
    border-color: rgba(212, 165, 116, 0.25);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(212, 165, 116, 0.08);
}

.collection-poem-card:hover::before {
    opacity: 1;
}

.collection-poem-card-content {
    padding: 18px;
    position: relative;
}

/* Category Badge */
.collection-poem-category {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #D4A574;
    background: rgba(212, 165, 116, 0.12);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Poem Title */
.collection-poem-title {
    font-family: 'Scheherazade New', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #F5EDE4;
    margin: 0 0 8px 0;
    line-height: 1.45;
    transition: color 0.25s ease;
}

.collection-poem-card:hover .collection-poem-title {
    color: #D4A574;
}

/* Poem Excerpt */
.collection-poem-excerpt {
    color: #9A8E82;
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0 0 14px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card Footer */
.collection-poem-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid rgba(212, 165, 116, 0.08);
}

/* Read Button */
.collection-poem-read-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #D4A574 0%, #C08850 100%);
    color: #1A1714;
    border: none;
    padding: 9px 16px;
    border-radius: 10px;
    font-family: 'Markazi Text', serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    flex: 1;
    justify-content: center;
}

.collection-poem-read-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.35);
    filter: brightness(1.1);
}

.collection-poem-read-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.25s ease;
}

.collection-poem-read-btn:hover svg {
    transform: translateX(-4px);
}

/* Remove Button */
.collection-poem-remove-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 70, 70, 0.2);
    color: #FF6B6B;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
    opacity: 0;
}

.collection-poem-card:hover .collection-poem-remove-btn {
    opacity: 1;
}

.collection-poem-remove-btn:hover {
    background: rgba(255, 70, 70, 0.15);
    border-color: rgba(255, 70, 70, 0.4);
    transform: scale(1.08);
}

/* ============================================================================
   PAGINATION
   ============================================================================ */

.collection-viewer-pagination {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 28px;
    border-top: 1px solid rgba(212, 165, 116, 0.1);
    background: rgba(20, 18, 16, 0.6);
    flex-shrink: 0;
}

.collection-viewer-pagination.visible {
    display: flex;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 8px;
    color: #A89B8D;
    font-family: 'Markazi Text', serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    padding: 0 10px;
}

.pagination-btn:hover:not(.disabled):not(.active) {
    background: rgba(212, 165, 116, 0.1);
    border-color: rgba(212, 165, 116, 0.3);
    color: #D4A574;
}

.pagination-btn.active {
    background: linear-gradient(135deg, #D4A574 0%, #C08850 100%);
    border-color: transparent;
    color: #1A1714;
    font-weight: 700;
}

.pagination-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-ellipsis {
    color: #6B5F54;
    padding: 0 4px;
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */

.collection-viewer-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 30px;
    text-align: center;
}

.collection-viewer-empty.visible {
    display: flex;
}

.collection-viewer-empty-icon {
    width: 70px;
    height: 70px;
    background: rgba(212, 165, 116, 0.08);
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.collection-viewer-empty-icon svg {
    width: 36px;
    height: 36px;
    color: #6B5F54;
}

.collection-viewer-empty h3 {
    font-family: 'Scheherazade New', serif;
    font-size: 1.3rem;
    color: #F5EDE4;
    margin: 0 0 8px 0;
}

.collection-viewer-empty p {
    color: #8A7F74;
    font-size: 0.95rem;
    margin: 0;
    max-width: 280px;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.collection-viewer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 30px;
    gap: 14px;
}

.collection-viewer-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(212, 165, 116, 0.15);
    border-top-color: #D4A574;
    border-radius: 50%;
    animation: cv-spin 0.8s linear infinite;
}

@keyframes cv-spin {
    to { transform: rotate(360deg); }
}

.collection-viewer-loading-text {
    color: #8A7F74;
    font-size: 0.9rem;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    .collection-viewer-modal {
        padding: 0;
    }
    
    .collection-viewer-content {
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        max-width: 100%;
    }
    
    .collection-viewer-header {
        flex-wrap: wrap;
        padding: 16px 18px;
        gap: 12px;
    }
    
    .collection-viewer-header-left {
        order: 1;
        width: 100%;
    }
    
    .collection-viewer-header-actions {
        order: 2;
        width: 100%;
    }
    
    .collection-viewer-search {
        width: 100%;
    }
    
    .collection-viewer-icon {
        width: 44px;
        height: 44px;
    }
    
    .collection-viewer-icon svg {
        width: 22px;
        height: 22px;
    }
    
    .collection-viewer-title {
        font-size: 1.25rem;
    }
    
    .collection-viewer-body {
        padding: 16px 18px;
    }
    
    .collection-viewer-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .collection-poem-card-content {
        padding: 16px;
    }
    
    .collection-poem-title {
        font-size: 1.15rem;
    }
    
    .collection-poem-remove-btn {
        opacity: 1;
    }
    
    .collection-viewer-pagination {
        padding: 14px 18px;
    }
}

@media (max-width: 400px) {
    .collection-viewer-close {
        width: 40px;
        height: 40px;
    }
    
    .collection-poem-footer {
        flex-direction: column;
        gap: 8px;
    }
    
    .collection-poem-read-btn {
        width: 100%;
    }
    
    .collection-poem-remove-btn {
        width: 100%;
        height: 38px;
    }
}
