﻿/* ========================================
   SUMMERNOTE EDITOR FIXES
   ======================================== */

/* Reset any conflicting global styles for Summernote */
.note-editor,
.note-editor *,
.note-toolbar,
.note-toolbar *,
.note-editable,
.note-editable * {
    box-sizing: border-box;
}

/* Ensure Summernote has proper z-index */
.note-editor {
    position: relative;
    z-index: 10;
}

/* Fix the main editor container */
.discussionTaskThreadNewMessage.note-editor,
.chat-message .note-editor {
    border: 1px solid rgba(76, 175, 80, 0.3); /* Fallback color */
    border: 1px solid rgba(var(--primary-rgb, 76, 175, 80), 0.3);
    border-radius: 0.75rem;
    overflow: hidden;
    margin: 0; /* Remove problematic negative margin */
    background: white;
    font-family: inherit;
}

/* Toolbar styling with fallbacks */
.discussionTaskThreadNewMessage .note-toolbar,
.chat-message .note-toolbar {
    background: rgba(76, 175, 80, 0.05); /* Fallback */
    background: rgba(var(--primary-rgb, 76, 175, 80), 0.05);
    border-bottom: 1px solid rgba(76, 175, 80, 0.2); /* Fallback */
    border-bottom: 1px solid rgba(var(--primary-rgb, 76, 175, 80), 0.2);
    padding: 0.5rem;
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

/* Fix toolbar button styling - this is crucial for proper display */
.discussionTaskThreadNewMessage .note-btn,
.chat-message .note-btn {
    display: inline-block !important;
    padding: 0.375rem 0.5rem !important;
    margin: 0 0.125rem !important;
    border: 1px solid transparent !important;
    border-radius: 0.25rem !important;
    background: transparent !important;
    color: #374151 !important; /* Fallback */
    color: var(--text-primary, #374151) !important;
    font-size: 0.875rem !important;
    line-height: 1.25 !important;
    text-align: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    min-width: 2rem !important;
    min-height: 2rem !important;
    vertical-align: middle !important;
}

    .discussionTaskThreadNewMessage .note-btn:hover,
    .chat-message .note-btn:hover {
        background: rgba(76, 175, 80, 0.1) !important; /* Fallback */
        background: rgba(var(--primary-rgb, 76, 175, 80), 0.1) !important;
        color: #2e7d32 !important; /* Fallback */
        color: var(--primary-dark, #2e7d32) !important;
        border-color: rgba(76, 175, 80, 0.2) !important; /* Fallback */
        border-color: rgba(var(--primary-rgb, 76, 175, 80), 0.2) !important;
    }

    .discussionTaskThreadNewMessage .note-btn.active,
    .chat-message .note-btn.active,
    .discussionTaskThreadNewMessage .note-btn:active,
    .chat-message .note-btn:active {
        background: #4caf50 !important; /* Fallback */
        background: var(--primary, #4caf50) !important;
        color: white !important;
        border-color: #4caf50 !important; /* Fallback */
        border-color: var(--primary, #4caf50) !important;
    }

    /* Fix button icons - ensure they display properly */
    .discussionTaskThreadNewMessage .note-btn i,
    .chat-message .note-btn i,
    .discussionTaskThreadNewMessage .note-btn .fa,
    .chat-message .note-btn .fa {
        font-size: 0.875rem !important;
        line-height: 1 !important;
        display: inline-block !important;
        width: auto !important;
        height: auto !important;
    }

    /* Dropdown button styling */
    .discussionTaskThreadNewMessage .note-btn.dropdown-toggle,
    .chat-message .note-btn.dropdown-toggle {
        padding-right: 1.25rem !important;
    }

        .discussionTaskThreadNewMessage .note-btn.dropdown-toggle::after,
        .chat-message .note-btn.dropdown-toggle::after {
            content: "▼" !important;
            margin-left: 0.25rem !important;
            font-size: 0.75rem !important;
        }

/* Editable area styling */
.discussionTaskThreadNewMessage .note-editable,
.chat-message .note-editable {
    background: white !important;
    color: #374151 !important; /* Fallback */
    color: var(--text-body, #374151) !important;
    padding: 1rem !important;
    min-height: 120px !important;
    font-size: 1rem !important;
    line-height: 1.5 !important;
    border: none !important;
    outline: none !important;
    font-family: inherit !important;
}

    .discussionTaskThreadNewMessage .note-editable:focus,
    .chat-message .note-editable:focus {
        outline: none !important;
        box-shadow: inset 0 0 0 2px rgba(76, 175, 80, 0.2) !important; /* Fallback */
        box-shadow: inset 0 0 0 2px rgba(var(--primary-rgb, 76, 175, 80), 0.2) !important;
    }

/* Dropdown menu styling */
.discussionTaskThreadNewMessage .note-dropdown-menu,
.chat-message .note-dropdown-menu {
    background: white !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    padding: 0.5rem 0 !important;
    margin: 0.25rem 0 0 0 !important;
    z-index: 1000 !important;
}

.discussionTaskThreadNewMessage .note-dropdown-item,
.chat-message .note-dropdown-item {
    padding: 0.5rem 1rem !important;
    color: #374151 !important;
    cursor: pointer !important;
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    text-align: left !important;
    font-size: 0.875rem !important;
    line-height: 1.25 !important;
}

    .discussionTaskThreadNewMessage .note-dropdown-item:hover,
    .chat-message .note-dropdown-item:hover {
        background: #f3f4f6 !important;
        color: #374151 !important;
    }

/* Button group styling */
.discussionTaskThreadNewMessage .note-btn-group,
.chat-message .note-btn-group {
    display: inline-flex !important;
    align-items: center !important;
    margin-right: 0.5rem !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 0.375rem !important;
    overflow: hidden !important;
}

    .discussionTaskThreadNewMessage .note-btn-group .note-btn,
    .chat-message .note-btn-group .note-btn {
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        border-right: 1px solid #e5e7eb !important;
    }

        .discussionTaskThreadNewMessage .note-btn-group .note-btn:last-child,
        .chat-message .note-btn-group .note-btn:last-child {
            border-right: none !important;
        }

/* Color palette styling */
.discussionTaskThreadNewMessage .note-color-palette,
.chat-message .note-color-palette {
    padding: 0.5rem !important;
    background: white !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.discussionTaskThreadNewMessage .note-color-row,
.chat-message .note-color-row {
    display: flex !important;
    gap: 0.25rem !important;
    margin-bottom: 0.25rem !important;
}

.discussionTaskThreadNewMessage .note-color-btn,
.chat-message .note-color-btn {
    width: 1.5rem !important;
    height: 1.5rem !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 0.25rem !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

    .discussionTaskThreadNewMessage .note-color-btn:hover,
    .chat-message .note-color-btn:hover {
        transform: scale(1.1) !important;
        border-color: #374151 !important;
    }

/* Status bar styling */
.discussionTaskThreadNewMessage .note-statusbar,
.chat-message .note-statusbar {
    background: #f9fafb !important;
    border-top: 1px solid #e5e7eb !important;
    padding: 0.375rem 0.75rem !important;
    font-size: 0.75rem !important;
    color: #6b7280 !important;
    text-align: right !important;
}

/* Handle resizing */
.discussionTaskThreadNewMessage .note-resizebar,
.chat-message .note-resizebar {
    background: #e5e7eb !important;
    height: 8px !important;
    cursor: ns-resize !important;
    border-bottom-left-radius: 0.75rem !important;
    border-bottom-right-radius: 0.75rem !important;
}

    .discussionTaskThreadNewMessage .note-resizebar:hover,
    .chat-message .note-resizebar:hover {
        background: #4caf50 !important; /* Fallback */
        background: var(--primary, #4caf50) !important;
    }

/* Modal and popover fixes */
.discussionTaskThreadNewMessage .note-modal,
.chat-message .note-modal {
    z-index: 2000 !important;
}

.discussionTaskThreadNewMessage .note-popover,
.chat-message .note-popover {
    z-index: 1500 !important;
}

/* Ensure proper font loading for icons */
.note-editor .note-btn i[class*="fa-"]::before,
.note-editor .note-btn .fa::before {
    font-family: "Font Awesome 5 Free", "FontAwesome", sans-serif !important;
    font-weight: 900 !important;
    font-style: normal !important;
}

/* ========================================
   RESPONSIVE FIXES FOR SUMMERNOTE
   ======================================== */

@media (max-width: 768px) {
    .discussionTaskThreadNewMessage .note-toolbar,
    .chat-message .note-toolbar {
        padding: 0.375rem;
        flex-wrap: wrap;
    }

    .discussionTaskThreadNewMessage .note-btn,
    .chat-message .note-btn {
        min-width: 1.75rem !important;
        min-height: 1.75rem !important;
        padding: 0.25rem 0.375rem !important;
        font-size: 0.8125rem !important;
    }

    .discussionTaskThreadNewMessage .note-editable,
    .chat-message .note-editable {
        min-height: 100px !important;
        padding: 0.75rem !important;
    }

    .discussionTaskThreadNewMessage .note-btn-group,
    .chat-message .note-btn-group {
        margin-right: 0.25rem !important;
        margin-bottom: 0.25rem !important;
    }
}

/* ========================================
   THEME INTEGRATION FIXES
   ======================================== */

/* Nature theme */
body.theme-nature .discussionTaskThreadNewMessage.note-editor,
body.theme-nature .chat-message .note-editor {
    border-color: rgba(76, 175, 80, 0.3);
}

body.theme-nature .discussionTaskThreadNewMessage .note-toolbar,
body.theme-nature .chat-message .note-toolbar {
    background: rgba(76, 175, 80, 0.05);
    border-bottom-color: rgba(76, 175, 80, 0.2);
}

body.theme-nature .discussionTaskThreadNewMessage .note-btn.active,
body.theme-nature .chat-message .note-btn.active {
    background: #4caf50 !important;
    border-color: #4caf50 !important;
}

/* Sky theme */
body.theme-sky .discussionTaskThreadNewMessage.note-editor,
body.theme-sky .chat-message .note-editor {
    border-color: rgba(33, 150, 243, 0.3);
}

body.theme-sky .discussionTaskThreadNewMessage .note-toolbar,
body.theme-sky .chat-message .note-toolbar {
    background: rgba(33, 150, 243, 0.05);
    border-bottom-color: rgba(33, 150, 243, 0.2);
}

body.theme-sky .discussionTaskThreadNewMessage .note-btn.active,
body.theme-sky .chat-message .note-btn.active {
    background: #2196f3 !important;
    border-color: #2196f3 !important;
}

/* Sunset theme */
body.theme-sunset .discussionTaskThreadNewMessage.note-editor,
body.theme-sunset .chat-message .note-editor {
    border-color: rgba(255, 112, 67, 0.3);
}

body.theme-sunset .discussionTaskThreadNewMessage .note-toolbar,
body.theme-sunset .chat-message .note-toolbar {
    background: rgba(255, 112, 67, 0.05);
    border-bottom-color: rgba(255, 112, 67, 0.2);
}

body.theme-sunset .discussionTaskThreadNewMessage .note-btn.active,
body.theme-sunset .chat-message .note-btn.active {
    background: #ff7043 !important;
    border-color: #ff7043 !important;
}

/* Mystical theme */
body.theme-mystical .discussionTaskThreadNewMessage.note-editor,
body.theme-mystical .chat-message .note-editor {
    border-color: rgba(126, 87, 194, 0.3);
}

body.theme-mystical .discussionTaskThreadNewMessage .note-toolbar,
body.theme-mystical .chat-message .note-toolbar {
    background: rgba(126, 87, 194, 0.05);
    border-bottom-color: rgba(126, 87, 194, 0.2);
}

body.theme-mystical .discussionTaskThreadNewMessage .note-btn.active,
body.theme-mystical .chat-message .note-btn.active {
    background: #7e57c2 !important;
    border-color: #7e57c2 !important;
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

.discussionTaskThreadNewMessage .note-btn:focus,
.chat-message .note-btn:focus {
    outline: 2px solid rgba(76, 175, 80, 0.5) !important;
    outline: 2px solid rgba(var(--primary-rgb, 76, 175, 80), 0.5) !important;
    outline-offset: 2px !important;
    z-index: 10 !important;
}

.discussionTaskThreadNewMessage .note-editable:focus,
.chat-message .note-editable:focus {
    outline: none !important;
}

/* Screen reader support */
.discussionTaskThreadNewMessage .note-btn[aria-label],
.chat-message .note-btn[aria-label] {
    position: relative;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .discussionTaskThreadNewMessage .note-editor,
    .chat-message .note-editor {
        border: 2px solid #333 !important;
    }

    .discussionTaskThreadNewMessage .note-toolbar,
    .chat-message .note-toolbar {
        background: #f5f5f5 !important;
        border-bottom: 2px solid #333 !important;
    }

    .discussionTaskThreadNewMessage .note-btn,
    .chat-message .note-btn {
        border: 1px solid #333 !important;
        background: white !important;
        color: #333 !important;
    }

        .discussionTaskThreadNewMessage .note-btn:hover,
        .chat-message .note-btn:hover {
            background: #333 !important;
            color: white !important;
        }

        .discussionTaskThreadNewMessage .note-btn.active,
        .chat-message .note-btn.active {
            background: #333 !important;
            color: white !important;
            border-color: #333 !important;
        }
}
