/* ACE Modal Overlay */
.ace-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 99998;
    justify-content: center;
    align-items: center;
}

/* ACE Modal Window */
.ace-modal {
    background: #2e3440; /* Nord theme color */
    color: #d8dee9;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
}

.ace-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #4c566a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ace-modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.ace-modal-close {
    background: none;
    border: none;
    color: #d8dee9;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.ace-modal-body {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Toolbar */
.ace-toolbar {
    background: #3b4252;
    padding: 8px;
    border-radius: 5px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ace-toolbar button {
    background: #4c566a;
    border: 1px solid #5e81ac;
    color: #eceff4;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.ace-toolbar button:hover {
    background: #5e81ac;
}

.ace-toolbar button.active {
    background: #88c0d0;
    color: #2e3440;
}

.ace-toolbar .ace-separator {
    width: 1px;
    height: 20px;
    background: #4c566a;
    margin: 0 5px;
}
.ace-toolbar .ace-ai-btn {
    margin-left: auto;
    background-color: #a3be8c;
    border-color: #a3be8c;
    color: #2e3440;
}
.ace-toolbar .ace-ai-btn:hover {
    background-color: #b48ead;
    border-color: #b48ead;
}


/* Content Area */
.ace-editor-content {
    flex-grow: 1;
    width: 100%;
    background: #3b4252;
    border: 1px solid #4c566a;
    border-radius: 5px;
    padding: 10px;
    min-height: 200px;
    font-family: monospace;
    color: #eceff4;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
}
#ace-editor-textarea {
    resize: vertical;
}

/* Attachments Area */
#ace-attachments-area {
    margin-top: 15px;
}
#ace-attachments-area h6 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #88c0d0;
}
#ace-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ace-attachment-item {
    position: relative;
    width: 80px;
    height: 80px;
    background: #3b4252;
    border: 1px solid #4c566a;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.ace-attachment-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ace-attachment-item .ace-file-info {
    text-align: center;
    font-size: 12px;
    padding: 5px;
    word-break: break-all;
}
.ace-attachment-item .ace-file-info i {
    font-size: 24px;
    margin-bottom: 5px;
}


.ace-attachment-remove {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #bf616a;
    color: #eceff4;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}


/* Modal Footer */
.ace-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #4c566a;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ace-modal-footer button {
    padding: 8px 16px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
}

.ace-cancel-button {
    background: #4c566a;
    color: #eceff4;
}
.ace-save-button {
    background: #5e81ac;
    color: #eceff4;
}

/* AI Prompt Overlay */
#ace-ai-prompt-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(46, 52, 64, 0.9);
    z-index: 10;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
}

#ace-ai-prompt-modal {
    background: #3b4252;
    padding: 20px;
    border-radius: 6px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}

#ace-ai-prompt-modal h4 { margin-top: 0;}
#ace-ai-prompt-modal p { font-size: 14px; color: #d8dee9; }

#ace-ai-prompt-input {
    width: 100%;
    height: 80px;
    background: #4c566a;
    border: 1px solid #5e81ac;
    color: #eceff4;
    border-radius: 4px;
    padding: 8px;
    resize: vertical;
    margin-top: 10px;
}

.ace-ai-prompt-actions {
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ace-ai-prompt-actions button {
    padding: 8px 16px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
}
#ace-ai-prompt-cancel { background: #4c566a; color: #eceff4; }
#ace-ai-prompt-ok { background: #a3be8c; color: #2e3440; }

/* Styles for tables inside the editor */
.ace-editor-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.ace-editor-content th,
.ace-editor-content td {
    border: 1px solid #4c566a;
    padding: 8px;
    text-align: left;
}

.ace-editor-content th {
    background-color: #3b4252;
}