/* Estilos personalizados para o sistema de comentários com Quill */

/* Editor Quill - Comentários */
.comment-content {
    line-height: 1.6;
    word-wrap: break-word;
}

.comment-content img {
    max-width: 80% !important;
    height: auto;
    margin: 10px 0;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
}

.comment-content p {
    margin-bottom: 10px;
}

.comment-content ul,
.comment-content ol,
.task-description-content ul,
.task-description-content ol {
    margin-bottom: 10px;
    padding-left: 20px;
}

/* Bloco de código do Quill em conteúdo renderizado: o quill.snow.css só estiliza
   .ql-code-block-container dentro de .ql-editor, então replicamos aqui para a visualização */
.comment-content .ql-code-block-container,
.task-description-content .ql-code-block-container {
    position: relative;
    margin: 5px 0;
    padding: 5px 10px;
    background-color: #23241f;
    color: #f8f8f2;
    border-radius: 3px;
    font-family: SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    white-space: pre-wrap;
    overflow: auto;
}

.comment-content .ql-code-block-container .ql-code-block,
.task-description-content .ql-code-block-container .ql-code-block {
    white-space: pre-wrap;
}

.comment-content pre,
.task-description-content pre {
    background-color: #23241f;
    color: #f8f8f2;
    padding: 5px 10px;
    border-radius: 3px;
    white-space: pre-wrap;
}

/* Correção de listas do Quill (bullet/ordered) em conteúdo renderizado */
.comment-content,
.task-description-content {
    counter-reset: list-0;
}

.comment-content ol,
.task-description-content ol {
    counter-reset: list-0;
}

.comment-content li[data-list],
.task-description-content li[data-list] {
    list-style: none;
    position: relative;
    padding-left: 1.5em;
}

.comment-content li[data-list]::before,
.task-description-content li[data-list]::before {
    position: absolute;
    left: 0;
    top: 0;
    width: 1.2em;
    text-align: right;
    white-space: nowrap;
}

.comment-content li[data-list="bullet"]::before,
.task-description-content li[data-list="bullet"]::before {
    content: "•";
}

.comment-content li[data-list="ordered"],
.task-description-content li[data-list="ordered"] {
    counter-increment: list-0;
}

.comment-content li[data-list="ordered"]::before,
.task-description-content li[data-list="ordered"]::before {
    content: counter(list-0, decimal) ". ";
}

.comment-content blockquote {
    margin: 10px 0;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-left: 4px solid #dee2e6;
    font-style: italic;
}

/* Quill editor customizations */
.ql-editor {
    min-height: 120px;
    max-height: 300px;
    overflow-y: auto;
}

.ql-editor.ql-blank::before {
    font-style: italic;
    color: #adb5bd;
}

/* Estilos para o editor Quill principal */
#quill-comment-editor,
#quill-project-comment-editor {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    background: #fff;
}

#quill-comment-editor:focus-within,
#quill-project-comment-editor:focus-within {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

#quill-comment-editor .ql-toolbar,
#quill-project-comment-editor .ql-toolbar {
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 12px 16px;
    border-radius: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

#quill-comment-editor .ql-container,
#quill-project-comment-editor .ql-container {
    border: none;
    border-radius: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#quill-comment-editor .ql-editor,
#quill-project-comment-editor .ql-editor {
    padding: 16px;
    min-height: 120px;
    line-height: 1.6;
    color: #495057;
}

#quill-comment-editor .ql-editor.ql-blank::before,
#quill-project-comment-editor .ql-editor.ql-blank::before {
    color: #adb5bd;
    font-style: normal;
    font-size: 14px;
}

/* Estilos para os botões da toolbar */
#quill-comment-editor .ql-toolbar .ql-formats,
#quill-project-comment-editor .ql-toolbar .ql-formats {
    margin-right: 15px;
}

#quill-comment-editor .ql-toolbar button,
#quill-project-comment-editor .ql-toolbar button {
    border-radius: 6px;
    transition: all 0.2s ease;
    margin: 0 2px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#quill-comment-editor .ql-toolbar button:hover,
#quill-project-comment-editor .ql-toolbar button:hover {
    background-color: #e3f2fd;
    color: #1976d2;
    transform: translateY(-1px);
}

#quill-comment-editor .ql-toolbar button.ql-active,
#quill-project-comment-editor .ql-toolbar button.ql-active {
    background-color: #2196f3;
    color: white;
}

