/* ========================================
   CKEditor Content Styling
   ========================================
   This CSS file handles all CKEditor formatted content
   to ensure proper display of images, text, and layouts
   ======================================== */

.ckeditor-content {
    line-height: 1.8;
    overflow: auto;
    word-wrap: break-word;
}

/* ========================================
   Image Handling
   ======================================== */

/* Default image styling */
.ckeditor-content img {
    max-width: 100%;
    height: auto;
    display: inline-block;
    border-radius: 8px;
}

/* CKEditor resized images - respect the width set in editor */
.ckeditor-content .image_resized {
    display: block;
}

.ckeditor-content .image_resized img {
    width: 100%;
}

/* Left aligned/floated images - Inline styles */
.ckeditor-content img[style*="float:left"],
.ckeditor-content img[style*="float: left"],
.ckeditor-content img[align="left"] {
    float: left;
    margin: 0 20px 20px 0;
    max-width: 50%;
}

/* Left aligned/floated images - CKEditor classes */
.ckeditor-content .image-style-align-left,
.ckeditor-content .image.image-style-align-left,
.ckeditor-content figure.image-style-align-left {
    float: left;
    margin: 0 20px 20px 0;
    max-width: 50%;
}

.ckeditor-content .image-style-align-left img {
    float: none;
    display: block;
    width: 100%;
}

/* Right aligned/floated images - Inline styles */
.ckeditor-content img[style*="float:right"],
.ckeditor-content img[style*="float: right"],
.ckeditor-content img[align="right"] {
    float: right;
    margin: 0 0 20px 20px;
    max-width: 50%;
}

/* Right aligned/floated images - CKEditor classes */
.ckeditor-content .image-style-align-right,
.ckeditor-content .image.image-style-align-right,
.ckeditor-content figure.image-style-align-right {
    float: right;
    margin: 0 0 20px 20px;
    max-width: 50%;
}

.ckeditor-content .image-style-align-right img {
    float: none;
    display: block;
    width: 100%;
}

/* Center aligned images - Inline styles */
.ckeditor-content img[style*="display:block"],
.ckeditor-content img[style*="display: block"],
.ckeditor-content img[align="center"] {
    display: block;
    margin: 20px auto;
    max-width: 100%;
}

/* Center aligned images - CKEditor classes */
.ckeditor-content .image-style-align-center,
.ckeditor-content .image.image-style-align-center,
.ckeditor-content figure.image-style-align-center {
    display: block;
    margin: 20px auto;
    max-width: 100%;
    text-align: center;
}

.ckeditor-content .image-style-align-center img {
    display: inline-block;
    margin: 0 auto;
}

/* ========================================
   Text Formatting
   ======================================== */

/* Paragraphs */
.ckeditor-content p {
    margin-bottom: 15px;
    text-align: justify;
    line-height: 1.8;
}

.ckeditor-content p:last-child {
    margin-bottom: 0;
}

/* Headings */
.ckeditor-content h1 {
    font-size: 2.5em;
    margin-top: 30px;
    margin-bottom: 20px;
    font-weight: 700;
    line-height: 1.2;
    color: #192335;
}

.ckeditor-content h2 {
    font-size: 2em;
    margin-top: 28px;
    margin-bottom: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: #192335;
}

.ckeditor-content h3 {
    font-size: 1.75em;
    margin-top: 25px;
    margin-bottom: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: #192335;
}

.ckeditor-content h4 {
    font-size: 1.5em;
    margin-top: 22px;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.4;
    color: #192335;
}

.ckeditor-content h5 {
    font-size: 1.25em;
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 600;
    line-height: 1.4;
    color: #192335;
}

.ckeditor-content h6 {
    font-size: 1em;
    margin-top: 18px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.5;
    color: #192335;
}

/* First heading has no top margin */
.ckeditor-content h1:first-child,
.ckeditor-content h2:first-child,
.ckeditor-content h3:first-child,
.ckeditor-content h4:first-child,
.ckeditor-content h5:first-child,
.ckeditor-content h6:first-child {
    margin-top: 0;
}

/* ========================================
   Lists
   ======================================== */

.ckeditor-content ul,
.ckeditor-content ol {
    margin-bottom: 15px;
    padding-left: 30px;
}

.ckeditor-content ul {
    list-style-type: disc;
}

.ckeditor-content ol {
    list-style-type: decimal;
}

.ckeditor-content li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.ckeditor-content ul ul,
.ckeditor-content ol ol,
.ckeditor-content ul ol,
.ckeditor-content ol ul {
    margin-top: 8px;
    margin-bottom: 8px;
}

/* Nested list styles */
.ckeditor-content ul ul {
    list-style-type: circle;
}

.ckeditor-content ul ul ul {
    list-style-type: square;
}

/* ========================================
   Tables
   ======================================== */

.ckeditor-content table {
    width: 100%;
    margin-bottom: 20px;
    border-collapse: collapse;
    background-color: #fff;
}

