/**
 * TipTap Content Styles for Frontend
 * Lightweight CSS for rendering TipTap editor content consistently
 */

.tiptap-content {
    color: inherit;
}

.tiptap-content > * + * {
    margin-block-start: 1rem;
}

/* Headings - use !important to override site-specific styles */
.tiptap-content h1,
.tiptap-content h2,
.tiptap-content h3,
.tiptap-content h4,
.tiptap-content h5,
.tiptap-content h6 {
    font-weight: 700 !important;
    line-height: 1.25;
}

.tiptap-content h1 {
    font-size: 1.75rem !important;
    line-height: 1.1;
}

.tiptap-content h2 {
    font-size: 1.5rem !important;
    line-height: 1.1;
}

.tiptap-content h3 {
    font-size: 1.25rem !important;
    line-height: 1.25;
}

.tiptap-content h4 {
    font-size: 1.125rem !important;
}

.tiptap-content h5 {
    font-size: 1rem !important;
}

.tiptap-content h6 {
    font-size: 0.875rem !important;
}

/* Lead text and small */
.tiptap-content .lead,
.tiptap-content .lead p,
.tiptap-content .lead span {
    font-size: 1.375rem !important;
    line-height: 1 !important;
}

.tiptap-content small,
.tiptap-content small p {
    font-size: 0.75rem !important;
}

/* Text alignment - use !important to override paragraph reset */
.tiptap-content [style*="text-align: center"],
.tiptap-content [style*="text-align:center"],
.tiptap-content .text-center {
    text-align: center !important;
}

.tiptap-content [style*="text-align: right"],
.tiptap-content [style*="text-align:right"],
.tiptap-content [style*="text-align: end"],
.tiptap-content [style*="text-align:end"],
.tiptap-content .text-right {
    text-align: right !important;
}

.tiptap-content [style*="text-align: left"],
.tiptap-content [style*="text-align:left"],
.tiptap-content [style*="text-align: start"],
.tiptap-content [style*="text-align:start"],
.tiptap-content .text-left {
    text-align: left !important;
}

.tiptap-content [style*="text-align: justify"],
.tiptap-content [style*="text-align:justify"],
.tiptap-content .text-justify {
    text-align: justify !important;
}

/* Paragraphs - reset site-specific paragraph styles */
.tiptap-content p {
    margin-bottom: 1rem;
    font-size: inherit !important;
    color: inherit !important;
    text-align: inherit !important;
}

.tiptap-content p:last-child {
    margin-bottom: 0;
}

/* Lists */
.tiptap-content ol,
.tiptap-content ul {
    padding-inline-start: 1rem;
    margin-inline-start: 1rem;
    margin-bottom: 1rem;
}

.tiptap-content ul {
    list-style: disc;
}

.tiptap-content ol {
    list-style: decimal;
}

.tiptap-content li {
    margin-bottom: 0.25rem;
}

.tiptap-content li p {
    margin-bottom: 0.25rem;
}

.tiptap-content li > ol,
.tiptap-content li > ul {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

/* Nested lists */
.tiptap-content ul ul {
    list-style: circle;
}

.tiptap-content ul ul ul {
    list-style: square;
}

/* Blockquote */
.tiptap-content blockquote {
    border-left: 0.25rem solid #9ca3af;
    padding-inline-start: 0.5rem;
    margin-inline-start: 1rem;
    font-size: 1.25rem;
    font-style: italic;
}

/* Links */
.tiptap-content a {
    color: #2563eb;
    text-decoration: underline;
}

.tiptap-content a:hover {
    color: #1d4ed8;
}

/* Tables */
.tiptap-content table {
    border-collapse: collapse;
    display: table !important;
    width: 100%;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.tiptap-content table td,
.tiptap-content table th {
    border: 1px solid #9ca3af;
    padding: 3px 5px;
    vertical-align: top;
    min-width: 1em;
    position: relative;
}

.tiptap-content table th {
    background-color: #e5e7eb;
    font-weight: 700;
}

.tiptap-content table .selectedCell:after {
    background: rgba(200, 200, 255, 0.4);
    content: "";
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
    position: absolute;
    z-index: 2;
}

.tiptap-content table .column-resize-handle {
    background-color: #adf;
    bottom: -2px;
    position: absolute;
    right: -2px;
    pointer-events: none;
    top: 0;
    width: 4px;
}

/* Code */
.tiptap-content code {
    background-color: #d1d5db;
    border-radius: 0.25rem;
    padding-inline: 0.25rem;
    font-family: monospace;
}

.tiptap-content pre {
    padding: 0.75rem 1rem;
    border-radius: 0.25rem;
    background-color: #1f2937;
    color: #d6deeb;
    overflow-x: auto;
}

.tiptap-content pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
}

/* Horizontal rule */
.tiptap-content hr {
    border: none;
    border-top: 2px solid #e5e7eb;
    margin: 2rem 0;
}

/* Images */
.tiptap-content img {
    display: inline-block;
    max-width: 100%;
    height: auto;
}

/* Text formatting - bold, italic, underline, strike */
.tiptap-content strong {
    font-weight: 700;
}

.tiptap-content em {
    font-style: italic;
}

.tiptap-content u {
    text-decoration: underline;
}

.tiptap-content s {
    text-decoration: line-through;
}

/* Subscript and superscript */
.tiptap-content sub {
    font-size: 0.75em;
    vertical-align: sub;
}

.tiptap-content sup {
    font-size: 0.75em;
    vertical-align: super;
}

/* Highlight/mark */
.tiptap-content mark {
    background-color: #fef08a;
    padding: 0 0.125rem;
}

/* Inline color styles (for font colors set in editor) */
.tiptap-content [style*="color:"] {
    /* Allow inline color styles to work */
}

/* Inline font-size styles (for font sizes set in editor) */
.tiptap-content [style*="font-size:"] {
    /* Allow inline font-size styles to work */
}
