/*
 * Custom Trix editor styles with dark mode support
 * Drop this file into app/assets/stylesheets/trix.css
 * and make sure actiontext.css does NOT import trix/dist/trix
 */

/* === Editor === */
trix-editor {
    border: 1px solid #bbb;
    border-radius: 3px;
    margin: 0;
    padding: 0.75rem 1rem;
    /* more padding for comfort */
    min-height: 20em;
    /* ≈ 320px */
    outline: none;
    background-color: #ffffff;
    color: #111827;
    /* gray-900 */
}

.dark trix-editor {
    background-color: #374151;
    /* gray-700 */
    border-color: #4b5563;
    /* gray-600 */
    color: #f9fafb;
    /* white */
}


/* === Toolbar === */
trix-toolbar * {
    box-sizing: border-box;
}

trix-toolbar {
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.25rem;
}

.dark trix-toolbar {
    background: #1f2937;
    /* gray-800 */
    border-color: #4b5563;
}

/* === Button row === */
trix-toolbar .trix-button-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    overflow-x: auto;
}

/* === Button groups === */
trix-toolbar .trix-button-group {
    display: flex;
    margin-bottom: 10px;
    border: 1px solid #bbb;
    border-radius: 3px;
}

trix-toolbar .trix-button-group:not(:first-child) {
    margin-left: 1.5vw;
}

@media (max-width: 768px) {
    trix-toolbar .trix-button-group:not(:first-child) {
        margin-left: 0;
    }
}

/* === Buttons === */
trix-toolbar .trix-button {
    position: relative;
    float: left;
    color: #374151;
    /* gray-700 */
    font-size: 0.75em;
    font-weight: 500;
    white-space: nowrap;
    padding: 0 0.5em;
    margin: 0;
    outline: none;
    border: none;
    border-radius: 0;
    background: transparent;
    transition: background 0.2s, color 0.2s;
}

trix-toolbar .trix-button:not(:first-child) {
    border-left: 1px solid #ccc;
}

trix-toolbar .trix-button.trix-active {
    background: #2563eb;
    /* blue-600 */
    color: #ffffff;
    font-weight: 600;
}

trix-toolbar .trix-button:not(:disabled) {
    cursor: pointer;
}

trix-toolbar .trix-button:disabled {
    color: rgba(107, 114, 128, 0.4);
    /* gray-500/40 */
}

/* Dark mode buttons */
.dark trix-toolbar .trix-button {
    color: #f9fafb;
    /* white */
}

.dark trix-toolbar .trix-button.trix-active {
    background: #3b82f6;
    /* blue-500 */
    color: #ffffff;
}

/* === Icon buttons === */
trix-toolbar .trix-button--icon::before {
    opacity: 0.7;
    filter: invert(0%) brightness(0%);
    /* black in light */
}

.dark trix-toolbar .trix-button--icon::before {
    filter: invert(100%) brightness(200%);
    /* white in dark */
    opacity: 0.9;
}

/* === Dialogs === */
trix-toolbar .trix-dialog {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.5rem;
    color: #111827;
}

.dark trix-toolbar .trix-dialog {
    background: #1f2937;
    /* gray-800 */
    border-color: #4b5563;
    color: #f9fafb;
}

.dark trix-toolbar .trix-input--dialog {
    background-color: #374151;
    /* gray-700 */
    color: #f9fafb;
    border: 1px solid #4b5563;
}

/* === Content === */
.trix-content {
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;
}

.trix-content h1 {
    font-size: 1.25em;
    font-weight: bold;
}

.trix-content blockquote {
    border-left: 3px solid #d1d5db;
    padding-left: 0.75em;
    margin-left: 0.75em;
    color: #4b5563;
}

.dark .trix-content blockquote {
    border-left-color: #6b7280;
    /* gray-500 */
    color: #d1d5db;
}

.trix-content pre {
    background-color: #f3f4f6;
    /* gray-100 */
    padding: 0.5rem;
    border-radius: 0.375rem;
}

.dark .trix-content pre {
    background-color: #1f2937;
    /* gray-800 */
    color: #f9fafb;
}