/* Modal Styles */
#details-modal,
#rating-details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#details-modal.modal-hidden,
#rating-details-modal.modal-hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: #fff;
    padding: 50px 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(1);
    transition: transform 0.3s ease;
    display: flex; /* Use flexbox for better control */
    flex-direction: column;
}

#details-modal .modal-content img {
    width: auto; /* Let width be auto to maintain aspect ratio */
    max-width: 100%; /* Don't exceed container width */
    max-height: 60vh; /* Limit height for very tall images */
    object-fit: contain; /* Ensure the whole image is visible */
    align-self: center; /* Center the image */
    border-radius: 8px;
    margin-bottom: 20px;
    cursor: pointer; /* Add cursor pointer to images in modal */
    transition: transform 0.2s ease;
}

#details-modal .modal-content img:hover {
    transform: scale(1.02);
}

#details-modal.modal-hidden .modal-content,
#rating-details-modal.modal-hidden .modal-content {
    transform: scale(0.95);
}

/* --- Modal Content Typography --- */
.modal-content h3 {
    margin: 0 0 10px 0;
    font-size: 1.8em; /* Modal title can be larger */
    color: #333;
}

.modal-content p {
    margin: 0 0 12px 0;
    font-size: 1em;
    line-height: 1.6;
    color: #666;
}

.modal-content .description {
    color: #555;
}

.modal-content .rating-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.modal-content .rating-table th,
.modal-content .rating-table td {
    border: 1px solid #e0e0e0;
    padding: 10px 15px;
    text-align: left;
}

.modal-content .rating-table th {
    background-color: #f9f9f9;
    font-weight: bold;
    color: #333;
}

.modal-content .rating-table td {
    color: #666;
}

.modal-content .rating-table tr:nth-child(even) {
    background-color: #fdfdfd;
}

.modal-content .release-date {
    font-size: 0.9em;
    color: #888;
}

.modal-content .category-info {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.modal-content .category-info p {
    margin: 0 0 5px 0;
    font-size: 0.9em;
}
.modal-content .details-info {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.modal-content .details-info p {
    margin: 0 0 5px 0;
    font-size: 0.9em;
}

.modal-content .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    font-size: 2.5em;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
    z-index: 10;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-content .close-btn:hover {
    color: #333;
}

.modal-content .share-btn {
    position: absolute;
    top: 20px;
    right: 80px; /* Position next to the close button */
    background: rgba(255, 255, 255, 0.8);
    border: none;
    font-size: 1.8em;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
    z-index: 10;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-content .share-btn:hover {
    color: #333;
}
.modal-content .series-tag {
    font-size: 0.9em;
}

/* Image Viewer Modal */
#image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050; /* Higher than other modals */
    opacity: 1;
    transition: opacity 0.3s ease;
}

#image-viewer.modal-hidden {
    opacity: 0;
    pointer-events: none;
}

.viewer-content {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    object-fit: contain;
    transition: transform 0.3s ease; /* Only animate transform (scale) */
    transform: scale(1);
    cursor: grab;
    position: relative; /* Needed for top/left positioning */
    top: 0;
    left: 0;
}

.viewer-content.dragging {
    cursor: grabbing;
}

#image-viewer.modal-hidden .viewer-content {
    transform: scale(0.9);
}

.close-viewer {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #fff;
    font-size: 2.5em;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 1051;
}

.close-viewer:hover {
    color: #ccc;
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    padding: 5px;
    display: flex;
    gap: 5px;
    z-index: 1051;
}

.zoom-controls button {
    background-color: transparent;
    border: none;
    color: white;
    font-size: 1.5em;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 50%;
}

.zoom-controls button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Styles for the error message in the modal */
.modal-error-info {
    padding: 20px;
    background-color: #fff3cd; /* A light yellow for warnings */
    border: 1px solid #ffeeba;
    border-radius: 8px;
    margin-bottom: 20px;
    color: #856404;
}

.modal-error-info h3 {
    margin-top: 0;
    color: #856404;
}

.modal-error-info ul {
    padding-left: 20px;
    margin-top: 10px;
}