/* Rich text editor (Components/Shared/RichTextEditor.razor) and read-only rich text blocks. */

.rte {
    position: relative;
    border: 2px solid var(--company-border-light, #e5e7eb);
    border-radius: var(--company-radius-lg, 0.75rem);
    background: var(--company-bg-primary, #ffffff);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rte:focus-within {
    border-color: var(--company-primary-500, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.rte-toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.4rem;
    padding: 0.45rem 0.5rem;
    background: var(--company-bg-secondary, #f9fafb);
    border-bottom: 1px solid var(--company-border-light, #e5e7eb);
    border-radius: calc(var(--company-radius-lg, 0.75rem) - 2px) calc(var(--company-radius-lg, 0.75rem) - 2px) 0 0;
}

.rte-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
    padding-inline-end: 0.4rem;
    border-inline-end: 1px solid var(--company-border-light, #e5e7eb);
}

.rte-group:last-child {
    border-inline-end: 0;
    padding-inline-end: 0;
}

.rte-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 32px;
    height: 32px;
    padding: 0 0.4rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--company-text-secondary, #4b5563);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.rte-btn:hover,
.rte-btn.active {
    background: var(--company-primary-50, #eff6ff);
    color: var(--company-primary-600, #2563eb);
    border-color: var(--company-primary-100, #dbeafe);
}

.rte-btn-text {
    font-weight: 600;
    font-size: 0.8rem;
}

.rte-select {
    height: 32px;
    max-width: 128px;
    padding: 0 0.35rem;
    border: 1px solid var(--company-border-light, #e5e7eb);
    border-radius: 6px;
    background: var(--company-bg-primary, #ffffff);
    color: var(--company-text-primary, #1f2937);
    font-size: 0.8rem;
}

.rte-color {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0;
    border-radius: 6px;
    color: var(--company-text-secondary, #4b5563);
    cursor: pointer;
}

.rte-color:hover {
    background: var(--company-primary-50, #eff6ff);
}

.rte-color i {
    font-size: 0.8rem;
    line-height: 1;
}

.rte-swatch {
    width: 18px;
    height: 4px;
    margin-top: 3px;
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.rte-color input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}

.rte-content {
    min-height: var(--rte-min-height, 180px);
    max-height: 70vh;
    overflow: auto;
    padding: 0.9rem 1rem;
    outline: none;
    color: var(--company-text-primary, #1f2937);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.rte-content:empty::before {
    content: attr(data-placeholder);
    color: var(--company-text-tertiary, #9ca3af);
    pointer-events: none;
}

/* Table tools panel: docked between toolbar and content, so it pushes the text down
   instead of floating over (and being covered by) the next editor on the page. */
.rte-table-panel {
    padding: 0.75rem 0.9rem 0.9rem;
    background: var(--company-bg-primary, #ffffff);
    border-bottom: 1px solid var(--company-border-light, #e5e7eb);
    box-shadow: inset 0 3px 0 var(--company-primary-100, #dbeafe);
}

.rte-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--company-text-primary, #1f2937);
}

.rte-panel-head i.fa-table {
    margin-inline-end: 0.35rem;
    color: var(--company-primary-600, #2563eb);
}

.rte-panel-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 1rem 1.5rem;
}

.rte-panel-col + .rte-panel-col {
    padding-inline-start: 1.5rem;
    border-inline-start: 1px solid var(--company-border-light, #e5e7eb);
}

.rte-menu-title {
    margin: 0 0 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--company-text-secondary, #6b7280);
}

.rte-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    align-items: end;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.rte-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--company-text-secondary, #6b7280);
}

.rte-field .rte-select {
    max-width: none;
    width: 100%;
}

.rte-field input[type="color"] {
    width: 100%;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--company-border-light, #e5e7eb);
    border-radius: 6px;
    background: var(--company-bg-primary, #ffffff);
    cursor: pointer;
}

.rte-check {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 32px;
    margin: 0;
    font-size: 0.8rem;
    color: var(--company-text-primary, #1f2937);
    cursor: pointer;
}

.rte-menu-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.6rem;
}

.rte-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--company-border-light, #e5e7eb);
    border-radius: 6px;
    background: var(--company-bg-primary, #ffffff);
    color: var(--company-text-primary, #1f2937);
    font-size: 0.78rem;
    cursor: pointer;
    text-align: start;
}

.rte-chip:hover {
    border-color: var(--company-primary-500, #3b82f6);
    color: var(--company-primary-600, #2563eb);
}

.rte-chip.danger:hover {
    border-color: var(--company-danger-500, #ef4444);
    color: var(--company-danger-600, #dc2626);
}

.rte-menu-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.45rem 0.75rem;
    border: 0;
    border-radius: 6px;
    background: var(--company-primary-600, #2563eb);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.rte-menu-hint {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--company-text-tertiary, #9ca3af);
}

.rte-menu-hint.warn {
    color: var(--company-danger-600, #dc2626);
}

/* Content styles shared by the editor and read-only views */
.rte-content table,
.rich-text-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
}

.rte-content td,
.rte-content th,
.rich-text-content td,
.rich-text-content th {
    border: 1px solid #9ca3af;
    padding: 6px 10px;
    min-width: 40px;
    vertical-align: middle;
}

.rte-content ul,
.rte-content ol,
.rich-text-content ul,
.rich-text-content ol {
    margin: 0.35rem 0;
    padding-inline-start: 1.6rem;
}

.rte-content p,
.rich-text-content p {
    margin: 0 0 0.5rem;
}

.rte-content h1, .rich-text-content h1 { font-size: 1.5rem; font-weight: 700; margin: 0.6rem 0 0.4rem; }
.rte-content h2, .rich-text-content h2 { font-size: 1.25rem; font-weight: 700; margin: 0.6rem 0 0.4rem; }
.rte-content h3, .rich-text-content h3 { font-size: 1.1rem; font-weight: 700; margin: 0.5rem 0 0.35rem; }

.rte-content blockquote,
.rich-text-content blockquote {
    margin: 0.5rem 0;
    padding: 0.25rem 0.9rem;
    border-inline-start: 4px solid #cbd5e1;
    color: #475569;
}

.rich-text-content {
    overflow-x: auto;
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (max-width: 860px) {
    .rte-panel-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .rte-panel-col + .rte-panel-col {
        padding-inline-start: 0;
        padding-top: 0.9rem;
        border-inline-start: 0;
        border-top: 1px solid var(--company-border-light, #e5e7eb);
    }
}

@media (max-width: 576px) {

    .rte-select {
        max-width: 108px;
    }
}
