/**
 * Comments Panel Styles
 * Slide-up comments panel with elastic animation
 * Horizontal layout: form left, comments right (scrollable)
 * 
 * @package Fotografiescu
 * @version 2.1.0 - Horizontal layout, positioned above controls
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --controls-height: 42px;
    --thumbnail-height: 110px; /* 100px image + 5px top + 5px bottom padding */
    --comments-panel-height: 260px;
    --comments-panel-bottom: calc(var(--controls-height) + var(--thumbnail-height) + 50px);
}

/* ========================================
   Comments Panel Container
   ======================================== */

.comments-panel {
    position: fixed !important;
    top: auto !important;
    /* Position dynamically above info overlay (set by JS) */
    bottom: var(--panel-snap-bottom, 300px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100%;
    height: var(--comments-panel-height);
    max-height: 35vh;
    background: rgba(20, 20, 20, 0.70);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0;
    margin: 0;
    /* Start hidden below viewport */
    transform: translateY(calc(100% + var(--comments-panel-bottom)));
    /* Elastic animation curve */
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Hidden state */
.comments-panel.hidden {
    transform: translateY(calc(100% + var(--comments-panel-bottom))) !important;
    pointer-events: none;
    visibility: hidden;
}

/* Opening - slide up (visible state) */
.comments-panel.visible,
.comments-panel:not(.hidden):not(.closing) {
    transform: translateY(0) !important;
    visibility: visible;
}

/* Closing animation */
.comments-panel.closing {
    transform: translateY(calc(100% + var(--comments-panel-bottom))) !important;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    visibility: visible;
}

/* ========================================
   Info Overlay - Comments Open State
   Info overlay stays in place - panels open ABOVE it
   ======================================== */

/* REMOVED: Info overlay no longer moves when panels open */

/* ========================================
   Header
   ======================================== */

.comments-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 8px 16px 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.comments-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}

/* Close button - now first element */
.comments-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.comments-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.comments-close .icon {
    width: 14px;
    height: 14px;
}

.comments-count {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
}

.comments-count:not(:empty)::before {
    content: '(';
}

.comments-count:not(:empty)::after {
    content: ')';
}

/* ========================================
   Main Body - Horizontal Layout
   ======================================== */

.comments-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-height: 0;
    padding: 0;
    margin: 0;
}

/* ========================================
   Left Column - Form
   ======================================== */

.comment-form {
    width: auto;
    min-width: 200px;
    max-width: 280px;
    flex-shrink: 0;
    padding: 12px 16px 12px 12px;
    margin-left: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

/* Reply indicator */
.reply-indicator {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
}

.reply-indicator.visible,
#reply-indicator[style*="display: flex"] {
    display: flex;
}

.cancel-reply-btn {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.cancel-reply-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.cancel-reply-btn .icon {
    width: 10px;
    height: 10px;
}

/* Author fields - vertical stack */
.comment-author-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.comment-author-fields input {
    width: 100%;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    color: #fff;
    font-size: 12px;
    transition: border-color 0.2s ease;
}

.comment-author-fields input:focus {
    outline: none;
    border-color: #3b82f6;
}

.comment-author-fields input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Comment textarea */
.comment-input-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.comment-input-wrapper textarea {
    width: 100%;
    flex: 1;
    min-height: 40px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    resize: none;
    transition: border-color 0.2s ease;
}

.comment-input-wrapper textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.comment-input-wrapper textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Form footer */
.comment-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 4px;
}

.char-count {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

#comment-submit {
    padding: 6px 14px;
    background: #3b82f6;
    border: none;
    border-radius: 5px;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

#comment-submit:hover:not(:disabled) {
    background: #2563eb;
}

#comment-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#comment-submit .spinner {
    width: 12px;
    height: 12px;
    border-width: 2px;
}

/* Form error */
.form-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 11px;
}

/* ========================================
   Right Column - Comments Container
   ======================================== */

.comments-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ========================================
   States (Loading, Empty, Error)
   ======================================== */

