/**
 * Flipbook Management Interface Styles
 * Requirements: 4.3, 4.4, 4.5 - Flipbook listing, metadata editing, deletion functionality
 */

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    margin-bottom: 0;
}

.section-actions {
    display: flex;
    gap: 1rem;
}

/* Filters Section */
.filters-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e9ecef;
}

.filters-form {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filter-group:first-child {
    flex: 2;
    min-width: 250px;
}

.search-input {
    background: white;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

/* Results Summary */
.results-summary {
    margin-bottom: 1rem;
    color: #6c757d;
    font-size: 0.9rem;
}

/* Flipbooks List */
.flipbooks-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.flipbook-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.flipbook-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Flipbook Thumbnail */
.flipbook-thumbnail {
    flex-shrink: 0;
    width: 80px;
    height: 110px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.thumbnail-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show image when loaded (can be handled by JS or just default) */
.thumbnail-image[src] {
    opacity: 1;
}

.thumbnail-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    background: #f8f9fa;
    z-index: 1;
}

/* Show fallback when image fails or is missing */
.thumbnail-wrapper.fallback .thumbnail-image {
    display: none !important;
}

.thumbnail-wrapper.fallback .thumbnail-fallback {
    opacity: 1;
    /* Make it fully visible immediately */
}

.thumbnail-placeholder {
    font-size: 2rem;
    opacity: 0.6;
}

/* Flipbook Info */
.flipbook-info {
    flex: 1;
    min-width: 0;
    /* Allow text truncation */
}

.flipbook-title {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.3;
}

.flipbook-description {
    color: #6c757d;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.flipbook-description em {
    font-style: italic;
    opacity: 0.7;
}

.flipbook-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    color: #6c757d;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.meta-item.visibility-public {
    color: #28a745;
}

.meta-item.visibility-private {
    color: #ffc107;
}

/* Flipbook Actions */
.flipbook-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* No Flipbooks State */
.no-flipbooks {
    text-align: center;
    padding: 4rem 2rem;
    color: #6c757d;
}

.no-flipbooks-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-flipbooks h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.no-flipbooks p {
    font-size: 1.1rem;
    line-height: 1.6;
}

.no-flipbooks a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.no-flipbooks a:hover {
    text-decoration: underline;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
}

.pagination-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    text-decoration: none;
    color: #2c3e50;
    font-weight: 500;
    transition: all 0.3s ease;
}

.pagination-btn:hover {
    border-color: #667eea;
    background: #667eea;
    color: white;
    text-decoration: none;
}

.pagination-info {
    color: #6c757d;
    font-size: 0.9rem;
    padding: 0 1rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }

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

.modal-header {
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #2c3e50;
    margin: 0;
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #2c3e50;
}

.modal-body {
    padding: 1.5rem 2rem;
}

.modal-footer {
    padding: 1rem 2rem 1.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Loading States */
.flipbook-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.flipbook-item.deleting {
    background: #fff5f5;
    border-color: #fecaca;
}

/* Button States */
.btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

/* Enhanced Responsive Design - Mobile First */

/* Base mobile styles (320px and up) */
.section-header {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 1rem;
}

.section-actions {
    justify-content: center;
    flex-wrap: wrap;
}

.filters-form {
    flex-direction: column;
    gap: 1rem;
}

.filter-group {
    min-width: auto;
}

.filter-actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.flipbook-item {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1rem;
}

.flipbook-thumbnail {
    align-self: center;
}

.flipbook-meta {
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.flipbook-actions {
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.flipbook-actions .btn {
    min-width: 120px;
}

.pagination {
    flex-direction: column;
    gap: 1rem;
}

.pagination-btn {
    width: 100%;
    text-align: center;
    min-height: 44px;
}

.modal-content {
    margin: 1rem;
    max-width: none;
}

.modal-header,
.modal-body,
.modal-footer {
    padding-left: 1rem;
    padding-right: 1rem;
}

.modal-footer {
    flex-direction: column;
    gap: 0.5rem;
}

.modal-footer .btn {
    width: 100%;
}

/* Small devices (576px and up) */
@media (min-width: 576px) {
    .filters-form {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: end;
    }

    .filter-group:first-child {
        flex: 2;
        min-width: 200px;
    }

    .flipbook-actions .btn {
        min-width: auto;
    }

    .modal-footer {
        flex-direction: row;
        justify-content: flex-end;
    }

    .modal-footer .btn {
        width: auto;
    }
}

/* Medium devices (768px and up) */
@media (min-width: 768px) {
    .section-header {
        flex-direction: row;
        align-items: center;
        text-align: left;
    }

    .flipbook-item {
        flex-direction: row;
        text-align: left;
        gap: 1.5rem;
        padding: 1.5rem;
    }

    .flipbook-thumbnail {
        align-self: flex-start;
    }

    .flipbook-meta {
        justify-content: flex-start;
        gap: 1rem;
    }

    .flipbook-actions {
        justify-content: flex-end;
        width: auto;
        flex-wrap: nowrap;
    }

    .pagination {
        flex-direction: row;
        justify-content: center;
    }

    .pagination-btn {
        width: auto;
    }

    .modal-content {
        margin: 0;
        max-width: 500px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    .btn,
    .pagination-btn,
    .modal-close {
        min-height: 44px;
        min-width: 44px;
    }

    .flipbook-item:hover {
        transform: none;
    }

    .flipbook-item:active {
        transform: scale(0.99);
        transition: transform 0.1s ease;
    }

    .btn:hover {
        transform: none;
    }

    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Print Styles */
@media print {

    .filters-section,
    .flipbook-actions,
    .pagination,
    .modal {
        display: none;
    }

    .flipbook-item {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }

    .flipbook-item:hover {
        transform: none;
    }
}