/* Система комментирования v2 */

/* Панель комментариев */
#comment-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: #fff;
    border-left: 2px solid #e0e0e0;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    overflow-y: auto;
    z-index: 9999;
    font-family: inherit;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

#comment-panel.open {
    transform: translateX(0);
}

#comment-panel-header {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#comment-panel-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

#comment-count {
    background: #1976d2;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    margin-left: 8px;
}

#comment-list {
    padding: 0;
}

.comment-item {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.comment-item:hover {
    background: #f9f9f9;
}

.comment-item.active {
    background: #e3f2fd;
    border-left: 3px solid #1976d2;
}

.comment-quote {
    font-size: 12px;
    color: #666;
    background: #f5f5f5;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    border-left: 2px solid #1976d2;
    max-height: 60px;
    overflow: hidden;
}

.comment-text {
    font-size: 13px;
    color: #333;
    line-height: 1.4;
}

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

.comment-actions button {
    font-size: 11px;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.comment-actions .edit-btn {
    background: #e3f2fd;
    color: #1976d2;
}

.comment-actions .delete-btn {
    background: #ffebee;
    color: #c62828;
}

/* Кнопка открытия панели */
#toggle-panel-btn {
    position: fixed;
    top: calc(var(--header-h, 60px) + 12px);
    right: 20px;
    background: #1976d2;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    z-index: 9998;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

#toggle-panel-btn:hover {
    background: #1565c0;
}

#toggle-panel-btn.has-comments {
    background: #388e3c;
}

/* Popup для добавления комментария */
#comment-popup {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 10000;
    display: none;
    width: 300px;
}

#comment-popup .input-wrap {
    position: relative;
}

#comment-popup textarea {
    width: 100%;
    height: 80px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 40px 8px 8px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}

#comment-popup .popup-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

#comment-popup button {
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

#comment-popup .save-btn {
    background: #1976d2;
    color: white;
}

#comment-popup .cancel-btn {
    background: #eee;
    color: #333;
}

/* Голосовой ввод — кнопка внутри textarea */
#voice-btn {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 32px;
    height: 32px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#voice-btn:hover {
    background: #e3f2fd;
    border-color: #1976d2;
}

#voice-btn.recording {
    background: #ffebee;
    border-color: #c62828;
    animation: pulse-rec 1s infinite;
}

#voice-btn svg {
    width: 16px;
    height: 16px;
}

@keyframes pulse-rec {
    0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(198, 40, 40, 0); }
}

/* Кнопка добавления комментария при выделении */
#add-comment-btn {
    position: fixed;
    background: #1976d2;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    z-index: 10001;
    display: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Подсветка прокомментированного текста */
.commented-text {
    background: linear-gradient(to bottom, #fff9c4 0%, #fff59d 100%);
    border-bottom: 2px solid #fbc02d;
    cursor: pointer;
    padding: 0 2px;
    margin: 0 -2px;
    border-radius: 2px;
}

.commented-text:hover {
    background: #fff59d;
}

/* Экспорт панель */
#export-section {
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

#export-section button {
    width: 100%;
    padding: 10px;
    background: #388e3c;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

#export-section button:hover {
    background: #2e7d32;
}

/* Адаптация основного контента */
body.panel-open {
    margin-right: 320px;
    transition: margin-right 0.3s ease;
}

/* Пустое состояние */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: #999;
}

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

@media (max-width: 768px) {
    #comment-panel { width: 280px; }
    body.panel-open { margin-right: 0; }
    #toggle-panel-btn { right: 12px; padding: 8px 12px; font-size: 12px; }
}
