/**
 * Comment System Styles
 * shadcn-inspired clean design with dark theme support
 */

/* ─────────────────────────────────────────────────────────────────────────────
   Comment Panel Container
   ───────────────────────────────────────────────────────────────────────────── */

.comment-panel {
    position: fixed;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Desktop: right-side slide-in panel */
.comment-panel.desktop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.comment-panel.desktop.open {
    opacity: 1;
}

/* Mobile: full-screen overlay */
.comment-panel.mobile {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.comment-panel.mobile.open {
    opacity: 1;
}

.comment-panel-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Panel Content
   ───────────────────────────────────────────────────────────────────────────── */

.comment-panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-color, #1a1a1a);
}

/* Desktop: slide in from right */
.comment-panel.desktop .comment-panel-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    border-left: 1px solid var(--border-color, #333);
}

.comment-panel.desktop.open .comment-panel-content {
    transform: translateX(0);
}

/* Mobile: slide up from bottom */
.comment-panel.mobile .comment-panel-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90svh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.comment-panel.mobile.open .comment-panel-content {
    transform: translateY(0);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Header
   ───────────────────────────────────────────────────────────────────────────── */

.comment-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #333);
    flex-shrink: 0;
}

.comment-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color, #fff);
}

.comment-count {
    font-weight: 400;
    color: var(--text-muted, #888);
    font-size: 14px;
}

.comment-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.comment-panel-close:hover {
    background: var(--hover-bg, #333);
    color: var(--text-color, #fff);
}

.comment-panel-close svg {
    width: 18px;
    height: 18px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Body (Comments List)
   ───────────────────────────────────────────────────────────────────────────── */

.comment-panel-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.no-comments {
    text-align: center;
    color: var(--text-muted, #888);
    padding: 32px 16px;
    font-size: 14px;
}

.comment-error {
    text-align: center;
    color: #ef4444;
    padding: 16px;
}

.comments-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: var(--text-muted, #888);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color, #333);
    border-top-color: var(--accent-color, #3b82f6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.load-more-btn {
    display: block;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color, #333);
    background: transparent;
    color: var(--text-color, #fff);
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.load-more-btn:hover:not(:disabled) {
    background: var(--hover-bg, #333);
}

.load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Comment Item
   ───────────────────────────────────────────────────────────────────────────── */

.comment-item {
    display: flex;
    gap: 12px;
    padding: 6px;
    background: var(--card-bg, #222);
    border-bottom: 1px solid var(--border-color, #333);
}

.comment-avatar {
    flex-shrink: 0;
}

.avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.comment-body {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color, #fff);
}

.comment-time {
    font-size: 12px;
    color: var(--text-muted, #888);
}

.comment-delete-btn {
    margin-left: auto;
    padding: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.comment-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.comment-delete-btn svg {
    width: 14px;
    height: 14px;
}

.comment-content {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color, #fff);
    word-break: break-word;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Comment Images
   ───────────────────────────────────────────────────────────────────────────── */

.comment-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.comment-images img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 6px;
    cursor: pointer;
    object-fit: cover;
    transition: transform 0.2s;
}

.comment-images img:hover {
    transform: scale(1.05);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Video Embeds
   ───────────────────────────────────────────────────────────────────────────── */

.video-embed-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.video-embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    padding: 6px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-embed-container:hover .video-expand-btn {
    opacity: 1;
}

.video-expand-btn:hover {
    background: rgba(59, 130, 246, 0.9);
}

.video-expand-btn svg {
    width: 16px;
    height: 16px;
}

.video-preview {
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
}

.video-preview-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
}

.video-preview-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.video-preview:hover .video-play-button {
    background: rgba(59, 130, 246, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-play-button svg {
    width: 24px;
    height: 24px;
    color: #fff;
    margin-left: 4px; /* Center play icon */
}

.video-preview-info {
    padding: 8px 12px;
    background: var(--card-bg, #222);
}

.video-platform {
    font-size: 12px;
    color: var(--text-muted, #888);
}

/* Theater / Bigger Screen Overlay */
.video-theater-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.video-theater-overlay.active {
    opacity: 1;
}

.video-theater-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
}

.video-theater-content {
    position: relative;
    width: 90vw;
    max-width: 1200px;
    border-radius: 12px;
    overflow: hidden;
    background: #111;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.video-theater-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #1a1a1a;
}

.video-theater-title {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #ddd;
}

.video-theater-external,
.video-theater-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    text-decoration: none;
}

.video-theater-external:hover,
.video-theater-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.video-theater-external svg,
.video-theater-close svg {
    width: 18px;
    height: 18px;
}

.video-theater-player {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
}

.video-theater-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Reactions
   ───────────────────────────────────────────────────────────────────────────── */

.comment-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color, #333);
}

.reaction-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px;
    border: none;
    background: transparent;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.reaction-btn:hover {
    background: var(--hover-bg, #333);
    border-color: var(--text-muted, #888);
}

.reaction-btn.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

.reaction-emoji {
    font-size: 14px;
    line-height: 1;
}

.reaction-count {
    color: var(--text-muted, #888);
    font-size: 12px;
    min-width: 12px;
}

.reaction-btn.active .reaction-count {
    color: #3b82f6;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Footer (Input)
   ───────────────────────────────────────────────────────────────────────────── */

.comment-panel-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color, #333);
    background: var(--bg-color, #1a1a1a);
    flex-shrink: 0;
}

.comment-input-container {
    position: relative;
}

.comment-input-container.drag-over {
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
}

.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.image-preview {
    position: relative;
    width: 60px;
    height: 60px;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.remove-image {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
}

.comment-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.comment-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #333);
    background: var(--card-bg, #222);
    color: var(--text-color, #fff);
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
}

.comment-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.comment-input::placeholder {
    color: var(--text-muted, #888);
}

.comment-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.image-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color, #333);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted, #888);
    transition: all 0.2s;
}

.image-upload-btn:hover {
    background: var(--hover-bg, #333);
    color: var(--text-color, #fff);
}

.image-upload-btn svg {
    width: 18px;
    height: 18px;
}

.post-btn {
    padding: 8px 16px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.post-btn:hover:not(:disabled) {
    background: #2563eb;
}

.post-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Dark Theme Overrides (already dark by default)
   ───────────────────────────────────────────────────────────────────────────── */

.dark-theme .comment-panel {
    --bg-color: #1a1a1a;
    --card-bg: #222;
    --border-color: #333;
    --text-color: #fff;
    --text-muted: #888;
    --hover-bg: #333;
    --accent-color: #3b82f6;
}

/* Light theme support */
body:not(.dark-theme) .comment-panel {
    --bg-color: #fff;
    --card-bg: #f5f5f5;
    --border-color: #e5e5e5;
    --text-color: #1a1a1a;
    --text-muted: #666;
    --hover-bg: #eee;
    --accent-color: #3b82f6;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive Adjustments
   ───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .comment-item {
        padding: 10px;
    }
    
    .avatar-placeholder {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .comment-content {
        font-size: 13px;
    }
    
    .comment-images img {
        max-width: 100px;
        max-height: 100px;
    }
    
    .reaction-btn {
        padding: 3px 6px;
        font-size: 12px;
    }
    
    .reaction-emoji {
        font-size: 12px;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Comment Button in Popup
   ───────────────────────────────────────────────────────────────────────────── */

.marker-popup-comment-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 5px 12px;
    margin-top: 6px;
    background: transparent;
    border: 1px solid var(--border-color, #333);
    color: var(--text-color, #fff);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.marker-popup-comment-btn:hover {
    opacity: 0.9;
}

.marker-popup-comment-btn svg {
    width: 16px;
    height: 16px;
}

.marker-popup-comment-count {
    background: #3b82f6;
    color: #fff;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

@media (max-width: 768px) {
    .comment-panel-header {
        padding: 4px 12px;
    }
}