/**
 * CKEditor Content Styling
 * Reusable CSS for frontend rich content rendering
 * 
 * Usage: Add class="ckeditor-content" to any content container with CKEditor output
 * Example: <div class="ckeditor-content">{!! $content !!}</div>
 */

/* Base Styles */
.ckeditor-content {
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.ckeditor-content * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Typography */
.ckeditor-content h1,
.ckeditor-content h2,
.ckeditor-content h3,
.ckeditor-content h4,
.ckeditor-content h5,
.ckeditor-content h6 {
    font-weight: 700;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ckeditor-content h1 { font-size: 2rem; }
.ckeditor-content h2 { font-size: 1.5rem; }
.ckeditor-content h3 { font-size: 1.25rem; }
.ckeditor-content h4 { font-size: 1.125rem; }
.ckeditor-content h5 { font-size: 1rem; }
.ckeditor-content h6 { font-size: 0.875rem; }

/* Paragraphs */
.ckeditor-content p {
    margin-bottom: 0.50rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Text Formatting */
.ckeditor-content strong,
.ckeditor-content b {
    font-weight: 700;
}

.ckeditor-content em,
.ckeditor-content i {
    font-style: italic;
}

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

/* Lists */
.ckeditor-content ul,
.ckeditor-content ol {
    margin-bottom: 0.5rem;
}

.ckeditor-content li {
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ckeditor-content ul {
    list-style-type: disc;
}

.ckeditor-content ol {
    list-style-type: decimal;
}

/* List alignment support */
.ckeditor-content ul,
.ckeditor-content ol {
    list-style-position: inside;
}

/* Links */
.ckeditor-content a {
    color: #4f46e5;
    text-decoration: underline;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ckeditor-content a:hover {
    color: #4338ca;
}

/* Tables */
.ckeditor-content table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    empty-cells: show;
}

.ckeditor-content table th,
.ckeditor-content table td {
    border: 1px solid #e2e8f0;
    padding: 0.75rem;
    text-align: left;
    vertical-align: top;
    width: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    height: auto;
    min-height: 1rem;
}

.ckeditor-content table th {
    font-weight: 700;
    border-bottom: 2px solid #e2e8f0;
    background-color: transparent;
}

.ckeditor-content table td {
    background-color: transparent;
}

/* Images */
.ckeditor-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem 0;
}

.ckeditor-content figure {
    max-width: 100%;
    margin: 0.5rem 0;
}

.ckeditor-content figure img {
    margin: 0;
}

.ckeditor-content figcaption {
    font-size: 0.875rem;
    color: #64748b;
    text-align: center;
    margin-top: 0.5rem;
}

/* Blockquotes */
.ckeditor-content blockquote {
    border-left: 4px solid #4f46e5;
    padding: 1rem 1.5rem;
    margin: 1rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
    font-style: italic;
    position: relative;
}

.ckeditor-content blockquote::before {
    content: "\201C";
    font-size: 2rem;
    color: #4f46e5;
    position: absolute;
    left: 0.5rem;
    top: -0.5rem;
    font-family: Georgia, serif;
    line-height: 1;
}

.ckeditor-content blockquote p {
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

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

/* Pre/Code */
.ckeditor-content pre,
.ckeditor-content code {
    background-color: #f8fafc;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: monospace;
    font-size: 0.875rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.ckeditor-content pre {
    display: block;
    padding: 1rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ckeditor-content code {
    display: inline;
    white-space: normal;
}

.ckeditor-content pre code {
    display: block;
    padding: 0;
    background: none;
}

/* Horizontal Rule */
.ckeditor-content hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 1.5rem 0;
}

/* Divs and Spans */
.ckeditor-content div {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ckeditor-content span {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Override inline font-size from CKEditor */
.ckeditor-content span[style*="font-size"],
.ckeditor-content div[style*="font-size"],
.ckeditor-content p[style*="font-size"] {
    font-size: unset !important;
    line-height: unset !important;
}

/* Iframes and Embedded Content */
.ckeditor-content iframe {
    max-width: 100%;
    width: 100%;
    border: none;
}

.ckeditor-content video,
.ckeditor-content embed {
    max-width: 100%;
    height: auto;
}

/* Responsive adjustments for mobile */
@media (max-width: 640px) {
    .ckeditor-content table th,
    .ckeditor-content table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .ckeditor-content h1 { font-size: 1.5rem; }
    .ckeditor-content h2 { font-size: 1.25rem; }
    .ckeditor-content h3 { font-size: 1.125rem; }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ckeditor-content table th,
    .ckeditor-content table td {
        border-color: #475569;
    }

    .ckeditor-content table th {
        border-bottom-color: #64748b;
    }

    .ckeditor-content blockquote {
        border-left-color: #818cf8;
    }

    .ckeditor-content blockquote::before {
        color: #818cf8;
    }

    .ckeditor-content pre,
    .ckeditor-content code {
        background-color: #1e293b;
    }

    .ckeditor-content hr {
        border-color: #475569;
    }
}

/* Tailwind Dark Mode Compatibility */
.dark .ckeditor-content h1,
.dark .ckeditor-content h2,
.dark .ckeditor-content h3,
.dark .ckeditor-content h4,
.dark .ckeditor-content h5,
.dark .ckeditor-content h6 {
    color: #f1f5f9;
}

.dark .ckeditor-content p,
.dark .ckeditor-content li,
.dark .ckeditor-content td {
    color: #cbd5e1;
}

.dark .ckeditor-content a {
    color: #818cf8;
}

.dark .ckeditor-content a:hover {
    color: #a5b4fc;
}