.ckeditor-content table td,
.ckeditor-content table th {
    padding: 12px 15px;
    border: 1px solid #ddd;
    text-align: left;
    vertical-align: top;
}

.ckeditor-content table th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: #192335;
}

.ckeditor-content table tr:nth-child(even) {
    background-color: #fafafa;
}

.ckeditor-content table tr:hover {
    background-color: #f0f0f0;
}

/* Responsive tables */
@media (max-width: 768px) {
    .ckeditor-content table {
        font-size: 0.9em;
    }

    .ckeditor-content table td,
    .ckeditor-content table th {
        padding: 8px 10px;
    }
}

/* ========================================
   Blockquotes
   ======================================== */

.ckeditor-content blockquote {
    border-left: 4px solid var(--it-theme-1, #192335);
    padding: 15px 20px;
    margin: 20px 0;
    font-style: italic;
    color: #666;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.ckeditor-content blockquote p {
    margin-bottom: 10px;
}

.ckeditor-content blockquote p:last-child {
    margin-bottom: 0;
}

/* ========================================
   Links
   ======================================== */

.ckeditor-content a {
    color: var(--it-theme-1, #192335);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.ckeditor-content a:hover {
    color: var(--it-theme-2, #0066cc);
    text-decoration: none;
}

/* ========================================
   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;
}

.ckeditor-content s,
.ckeditor-content strike {
    text-decoration: line-through;
}

.ckeditor-content code {
    background-color: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: "Courier New", monospace;
    font-size: 0.9em;
}

.ckeditor-content pre {
    background-color: #f4f4f4;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.ckeditor-content pre code {
    background-color: transparent;
    padding: 0;
}

/* ========================================
   Horizontal Rules
   ======================================== */

.ckeditor-content hr {
    border: none;
    border-top: 2px solid #e0e0e0;
    margin: 30px 0;
}

/* ========================================
   Figure and Caption
   ======================================== */

.ckeditor-content figure {
    margin: 20px 0;
    text-align: center;
}

.ckeditor-content figcaption {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
    text-align: center;
    margin-top: 8px;
    padding: 0 10px;
}

/* ========================================
   Embedded Content
   ======================================== */

.ckeditor-content iframe {
    max-width: 100%;
    margin: 20px 0;
    border-radius: 8px;
}

.ckeditor-content video {
    max-width: 100%;
    height: auto;
    margin: 20px 0;
    border-radius: 8px;
}

/* ========================================
   Text Alignment
   ======================================== */

.ckeditor-content .text-left,
.ckeditor-content [style*="text-align: left"],
.ckeditor-content [style*="text-align:left"] {
    text-align: left !important;
}

.ckeditor-content .text-center,
.ckeditor-content [style*="text-align: center"],
.ckeditor-content [style*="text-align:center"] {
    text-align: center !important;
}

.ckeditor-content .text-right,
.ckeditor-content [style*="text-align: right"],
.ckeditor-content [style*="text-align:right"] {
    text-align: right !important;
}

.ckeditor-content .text-justify,
.ckeditor-content [style*="text-align: justify"],
.ckeditor-content [style*="text-align:justify"] {
    text-align: justify !important;
}

/* ========================================
   Clear Floats
   ======================================== */

.ckeditor-content::after {
    content: "";
    display: table;
    clear: both;
}

.ckeditor-content .clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
    /* Reset floated images on mobile - Inline styles */
    .ckeditor-content img[style*="float:left"],
    .ckeditor-content img[style*="float: left"],
    .ckeditor-content img[style*="float:right"],
    .ckeditor-content img[style*="float: right"],
    .ckeditor-content img[align="left"],
    .ckeditor-content img[align="right"] {
        float: none !important;
        display: block;
        margin: 20px auto !important;
        max-width: 100% !important;
    }

    /* Reset floated images on mobile - CKEditor classes */
    .ckeditor-content .image-style-align-left,
    .ckeditor-content .image.image-style-align-left,
    .ckeditor-content figure.image-style-align-left,
    .ckeditor-content .image-style-align-right,
    .ckeditor-content .image.image-style-align-right,
    .ckeditor-content figure.image-style-align-right {
        float: none !important;
        display: block;
        margin: 20px auto !important;
        max-width: 100% !important;
    }

    /* Adjust heading sizes on mobile */
    .ckeditor-content h1 {
        font-size: 2em;
    }

    .ckeditor-content h2 {
        font-size: 1.75em;
    }

    .ckeditor-content h3 {
        font-size: 1.5em;
    }

    .ckeditor-content h4 {
        font-size: 1.25em;
    }

    /* Adjust padding on mobile */
    .ckeditor-content blockquote {
        padding: 10px 15px;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .ckeditor-content {
        color: #000;
    }

    .ckeditor-content a {
        text-decoration: underline;
        color: #000;
    }

    .ckeditor-content img {
        max-width: 100%;
        page-break-inside: avoid;
    }
}
