/* static/css/components.css */

/* modern inputs styling */
.form-control-custom {
    /* display:block + width:100%: label luôn nằm trên input, field không
       tràn khỏi cột grid trong modal form (gây dính cột / cuộn ngang) */
    display: block;
    width: 100%;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.9rem 1rem;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .035);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color .2s ease;
}

.form-control-custom::placeholder {
    color: var(--text-sub);
    opacity: .72;
}

.form-control-custom:focus {
    background-color: var(--bg-card);
    color: var(--text-main);
    outline: none;
    border-color: var(--emerald-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Input file: style nút chọn file đồng bộ theme thay nút native của trình duyệt */
.form-control-custom[type="file"] {
    padding: .55rem .75rem;
    cursor: pointer;
}

.form-control-custom::file-selector-button {
    margin-right: .9rem;
    padding: .5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: .7rem;
    background: var(--bg-hover);
    color: var(--text-main);
    font-weight: 700;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}

.form-control-custom[type="file"]:hover::file-selector-button {
    background: var(--border-color);
    border-color: var(--emerald-500);
}

/* Rich text content blocks (course description, lesson body text):
   long-form reading needs high-contrast body color and generous spacing —
   --text-sub is a muted label color and reads as too faint at paragraph length. */
.rich-content {
    color: var(--text-main);
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.85;
}

.rich-content p {
    margin-bottom: 1.15rem;
}

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

.rich-content strong,
.rich-content b {
    font-weight: 700;
}

.rich-content > :first-child {
    margin-top: 0;
}

.rich-content h1,
.rich-content h2,
.rich-content h3,
.rich-content h4,
.rich-content h5,
.rich-content h6 {
    color: var(--text-main);
    font-weight: 800;
    line-height: 1.3;
    margin: 1.75rem 0 .75rem;
}

.rich-content h1 { font-size: 1.5rem; }
.rich-content h2 { font-size: 1.3rem; }
.rich-content h3 { font-size: 1.15rem; }
.rich-content h4,
.rich-content h5,
.rich-content h6 { font-size: 1.05rem; }

.rich-content ul,
.rich-content ol {
    margin: 0 0 1.15rem;
    padding-left: 1.4rem;
}

.rich-content li {
    margin-bottom: .4rem;
}

.rich-content li:last-child {
    margin-bottom: 0;
}

.rich-content li > ul,
.rich-content li > ol {
    margin-top: .4rem;
    margin-bottom: 0;
}

.rich-content blockquote {
    margin: 0 0 1.15rem;
    padding: .75rem 1.1rem;
    border-left: 3px solid var(--emerald-500);
    background: rgba(16, 185, 129, .06);
    border-radius: 0 .6rem .6rem 0;
}

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

.rich-content code {
    background: var(--bg-hover);
    padding: .15rem .4rem;
    border-radius: .35rem;
    font-size: .9em;
}

.rich-content pre {
    background: var(--bg-hover);
    padding: 1rem 1.1rem;
    border-radius: .75rem;
    overflow-x: auto;
    margin: 0 0 1.15rem;
    border: 1px solid var(--border-color);
}

.rich-content pre code {
    background: none;
    padding: 0;
}

.rich-content table {
    display: block;
    width: 100%;
    max-width: fit-content;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 0 0 1.15rem;
    font-size: .95rem;
}

.rich-content th,
.rich-content td {
    border: 1px solid var(--border-color);
    padding: .55rem .75rem;
    text-align: left;
}

.rich-content th {
    background: var(--bg-hover);
    font-weight: 700;
}

/* Kích thước phụ cho khối rich text ngắn (đề bài, mô tả quiz, feedback...) */
.rich-content-sm {
    font-size: .875rem;
    line-height: 1.65;
}

/* Đặt trên nền màu (hero lộ trình...): ăn theo màu chữ của khối cha */
.rich-content-inherit,
.rich-content-inherit h1,
.rich-content-inherit h2,
.rich-content-inherit h3,
.rich-content-inherit h4,
.rich-content-inherit h5,
.rich-content-inherit h6 {
    color: inherit;
}

/* Nội dung 1 đoạn nằm trong flex row (vd. text câu hỏi cạnh badge "Câu X")
   không được lòi margin đáy của block cuối */
.rich-content > :last-child {
    margin-bottom: 0;
}

/* ===== CKEditor 5 (textarea[data-rich-editor], nạp lazy từ CDN) =====
   ckeditor5.css được inject vào <head> SAU file này, nên mọi override biến
   --ck-* phải dùng selector html:root / html:root[data-bs-theme="dark"] để
   thắng :root của CKEditor về specificity bất chấp thứ tự nạp. */
html:root {
    /* Balloon (sửa link...) mặc định z~999, thấp hơn modal Bootstrap (1055).
       Khai cả 2 tên biến vì CKEditor đổi tên giữa các version. */
    --ck-z-panel: 2060;
    --ck-z-modal: 2060;
    --ck-color-focus-border: var(--emerald-500);
}

.ck.ck-editor__editable_inline {
    min-height: 180px;
}

/* Vùng soạn thảo mô phỏng typography của .rich-content để WYSIWYG khớp
   với trang render cho học viên */
.ck.ck-content {
    color: var(--text-main);
    font-size: 1.05rem;
    line-height: 1.85;
}

.ck.ck-content h1 { font-size: 1.5rem; }
.ck.ck-content h2 { font-size: 1.3rem; }
.ck.ck-content h3 { font-size: 1.15rem; }
.ck.ck-content h4 { font-size: 1.05rem; }

.ck.ck-content h1,
.ck.ck-content h2,
.ck.ck-content h3,
.ck.ck-content h4 {
    font-weight: 800;
    line-height: 1.3;
}

.ck.ck-content blockquote {
    border-left: 3px solid var(--emerald-500);
    background: rgba(16, 185, 129, .06);
    font-style: normal;
}

.ck.ck-content code {
    background: var(--bg-hover);
    border-radius: .35rem;
}

.ck.ck-content pre {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: .75rem;
}

/* Dark theme cho khung CKEditor (toolbar, dropdown, balloon, input) */
html:root[data-bs-theme="dark"] {
    --ck-color-base-background: var(--bg-input);
    --ck-color-base-border: rgba(255, 255, 255, 0.12);
    --ck-color-base-text: var(--text-main);
    --ck-color-text: var(--text-main);
    --ck-color-toolbar-background: var(--bg-card);
    --ck-color-toolbar-border: rgba(255, 255, 255, 0.12);
    --ck-color-panel-background: var(--bg-card);
    --ck-color-panel-border: rgba(255, 255, 255, 0.12);
    --ck-color-dropdown-panel-background: var(--bg-card);
    --ck-color-list-background: var(--bg-card);
    --ck-color-list-button-hover-background: var(--bg-hover);
    --ck-color-button-default-hover-background: var(--bg-hover);
    --ck-color-button-default-active-background: var(--bg-hover);
    --ck-color-button-on-background: rgba(16, 185, 129, .18);
    --ck-color-button-on-hover-background: rgba(16, 185, 129, .25);
    --ck-color-button-text: var(--text-main);
    --ck-color-input-background: var(--bg-input);
    --ck-color-input-border: rgba(255, 255, 255, 0.15);
    --ck-color-input-text: var(--text-main);
    --ck-color-labeled-field-label-background: var(--bg-card);
    --ck-color-tooltip-background: var(--bg-card);
    --ck-color-tooltip-text: var(--text-main);
}

/* Glassmorphism elements */
.glass-panel {
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
}