#quill-comment-editor .ql-toolbar .ql-stroke,
#quill-project-comment-editor .ql-toolbar .ql-stroke {
    stroke: currentColor;
}

#quill-comment-editor .ql-toolbar .ql-fill,
#quill-project-comment-editor .ql-toolbar .ql-fill {
    fill: currentColor;
}

/* Estilos específicos para editor de edição */
#quill-edit-project-comment-editor {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    background: #fff;
}

#quill-edit-project-comment-editor:focus-within {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

#quill-edit-project-comment-editor .ql-toolbar {
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 12px 16px;
    border-radius: 0;
}

#quill-edit-project-comment-editor .ql-container {
    border: none;
    border-radius: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#quill-edit-project-comment-editor .ql-editor {
    padding: 16px;
    min-height: 150px;
    line-height: 1.6;
    color: #495057;
}

#quill-edit-project-comment-editor .ql-editor.ql-blank::before {
    color: #adb5bd;
    font-style: normal;
    font-size: 14px;
}

/* Modal de edição */
#editProjectCommentModal .modal-content {
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

#editProjectCommentModal .modal-header {
    border-bottom: 1px solid #e9ecef;
    padding: 1.25rem 1.5rem;
}

#editProjectCommentModal .modal-body {
    padding: 1.5rem;
}

#editProjectCommentModal .modal-footer {
    border-top: 1px solid #e9ecef;
    padding: 1rem 1.5rem;
}

/* Estilos para o formulário de comentários */
#commentForm,
#projectCommentForm {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e9ecef;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

#commentForm:focus-within,
#projectCommentForm:focus-within {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.1), 0 4px 16px rgba(0,123,255,0.15);
    transform: translateY(-2px);
}

#commentForm .form-label,
#projectCommentForm .form-label {
    font-size: 1.05rem;
    color: #495057;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

#commentForm .form-label i,
#projectCommentForm .form-label i {
    color: #007bff;
    font-size: 1.1rem;
}

/* Estilos para os botões do formulário */
#commentForm .btn,
#projectCommentForm .btn {
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#commentForm .btn:hover,
#projectCommentForm .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

#commentForm .btn-primary,
#projectCommentForm .btn-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    color: white;
}

#commentForm .btn-primary:hover,
#projectCommentForm .btn-primary:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
}

#commentForm .btn-outline-secondary,
#projectCommentForm .btn-outline-secondary {
    border: 2px solid #6c757d;
    color: #6c757d;
    background: transparent;
}

#commentForm .btn-outline-secondary:hover,
#projectCommentForm .btn-outline-secondary:hover {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

