.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    align-items: start;
    /* padding: 10px 0 10px 0; */
    overflow-y: auto;
    scrollbar-width: thin;
    overflow: hidden;
    /* for Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.6) transparent;
}

.modal-content-container {
    display: block;
    width: 90%;
    height: 90%;
    overflow-y: auto;
    position: relative;
    padding: 20px;
}

/* ✅ For Chrome, Edge, Safari */
.modal::-webkit-scrollbar {
    width: 2px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
    /* transparent track */
}

.modal::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    /* semi-transparent thumb */
    border-radius: 4px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6);
}

.modal-content {
    flex: 1;
    object-fit: contain;
    margin: auto;
    display: block;
    max-width: 50%;
    max-height: 100%;
    border-radius: 8px;
}

#modalVideo {
    flex: 1;
    margin: auto;
    display: block;
    width: 100%;
    max-width: 50%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    background: #000;
}

.close {
    position: fixed;
    top: 10px;
    right: 10px;
    color: #fff;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 50%;
    z-index: 1;
}

.close ion-icon {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    background-color: #000;
}

#caption {
    margin: auto;
    display: block;
    text-align: center;
    color: #ccc;
    font-size: 18px;
    padding: 10px;
}

.carousel {
    position: relative;
    max-width: 1000px;
    width: min(100%, 1000px);
    max-height: min(70vh, 760px);
    height: min(70vh, 760px);
    overflow: hidden;
    margin: auto;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.carousel-inner {
    display: flex;
    align-items: center;
    height: 100%;
    transition: transform 0.5s ease;
}

.carousel-item {
    min-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.carousel img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    margin: auto;
}

.carousel-control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    cursor: pointer;
    width: 50px;
    height: 50px;
    line-height: 45px;
    text-align: center;
    z-index: 10;
}

.carousel-control.prev {
    left: 10px;
}

.carousel-control.next {
    right: 10px;
}

.carousel-indicators {
    display: flex;
    justify-content: center;
    position: absolute;
    bottom: 10px;
    width: 100%;
}

.indicator {
    width: 10px;
    height: 10px;
    background-color: #bbb;
    border-radius: 50%;
    margin: 0 5px;
    cursor: pointer;
}

.indicator.active {
    background-color: #333;
}

.box-modal-container {
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.carousel-description {
    text-align: center;
    margin-top: 20px;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.carousel-description h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #ccc;
}

.carousel-description p {
    font-size: 18px;
    color: #ccc;
    background-color: rgba(0, 0, 0, 0.78);
    padding: 10px 20px;
    border-radius: 10px;
}

.comment-section {
    flex: 1;
    height: 96%;
    display: none;
    flex-direction: column;
    background: rgba(30, 30, 30, 0.9);
    color: #fff;
    padding: 20px;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    overflow-y: auto;
}

.comment-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 16px;
    color: #ccc;
}

.comment-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.comment-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.comment-item img {
    border-radius: 50%;
    height: 48px;
    width: 48px;
    object-fit: cover;
}

.comment-content {
    flex: 1;
}

.comment-author {
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.comment-text {
    color: #ddd;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.comment-meta {
    font-size: 0.8rem;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 10px;
}

.comment-meta u {
    text-decoration: none;
    color: #aaa;
    cursor: pointer;
}

.comment-meta u:hover {
    color: #1e88e5;
}

.comment-meta span {
    font-size: 0.8rem;
    color: #ccc;
}

/* Input box */
.comment-input {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    margin-top: 15px;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 12px;
}

.comment-input img {
    border-radius: 50%;
    height: 40px;
    width: 40px;
    align-self: center;
}

.comment-input-field {
    position: relative;
    min-width: 0;
}

.comment-input input {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 20px;
    padding: 12px 44px 12px 16px;
    color: #fff;
    font-size: 0.98rem;
    min-height: 46px;
    line-height: 1.2;
    outline: none;
    box-sizing: border-box;
    transition: background 0.3s, box-shadow 0.2s ease;
}

.comment-input input:focus {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.25);
}

.comment-input input::placeholder {
    color: rgba(255, 255, 255, 0.65);
}

.comment-emoji-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.comment-emoji-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.comment-emoji-btn ion-icon {
    font-size: 17px;
}

.comment-emoji-picker {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: min(260px, calc(100vw - 120px));
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
    z-index: 20;
}

.comment-emoji-picker[hidden] {
    display: none !important;
}

