/**
 * HL Editor CSS
 * Styles cho nội dung được tạo từ CKEditor
 * Chỉ áp dụng cho elements bên trong .hl-editor để tránh conflict với code khác
 */

.hl-editor {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    word-wrap: break-word;
}

/* Typography - Headings */
.hl-editor h1,
.hl-editor h2,
.hl-editor h3,
.hl-editor h4,
.hl-editor h5,
.hl-editor h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    color: #2c3e50;
}

.hl-editor h1 {
    font-size: 2.25em;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.5em;
}

.hl-editor h2 {
    font-size: 1.875em;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.4em;
}

.hl-editor h3 {
    font-size: 1.5em;
}

.hl-editor h4 {
    font-size: 1.25em;
}

.hl-editor h5 {
    font-size: 1.125em;
}

.hl-editor h6 {
    font-size: 1em;
    color: #666;
}

/* Paragraph */
.hl-editor p {
    margin-bottom: 1em;
    text-align: justify;
}

.hl-editor p:last-child {
    margin-bottom: 0;
}

/* Links */
.hl-editor a {
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.hl-editor a:hover {
    color: #0056b3;
    border-bottom-color: #0056b3;
}

.hl-editor a:visited {
    color: #6f42c1;
}

/* Lists */
.hl-editor ul,
.hl-editor ol {
    margin: 1em 0;
    padding-left: 2em;
}

.hl-editor ul {
    list-style-type: disc;
}

.hl-editor ol {
    list-style-type: decimal;
}

.hl-editor li {
    margin-bottom: 0.5em;
    line-height: 1.6;
}

.hl-editor ul ul,
.hl-editor ol ol,
.hl-editor ul ol,
.hl-editor ol ul {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.hl-editor ul ul {
    list-style-type: circle;
}

.hl-editor ul ul ul {
    list-style-type: square;
}

/* Images */
.hl-editor img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5em auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Images inside paragraph */
.hl-editor p img {
    margin: 1em auto;
}

.hl-editor img.align-left {
    float: left;
    margin-right: 1.5em;
    margin-bottom: 1em;
    margin-top: 0;
}

.hl-editor img.align-right {
    float: right;
    margin-left: 1.5em;
    margin-bottom: 1em;
    margin-top: 0;
}

.hl-editor img.align-center {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Clear floats */
.hl-editor::after {
    content: "";
    display: table;
    clear: both;
}

/* Tables */
.hl-editor table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.95em;
    overflow-x: auto;
    display: block;
}

.hl-editor table thead {
    background-color: #f8f9fa;
}

.hl-editor table tbody {
    /* Normal tbody styling */
}

.hl-editor table th,
.hl-editor table td {
    padding: 0.75em 1em;
    border: 1px solid #dee2e6;
    text-align: left;
}

.hl-editor table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

/* Respect inline text-align styles */
.hl-editor table td[style*="text-align:center"],
.hl-editor table td[style*="text-align: center"] {
    text-align: center !important;
}

.hl-editor table td[style*="text-align:right"],
.hl-editor table td[style*="text-align: right"] {
    text-align: right !important;
}

.hl-editor table td[style*="text-align:left"],
.hl-editor table td[style*="text-align: left"] {
    text-align: left !important;
}

.hl-editor table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.hl-editor table tbody tr:hover {
    background-color: #e9ecef;
}

/* Blockquotes */
.hl-editor blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 4px solid #007bff;
    background-color: #f8f9fa;
    font-style: italic;
    color: #555;
}

.hl-editor blockquote p {
    margin-bottom: 0.5em;
}

.hl-editor blockquote p:last-child {
    margin-bottom: 0;
}

/* Code */
.hl-editor code {
    background-color: #f4f4f4;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.hl-editor pre {
    background-color: #f4f4f4;
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1.5em 0;
    border: 1px solid #dee2e6;
}

.hl-editor pre code {
    background-color: transparent;
    padding: 0;
    color: #333;
    font-size: 0.9em;
}

/* Horizontal Rule */
.hl-editor hr {
    border: none;
    border-top: 2px solid #dee2e6;
    margin: 2em 0;
}

/* Text Alignment */
.hl-editor .text-left {
    text-align: left;
}

.hl-editor .text-center {
    text-align: center;
}

.hl-editor .text-right {
    text-align: right;
}

.hl-editor .text-justify {
    text-align: justify;
}

/* Inline styles - respect user-defined colors and styles */
.hl-editor span[style] {
    /* Allow inline styles to work */
}

.hl-editor [style*="color"] {
    /* Respect inline color styles */
}

/* Strong and Emphasis */
.hl-editor strong,
.hl-editor b {
    font-weight: 600;
    color: #2c3e50;
}

.hl-editor em,
.hl-editor i {
    font-style: italic;
}

.hl-editor u {
    text-decoration: underline;
}

.hl-editor s,
.hl-editor strike,
.hl-editor del {
    text-decoration: line-through;
    color: #666;
}

/* Mark / Highlight */
.hl-editor mark {
    background-color: #ffeb3b;
    color: #000;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

/* Subscript and Superscript */
.hl-editor sub,
.hl-editor sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

.hl-editor sup {
    top: -0.5em;
}

.hl-editor sub {
    bottom: -0.25em;
}

/* Spacing Utilities */
.hl-editor .mb-1 { margin-bottom: 0.25em; }
.hl-editor .mb-2 { margin-bottom: 0.5em; }
.hl-editor .mb-3 { margin-bottom: 1em; }
.hl-editor .mb-4 { margin-bottom: 1.5em; }
.hl-editor .mb-5 { margin-bottom: 3em; }

.hl-editor .mt-1 { margin-top: 0.25em; }
.hl-editor .mt-2 { margin-top: 0.5em; }
.hl-editor .mt-3 { margin-top: 1em; }
.hl-editor .mt-4 { margin-top: 1.5em; }
.hl-editor .mt-5 { margin-top: 3em; }

/* Responsive */
@media (max-width: 768px) {
    .hl-editor {
        font-size: 14px;
    }
    
    .hl-editor h1 {
        font-size: 1.75em;
    }
    
    .hl-editor h2 {
        font-size: 1.5em;
    }
    
    .hl-editor h3 {
        font-size: 1.25em;
    }
    
    .hl-editor img.align-left,
    .hl-editor img.align-right {
        float: none;
        display: block;
        margin: 1em auto;
    }
    
    .hl-editor table {
        font-size: 0.85em;
    }
    
    .hl-editor table th,
    .hl-editor table td {
        padding: 0.5em 0.75em;
    }
}

/* Print Styles */
@media print {
    .hl-editor {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    .hl-editor a {
        color: #000;
        text-decoration: underline;
    }
    
    .hl-editor img {
        max-width: 100%;
        page-break-inside: avoid;
    }
    
    .hl-editor table {
        page-break-inside: avoid;
    }
}
