/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background-color: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 20px;
    color: #333;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.gallery-nav .nav-link {
    text-decoration: none;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.gallery-nav .nav-link:hover {
    background-color: #f0f0f0;
    color: #333;
}

.gallery-nav .nav-link.active {
    color: #6c5ce7;
    font-weight: 700;
    background-color: #f0edff;
}

.gallery-nav .nav-select {
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: white;
    color: #666;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s, color 0.2s;
}

.gallery-nav .nav-select:hover {
    background-color: #f0f0f0;
    color: #333;
}

.gallery-nav .nav-select.active {
    color: #6c5ce7;
    font-weight: 700;
    background-color: #f0edff;
    border-color: #6c5ce7;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
    font-size: 18px;
    color: #666;
}

.loading i {
    margin-right: 10px;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 10px;
}

.image-card {
    position: relative;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-card img,
.image-card video {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    padding: 15px;
    opacity: 0;
    transition: opacity 0.3s;
}

.image-card:hover .image-overlay {
    opacity: 1;
}

.image-stats {
    display: flex;
    gap: 15px;
    color: white;
    font-size: 14px;
}

.image-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    background-color: white;
    border-radius: 8px;
    color: #999;
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 18px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    max-width: 1200px;
    width: 100%;
    height: calc(100vh - 40px);
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 8px;
    font-size: 20px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    z-index: 1001;
    background-color: rgba(255, 255, 255, 0.9);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    transition: background-color 0.3s;
}

.modal-close:hover {
    background-color: #f0f0f0;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: #666;
    cursor: pointer;
    z-index: 1001;
    background-color: rgba(255, 255, 255, 0.9);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.modal-nav:hover {
    background-color: #f0f0f0;
}

.modal-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.modal-nav-prev {
    left: 15px;
}

.modal-nav-next {
    right: 15px;
}

/* Fullscreen Button */
.fullscreen-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    font-size: 16px;
    color: #fff;
    cursor: pointer;
    z-index: 1001;
    background-color: rgba(0, 0, 0, 0.5);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.fullscreen-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Fullscreen Mode */
.modal.fullscreen-mode {
    padding: 0;
    background-color: #000;
}

.modal.fullscreen-mode .modal-content {
    max-width: 100%;
    width: 100%;
    height: 100%;
    border-radius: 0;
    background-color: #000;
}

.modal.fullscreen-mode .modal-body {
    height: 100%;
}

.modal.fullscreen-mode .image-section {
    width: 100%;
    height: 100%;
}

.modal.fullscreen-mode .image-section img,
.modal.fullscreen-mode .image-section video {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    object-fit: contain;
}

.modal.fullscreen-mode .image-section .video-wrapper {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
}

.modal.fullscreen-mode .image-section .video-wrapper video {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
}

.modal.fullscreen-mode .info-section {
    display: none;
}

.modal.fullscreen-mode .modal-close {
    top: 15px;
    right: 15px;
    font-size: 24px;
    width: 36px;
    height: 36px;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.fullscreen-mode .modal-close:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.fullscreen-mode .modal-nav {
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    width: 48px;
    height: 48px;
    font-size: 24px;
}

.modal.fullscreen-mode .modal-nav:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.fullscreen-mode .fullscreen-btn {
    bottom: 15px;
    right: 15px;
}

.modal-body {
    display: flex;
    height: 100%;
}

.image-section {
    flex: 1;
    position: relative;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-section img,
.image-section video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-section .video-wrapper {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.info-section {
    width: 400px;
    display: flex;
    flex-direction: column;
    background-color: white;
    max-height: 90vh;
    overflow-y: auto;
}

.user-interaction-row {
    padding: 10px 50px 10px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.user-info i {
    font-size: 24px;
    color: #666;
}

.interaction-bar {
    display: flex;
    gap: 20px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: #333;
    transition: color 0.3s;
}

.btn-icon:hover {
    color: #007bff;
}

.btn-icon.liked {
    color: #e74c3c;
}

.btn-icon i {
    font-size: 20px;
}

/* Comments Section */
.comments-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.loading-comments {
    text-align: center;
    padding: 20px;
    color: #666;
}

.loading-comments i {
    font-size: 24px;
}

.error-message {
    text-align: center;
    padding: 20px;
    color: #e74c3c;
}

.no-comments {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.comment-item {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-user {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.comment-user i {
    margin-right: 5px;
    color: #666;
}

.comment-time {
    font-size: 12px;
    color: #999;
}

.comment-content {
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.comment-actions {
    display: flex;
    gap: 10px;
}

.comment-like-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
    transition: color 0.3s;
}

.comment-like-btn:hover {
    color: #e74c3c;
}

.comment-input-container {
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

.comment-input-container input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

.comment-input-container input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.comment-input-container .btn-primary {
    background-color: #007bff;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.comment-input-container .btn-primary:hover:not(:disabled) {
    background-color: #0056b3;
}

.comment-input-container .btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Login Prompt Modal */
.modal-content-small {
    background-color: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.modal-content-small h3 {
    margin-bottom: 15px;
    font-size: 20px;
}

.modal-content-small p {
    margin-bottom: 25px;
    color: #666;
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-primary {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: #0056b3;
}

/* Stored Images Section (Card style) */
.card {
    background-color: white;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stored-image-card {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: border-color 0.3s, transform 0.2s;
    text-align: center;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    background-color: white;
}

.stored-image-card:hover {
    border-color: #007bff;
    transform: translateY(-2px);
}

.stored-image-card.selected {
    border-color: #28a745;
    background-color: #f8fff8;
}

.stored-image-card img,
.stored-image-card video {
    width: 100%;
    flex: 1;
    object-fit: cover;
    border-radius: 4px;
    min-height: 100px;
    max-height: 180px;
    background-color: #f0f0f0;
}

.stored-image-card .file-name {
    font-size: 11px;
    color: #666;
    margin-top: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .image-card img,
    .image-card video {
        height: 150px;
    }

    .modal-body {
        flex-direction: column;
    }

    .info-section {
        width: 100%;
        max-height: 50vh;
    }

    .image-section {
        max-height: 40vh;
    }

    .image-section img,
    .image-section video {
        max-height: 40vh;
    }

    .image-section .video-wrapper {
        max-height: 40vh;
    }

    .header h1 {
        font-size: 18px;
    }

    .modal-nav-next {
        right: 15px;
    }
}

/* Video Merge Mode */
.merge-mode .stored-image-card:not(.merge-selectable) {
    opacity: 0.4;
    pointer-events: none;
}

.merge-mode .stored-image-card.merge-selectable {
    cursor: pointer;
}

.stored-image-card.merge-selected {
    border-color: #007bff !important;
    background-color: #f0f7ff;
    box-shadow: 0 0 0 2px #007bff;
}

.merge-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: #007bff;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