.comments-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    flex: 1;
}

.comments-state svg {
    margin-bottom: 8px;
    opacity: 0.5;
    width: 32px;
    height: 32px;
}

.comments-state p {
    margin: 0;
    font-size: 13px;
}

.comments-state .hint {
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
}

.comments-state .error-message {
    color: #f87171;
}

.retry-btn {
    margin-top: 8px;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Spinner */
.comments-state .spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Comments List (Scrollable)
   ======================================== */

.comments-list {
    flex: 1;
    padding: 12px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comments-list:empty {
    display: none;
}

/* ========================================
   Individual Comment Item
   ======================================== */

.comment-item {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.comment-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.comment-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    flex-shrink: 0;
}

.comment-meta {
    flex: 1;
    min-width: 0;
}

.comment-author {
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}

.comment-date {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

.comment-content {
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

.comment-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.comment-action-btn {
    background: none;
    border: none;
    padding: 3px 6px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.comment-action-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* ========================================
   Login Prompt
   ======================================== */

.comments-login-prompt {
    padding: 8px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.comments-login-prompt a {
    color: #3b82f6;
    text-decoration: none;
}

.comments-login-prompt a:hover {
    text-decoration: underline;
}

.comments-login-prompt.hidden {
    display: none;
}

/* ========================================
   Mobile/Tablet Responsive - Vertical Layout
   ======================================== */

@media (max-width: 900px) {
    :root {
        --comments-panel-height: 320px;
    }
    
    .comments-panel {
        max-height: 45vh;
    }
    
    .comments-body {
        flex-direction: column;
    }
    
    .comment-form {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 10px 14px;
        max-height: none;
        flex-shrink: 0;
    }
    
    .comment-author-fields {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .comment-author-fields input {
        flex: 1;
        min-width: 100px;
    }
    
    .comment-author-fields input:last-child {
        flex: 100%;
    }
    
    .comments-container {
        flex: 1;
        min-height: 80px;
    }
    
    .comments-list {
        padding: 10px 14px;
    }
}

@media (max-width: 600px) {
    :root {
        --comments-panel-height: 55vh;
        --comments-panel-bottom: 100px;
    }
    
    .comments-panel {
        max-height: 55vh;
    }
    
    .comment-author-fields {
        flex-direction: column;
    }
    
    .comment-author-fields input:last-child {
        flex: 1;
    }
    
    .comments-header {
        padding: 6px 14px;
    }
    
    .comments-header h3 {
        font-size: 12px;
    }
}

/* ========================================
   Scrollbar Styling
   ======================================== */

.comments-list::-webkit-scrollbar,
.comment-form::-webkit-scrollbar {
    width: 4px;
}

.comments-list::-webkit-scrollbar-track,
.comment-form::-webkit-scrollbar-track {
    background: transparent;
}

.comments-list::-webkit-scrollbar-thumb,
.comment-form::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.comments-list::-webkit-scrollbar-thumb:hover,
.comment-form::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ========================================
   INFO PANEL STYLES
   Matches comments panel styling
   ======================================== */

.info-panel {
    position: fixed !important;
    top: auto !important;
    /* Position dynamically above info overlay (set by JS) */
    bottom: var(--panel-snap-bottom, 300px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100%;
    height: var(--comments-panel-height);
    max-height: 35vh;
    background: rgba(20, 20, 20, 0.70);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0;
    margin: 0;
    transform: translateY(calc(100% + var(--comments-panel-bottom)));
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.info-panel.hidden {
    transform: translateY(calc(100% + var(--comments-panel-bottom))) !important;
    pointer-events: none;
    visibility: hidden;
}

.info-panel.visible,
.info-panel:not(.hidden):not(.closing) {
    transform: translateY(0) !important;
    visibility: visible;
}

.info-panel.closing {
    transform: translateY(calc(100% + var(--comments-panel-bottom))) !important;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    visibility: visible;
}

/* REMOVED: Info overlay no longer moves when info panel opens */

/* Info Panel Header */
.info-panel-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 16px 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    gap: 12px;
}

/* Close button - now first element */
.info-panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    order: -1; /* Ensure it's first */
}

.info-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.info-panel-close .icon {
    width: 14px;
    height: 14px;
}

.info-panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* Stats in header */
.info-header-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    justify-content: flex-start;
    margin-left: 20px;
}

.info-header-stats .info-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.info-header-stats .info-stat-icon {
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.5);
}

.info-header-stats .info-stat-value {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
}

/* Category badges in header */
.info-header-categories {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
    margin-right: 12px;
}

.info-header-categories:empty {
    display: none;
}

.info-category-badge {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    font-size: 11px;
    color: #60a5fa;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.info-category-badge:hover {
    background: rgba(59, 130, 246, 0.3);
}

.info-category-badge.primary {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
}

/* Info Panel Body - Horizontal Sections */
.info-panel-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px;
    gap: 16px;
}

/* Info Section */
.info-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.info-section:first-child {
    padding-left: 0;
}

.info-section:last-child {
    border-right: none;
    padding-right: 0;
}

.info-section-label {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stats Section - REMOVED, now in header */

/* Keywords Section */
.info-section-keywords {
    min-width: 200px;
    max-width: 300px;
}

.info-keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow-y: auto;
    max-height: 160px;
}

.info-keywords-list .keyword-tag {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
}

.info-keywords-list .keyword-tag:hover {
    background: rgba(59, 130, 246, 0.3);
    color: #fff;
}

.info-keywords-list .no-data,
.info-colors-list .no-data {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

/* Colors + Mood Combined Section (stacked) */
.info-section-colors-mood {
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-section-colors-mood .info-subsection {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-colors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.info-colors-list .color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.info-colors-list .color-swatch:hover {
    transform: scale(1.15);
}

.info-mood-value {
    font-size: 13px;
    color: #fff;
    line-height: 1.4;
}

.info-mood-value:empty::after {
    content: '-';
    color: rgba(255, 255, 255, 0.4);
}

/* Model Section */
.info-section-model {
    min-width: 140px;
}

.info-section-model.hidden {
    display: none;
}

.info-model-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-model-name {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
}

.info-model-name:empty {
    display: none;
}

.info-model-agency {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.info-model-agency:empty {
    display: none;
}

/* Technical Section */
.info-section-technical {
    min-width: 280px;
}

.info-technical-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 16px;
}

.info-tech-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-tech-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

.info-tech-value {
    font-size: 12px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Category Section - REMOVED, already displayed in overlay */

/* Active state for buttons */
.overlay-icon-btn.btn-info.active,
.overlay-icon-btn.btn-comments.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* Info Panel Responsive */
@media (max-width: 900px) {
    .info-panel {
        max-height: 45vh;
    }
    
    .info-panel-body {
        flex-wrap: wrap;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .info-section {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 12px 0;
        width: 100%;
    }
    
    .info-section:first-child {
        padding-top: 0;
    }
    
    .info-section:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .info-section-keywords,
    .info-section-technical {
        max-width: none;
        min-width: auto;
    }
    
    .info-technical-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* REMOVED: Info overlay no longer moves when panels open */
}

@media (max-width: 600px) {
    .info-panel {
        max-height: 55vh;
    }
    
    .info-technical-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .info-panel-header {
        padding: 6px 14px;
    }
    
    .info-panel-header h3 {
        font-size: 12px;
    }
}

/* Info Panel Scrollbar */
.info-panel-body::-webkit-scrollbar,
.info-keywords-list::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.info-panel-body::-webkit-scrollbar-track,
.info-keywords-list::-webkit-scrollbar-track {
    background: transparent;
}

.info-panel-body::-webkit-scrollbar-thumb,
.info-keywords-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.info-panel-body::-webkit-scrollbar-thumb:hover,
.info-keywords-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}