/* Upload de arquivos para comentários */
.file-item {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-item:last-child {
    margin-bottom: 0;
}

.file-item .file-info {
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.file-item .file-info i {
    color: #6c757d;
    margin-right: 8px;
}

.file-item .remove-btn {
    padding: 2px 6px;
    font-size: 12px;
    line-height: 1;
}

/* Preview de arquivos no comentário */
#comment-file-preview {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

#comment-file-preview .card-body {
    padding: 12px;
}

/* Timeline de comentários */
.timeline-item .comment-content {
    background-color: #fff;
    padding: 0;
    border: none;
    box-shadow: none;
}

.timeline-item .comment-attachments {
    margin-top: 10px;
}

.timeline-item .comment-attachments .list-group-item {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 4px;
    padding: 8px 12px;
    background-color: #f8f9fa;
}

.timeline-item .comment-attachments .list-group-item:hover {
    background-color: #e9ecef;
}

/* Indicador de carregamento para upload de imagens */
.ql-editor .loading-indicator {
    display: inline-block;
    padding: 2px 6px;
    background-color: #e9ecef;
    border-radius: 3px;
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

/* Drag and drop visual feedback */
.ql-editor.drag-over {
    background-color: #f8f9fa;
    border: 2px dashed #007bff;
    opacity: 0.8;
}

/* Estilos para imagens inline nos comentários */
.comment-content .ql-align-center {
    text-align: center;
}

.comment-content .ql-align-right {
    text-align: right;
}

.comment-content .ql-align-left {
    text-align: left;
}

.comment-content .ql-color-red {
    color: #dc3545;
}

.comment-content .ql-color-green {
    color: #198754;
}

.comment-content .ql-color-blue {
    color: #0d6efd;
}

.comment-content .ql-bg-yellow {
    background-color: #fff3cd;
}

.comment-content .ql-bg-pink {
    background-color: #f8d7da;
}

.comment-content .ql-bg-lightblue {
    background-color: #d1ecf1;
}

/* Responsividade */
@media (max-width: 768px) {
    .ql-toolbar {
        padding: 8px;
    }
    
    .ql-toolbar .ql-formats {
        margin-right: 8px;
    }
    
    .file-item {
        padding: 6px 8px;
        font-size: 14px;
    }
    
    .comment-content img {
        max-width: 80% !important;
        height: auto;
    }
}

/* Animações */
.file-item {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botão de anexar arquivos */
.btn-outline-primary {
    border-color: #0d6efd;
    color: #0d6efd;
}

.btn-outline-primary:hover {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

/* Estilos unificados para editores Quill - tanto tarefas quanto projetos */
#quill-comment-editor,
#quill-project-comment-editor,
#quill-edit-comment-editor,
#quill-edit-project-comment-editor {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.3s ease, height 0.2s ease;
    background: #fff;
}

#quill-comment-editor:focus-within,
#quill-project-comment-editor:focus-within,
#quill-edit-comment-editor:focus-within,
#quill-edit-project-comment-editor:focus-within {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

#quill-comment-editor .ql-toolbar,
#quill-project-comment-editor .ql-toolbar,
#quill-edit-comment-editor .ql-toolbar,
#quill-edit-project-comment-editor .ql-toolbar {
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 12px 16px;
    border-radius: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

#quill-comment-editor .ql-container,
#quill-project-comment-editor .ql-container,
#quill-edit-comment-editor .ql-container,
#quill-edit-project-comment-editor .ql-container {
    border: none;
    border-radius: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#quill-comment-editor .ql-editor,
#quill-project-comment-editor .ql-editor,
#quill-edit-comment-editor .ql-editor,
#quill-edit-project-comment-editor .ql-editor {
    padding: 16px;
    min-height: 120px;
    height: auto !important;
    max-height: none !important;
    line-height: 1.6;
    color: #495057;
    overflow: hidden !important;
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    resize: none;
    transition: height 0.2s ease;
}

#quill-edit-comment-editor .ql-editor,
#quill-edit-project-comment-editor .ql-editor {
    min-height: 150px;
}

#quill-comment-editor .ql-editor.ql-blank::before,
#quill-project-comment-editor .ql-editor.ql-blank::before,
#quill-edit-comment-editor .ql-editor.ql-blank::before,
#quill-edit-project-comment-editor .ql-editor.ql-blank::before {
    color: #adb5bd;
    font-style: normal;
    font-size: 14px;
}

/* Estilos para imagens no editor Quill */
#quill-comment-editor .ql-editor img,
#quill-project-comment-editor .ql-editor img,
#quill-edit-comment-editor .ql-editor img,
#quill-edit-project-comment-editor .ql-editor img {
    max-width: 80% !important;
    height: auto !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    margin: 10px 0 !important;
    display: block !important;
}

/* Estilos para os botões da toolbar do Quill */
#quill-comment-editor .ql-toolbar .ql-formats,
#quill-project-comment-editor .ql-toolbar .ql-formats,
#quill-edit-comment-editor .ql-toolbar .ql-formats,
#quill-edit-project-comment-editor .ql-toolbar .ql-formats {
    margin-right: 15px;
}

#quill-comment-editor .ql-toolbar button,
#quill-project-comment-editor .ql-toolbar button,
#quill-edit-comment-editor .ql-toolbar button,
#quill-edit-project-comment-editor .ql-toolbar button {
    border-radius: 6px;
    transition: all 0.2s ease;
    margin: 0 2px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#quill-comment-editor .ql-toolbar button:hover,
#quill-project-comment-editor .ql-toolbar button:hover,
#quill-edit-comment-editor .ql-toolbar button:hover,
#quill-edit-project-comment-editor .ql-toolbar button:hover {
    background-color: #e3f2fd;
    color: #1976d2;
    transform: translateY(-1px);
}

#quill-comment-editor .ql-toolbar button.ql-active,
#quill-project-comment-editor .ql-toolbar button.ql-active,
#quill-edit-comment-editor .ql-toolbar button.ql-active,
#quill-edit-project-comment-editor .ql-toolbar button.ql-active {
    background-color: #2196f3;
    color: white;
}

