/**
 * Rich Text Content Styles
 *
 * Reusable styles for rendering rich text content created with TipTap editor.
 * Used in:
 * - Product descriptions
 * - Blog posts
 * - Page content
 * - Any other rich text areas
 *
 * Usage: Add class "rich-text-content" to the container element
 */

/* Base container */
.rich-text-content {
    font-size: 1rem;
    line-height: 1.6;
    color: inherit;
}

/* Reset unwanted inherited styles from theme */
.rich-text-content span,
.rich-text-content font {
    background-color: transparent;
}

/* Headings */
.rich-text-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.rich-text-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.rich-text-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.rich-text-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.rich-text-content h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.rich-text-content h6 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

/* Paragraphs */
.rich-text-content p {
    margin-bottom: 1rem;
}

/* Divs - no extra margins, just inherit */
.rich-text-content div {
    margin: 0;
    padding: 0;
}

/* Empty elements with only <br> - minimal height */
.rich-text-content p:empty,
.rich-text-content div:empty,
.rich-text-content span:empty,
.rich-text-content p:has(> br:only-child),
.rich-text-content div:has(> br:only-child),
.rich-text-content div:has(> span:only-child > br:only-child) {
    min-height: 0;
    line-height: inherit;
    margin: 0;
}

/* Lists */
.rich-text-content ul,
.rich-text-content ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.rich-text-content li {
    margin-bottom: 0.25rem;
}

/* Blockquote */
.rich-text-content blockquote {
    border-left: 4px solid var(--accent-color, #5d57f4);
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1rem;
    color: #6c757d;
    font-style: italic;
}

/* Horizontal rule */
.rich-text-content hr {
    border: none;
    border-top: 2px solid #dee2e6;
    margin: 2rem 0;
}

/* Text formatting */
.rich-text-content strong {
    font-weight: 700;
}

.rich-text-content em {
    font-style: italic;
}

.rich-text-content u {
    text-decoration: underline;
}

.rich-text-content s {
    text-decoration: line-through;
}

/* Superscript and subscript */
.rich-text-content sup {
    position: relative;
    font-size: 75%;
    line-height: 0;
    vertical-align: baseline;
    top: -0.5em;
}

.rich-text-content sub {
    position: relative;
    font-size: 75%;
    line-height: 0;
    vertical-align: baseline;
    bottom: -0.25em;
}

/* Links */
.rich-text-content a {
    color: var(--accent-color, #5d57f4);
    text-decoration: underline;
}

.rich-text-content a:hover {
    text-decoration: none;
}

/* Code */
.rich-text-content code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.rich-text-content pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.rich-text-content pre code {
    background: none;
    padding: 0;
}

/* Tables - default styles (can be overridden by inline styles) */
.rich-text-content table,
.rich-text-content .tiptap-table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    overflow: hidden;
    border: 2px solid #dee2e6;
}

.rich-text-content table td,
.rich-text-content table th,
.rich-text-content .tiptap-table td,
.rich-text-content .tiptap-table th {
    min-width: 1em;
    box-sizing: border-box;
}

/* Remove right border from last column to avoid double border with table border */
.rich-text-content table td:last-child,
.rich-text-content table th:last-child,
.rich-text-content .tiptap-table td:last-child,
.rich-text-content .tiptap-table th:last-child {
    border-right: none !important;
}

/* Remove bottom border from last row to avoid double border with table border */
.rich-text-content table tr:last-child td,
.rich-text-content .tiptap-table tr:last-child td {
    border-bottom: none !important;
}

/* Images - only max-width for responsiveness, rest comes from inline styles */
.rich-text-content img {
    max-width: 100%;
}

/* Image Alignment */
.rich-text-content img[data-align="left"] {
    margin-left: 0;
    margin-right: auto;
}

.rich-text-content img[data-align="center"] {
    margin-left: auto;
    margin-right: auto;
}

.rich-text-content img[data-align="right"] {
    margin-left: auto;
    margin-right: 0;
}

/* Image Float (text wrapping) */
.rich-text-content img[data-float="left"] {
    float: left;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
    margin-left: 0;
}

.rich-text-content img[data-float="right"] {
    float: right;
    margin-left: 1rem;
    margin-bottom: 0.5rem;
    margin-right: 0;
}

/* Clear floats */
.rich-text-content::after {
    content: "";
    display: table;
    clear: both;
}

/* Preserve inline styles - allow inline styles to override defaults */
.rich-text-content [style] {
    /* Inline styles take precedence */
}

/* First element - remove top margin */
.rich-text-content > *:first-child {
    margin-top: 0;
}

/* Last element - remove bottom margin */
.rich-text-content > *:last-child {
    margin-bottom: 0;
}