.comment-emoji-picker button {
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    height: 34px;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

.comment-emoji-picker button:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* ✉️ Send button styling */
.send-btn {
    background: #1e88e5;
    color: #fff;
    border: none;
    padding: 11px 16px;
    border-radius: 20px;
    font-size: 0.92rem;
    min-height: 46px;
    min-width: 76px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    align-self: stretch;
}

.send-btn:hover {
    background: #42a5f5;
    transform: translateY(-1px);
}

.send-btn:active {
    background: #1565c0;
    transform: translateY(0);
}

/* Scrollbar styling */
.comment-section::-webkit-scrollbar {
    width: 4px;
}

.comment-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

.comment-section::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6);
}

.no-comments {
    text-align: center;
    color: #666;
    font-style: italic;
    margin: 10px 0;
}

.prev-comments-btn {
    display: block;
    margin-bottom: 10px;
    padding: 4px 8px;
    background-color: #eee;
    border: 1px solid #ccc;
    cursor: pointer;
}

.comment-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px 0;
}

.comment-spinner .spinner {
    border: 3px solid #ddd;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: comment-spinner 0.7s linear infinite;
}

@keyframes comment-spinner {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Mobile responsiveness */
@media only screen and (max-width: 768px) {
    .modal {
        flex-direction: column;
        overflow-y: auto;
        /* allow scrolling only inside modal, not window */
        align-items: flex-start;
    }

    .modal-content-container {
        flex-direction: column;
        width: 100%;
        height: auto;
        overflow: visible;
        padding: 0;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        border-radius: 0;
        max-height: 40vh;
        overflow-y: auto;
        flex-basis: 40%;
    }

    #modalVideo {
        max-width: 100%;
        width: 100%;
        max-height: 40vh;
        height: auto;
        flex-basis: 40%;
        border-radius: 0;
        overflow: hidden;
        object-fit: contain;
    }

    .comment-section {
        width: 100%;
        height: 100%;
        max-height: 50vh;
        overflow-y: auto;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        padding: 15px 0 0 0;
        box-sizing: border-box;
        display: flex;
    }



    .close {
        font-size: 40px;
    }

    #caption {
        font-size: 16px;
    }

    .box-modal-container {
        height: auto;
        padding: 10px;
    }

    .carousel {
        width: 100%;
        max-height: min(52vh, 420px);
        height: min(52vh, 420px);
        border-radius: 10px;
    }

    .carousel-control {
        width: 42px;
        height: 42px;
        line-height: 38px;
        font-size: 1.6rem;
    }

    .carousel-control.prev {
        left: 6px;
    }

    .carousel-control.next {
        right: 6px;
    }

    .carousel-description {
        margin-top: 12px;
    }

    .carousel-description h3 {
        font-size: 1.1rem;
    }

    .carousel-description p {
        font-size: 15px;
        padding: 8px 12px;
    }

    .comment-list {
        max-height: 55vh;
        overflow-y: auto;
    }

    .comment-list,
    .comment-header {
        padding: 10px;
    }

    .comment-input {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding: 10px;
        gap: 8px;
        align-items: end;
    }

    .comment-input img {
        height: 36px;
        width: 36px;
        align-self: center;
    }

    .comment-input-field {
        min-width: 0;
    }

    .comment-input input {
        width: 100% !important;
        border-radius: 12px;
        font-size: 0.95rem;
        padding: 12px 42px 12px 12px;
        min-height: 44px;
        height: auto;
    }

    .comment-emoji-btn {
        width: 28px;
        height: 28px;
        right: 7px;
    }

    .comment-emoji-picker {
        width: min(220px, calc(100vw - 90px));
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
        padding: 7px;
    }

    .send-btn {
        padding: 10px 12px;
        border-radius: 12px;
        font-size: 0.88rem;
        min-height: 44px;
        min-width: 70px;
    }

    .prev-comments-btn {
        width: 50%;
        margin: auto;
    }
}

@media only screen and (max-width: 480px) {
    #caption {
        font-size: 14px;
    }
}

@media only screen and (max-width: 400px) {
    .comment-input {
        grid-template-columns: auto 1fr;
        grid-template-areas:
            "avatar field"
            "send send";
        align-items: center;
    }

    .comment-input img {
        grid-area: avatar;
    }

    .comment-input-field {
        grid-area: field;
    }

    .send-btn {
        grid-area: send;
        width: 100%;
        justify-content: center;
    }

    .comment-input input {
        font-size: 0.9rem;
        padding: 10px 40px 10px 10px;
        min-height: 42px;
    }

    .comment-emoji-picker {
        width: min(210px, calc(100vw - 70px));
        grid-template-columns: repeat(4, 1fr);
    }

    .send-btn {
        font-size: 0.9rem;
        padding: 10px 12px;
    }
}