#quill-comment-editor .ql-toolbar .ql-stroke,
#quill-project-comment-editor .ql-toolbar .ql-stroke,
#quill-edit-comment-editor .ql-toolbar .ql-stroke,
#quill-edit-project-comment-editor .ql-toolbar .ql-stroke {
    stroke: currentColor;
}

#quill-comment-editor .ql-toolbar .ql-fill,
#quill-project-comment-editor .ql-toolbar .ql-fill,
#quill-edit-comment-editor .ql-toolbar .ql-fill,
#quill-edit-project-comment-editor .ql-toolbar .ql-fill {
    fill: currentColor;
}
.comment-content a {
    color: #0d6efd;
    text-decoration: none;
}

.comment-content a:hover {
    color: #0a58ca;
    text-decoration: underline;
}

/* Estilos para anexos nos comentários */
.comment-attachments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.comment-attachment-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    text-decoration: none;
    animation: slideInUp 0.2s ease;
}

.comment-attachment-item:last-child {
    margin-bottom: 0;
}

.comment-attachment-item:hover {
    background: #e3f2fd;
    border-color: #90caf9;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

/* O transform do hover cria um contexto de empilhamento que prende o z-index
   do menu de ações do anexo dentro do item; sem elevar o próprio item, o card
   seguinte (Histórico da Tarefa) é pintado por cima do menu aberto. */
.comment-attachment-item:has(.dropdown-menu.show),
.comment-attachment-item:focus-within {
    position: relative;
    z-index: var(--bs-dropdown-zindex, 1000);
}

.comment-attachment-icon {
    flex-shrink: 0;
    font-size: 1.25rem;
    color: #6c757d;
}

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

.comment-attachment-name {
    font-weight: 500;
    color: #495057;
    word-break: break-all;
    overflow-wrap: break-word;
    line-height: 1.3;
    margin-bottom: 2px;
}

.comment-attachment-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Estilos para preview de arquivos antes do envio */
.comment-files-preview-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e3f2fd 100%);
    border: 1px solid #b3e5fc;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(3,169,244,0.1);
}

.comment-files-preview-header {
    color: #0277bd;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.comment-files-preview-list {
    gap: 8px;
    display: flex;
    flex-direction: column;
}

.comment-file-preview-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    animation: slideInUp 0.3s ease;
}

.comment-file-preview-item:hover {
    border-color: #64b5f6;
    box-shadow: 0 2px 8px rgba(3,169,244,0.15);
    transform: translateY(-1px);
}

.comment-file-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.comment-file-preview-icon {
    flex-shrink: 0;
    font-size: 1.4rem;
}

.comment-file-preview-info {
    flex: 1;
    min-width: 0;
}

.comment-file-preview-name {
    font-weight: 500;
    color: #495057;
    word-break: break-all;
    overflow-wrap: break-word;
    line-height: 1.3;
    margin-bottom: 2px;
}

.comment-file-preview-meta {
    font-size: 0.8rem;
    color: #0277bd;
    font-weight: 500;
}

/* Animação para elementos que aparecem */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upload-item {
    animation: slideInUp 0.3s ease;
}

/* Responsividade */
@media (max-width: 768px) {
    #commentForm,
    #projectCommentForm {
        padding: 16px;
        border-radius: 12px;
    }
    
    #commentForm .d-flex.justify-content-between,
    #projectCommentForm .d-flex.justify-content-between {
        flex-direction: column;
        gap: 12px;
    }
    
    #commentForm .btn,
    #projectCommentForm .btn {
        width: 100%;
        justify-content: center;
    }
    
    #commentForm .d-flex.align-items-center,
    #projectCommentForm .d-flex.align-items-center {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    #quill-comment-editor .ql-editor img,
    #quill-project-comment-editor .ql-editor img,
    #quill-edit-comment-editor .ql-editor img,
    #quill-edit-project-comment-editor .ql-editor img,
    .comment-content img {
        max-width: 95% !important;
    }
    
    #quill-comment-editor .ql-toolbar,
    #quill-project-comment-editor .ql-toolbar,
    #quill-edit-comment-editor .ql-toolbar,
    #quill-edit-project-comment-editor .ql-toolbar {
        padding: 8px 12px;
    }
    
    #quill-comment-editor .ql-toolbar button,
    #quill-project-comment-editor .ql-toolbar button,
    #quill-edit-comment-editor .ql-toolbar button,
    #quill-edit-project-comment-editor .ql-toolbar button {
        width: 28px;
        height: 28px;
        margin: 0 1px;
    }
}
