/* ============================================================
   css/cbt_question_tools.css
   Modern question editor components shared by:
     - admin_practice_questions.php
     - teacher_cbt_questions.php (+ AJAX edit form)
   ============================================================ */

/* ── Special-character toolbar ─────────────────────────────── */
.cbt-sc-toolbar,
.pq-sc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .38rem;
    padding: .65rem .75rem;
    margin-bottom: .65rem;
    background:
        linear-gradient(180deg, rgba(255,255,255,.7), rgba(248,250,252,.95)),
        var(--gray-50, #f8fafc);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}

.cbt-sc-group {
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted, #64748b);
    margin: 0 .25rem 0 .15rem;
}

.cbt-sc-btn {
    min-width: 2.55rem;
    height: 2.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 .45rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: #fff;
    color: var(--text, #0f172a);
    font-size: 1.24rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.cbt-sc-btn:hover {
    background: var(--primary, #0c5430);
    border-color: var(--primary, #0c5430);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,.12);
}

.cbt-sc-btn:active { transform: translateY(0); }

.cbt-sc-btn.cbt-sc-tag {
    min-width: auto;
    padding: 0 .7rem;
    font-size: 1.08rem;
    font-weight: 800;
    background: var(--primary-mist, #e8f5ee);
    border-color: rgba(12,84,48,.22);
    color: var(--primary-dark, #083b22);
}

.cbt-sc-btn.cbt-sc-tag:hover {
    background: var(--primary, #0c5430);
    color: #fff;
}

.cbt-sc-div {
    width: 1px;
    height: 1.75rem;
    background: var(--border, #cbd5e1);
    margin: 0 .35rem;
    opacity: .65;
}

.cbt-sc-compact .cbt-sc-group { display: none; }
.cbt-sc-compact .cbt-sc-div { margin: 0 .2rem; }

/* ── Rich-text formatting inside questions ─────────────────── */
.cbt-rich-text sup { font-size: .72em; line-height: 0; vertical-align: super; }
.cbt-rich-text sub { font-size: .72em; line-height: 0; vertical-align: sub; }

/* ── Modern image upload zone ──────────────────────────────── */
.cbt-upload {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    width: 100%;
    min-height: 11.5rem;
    padding: 1.4rem 1.2rem;
    overflow: hidden;
    text-align: center;
    cursor: pointer;
    background:
        radial-gradient(circle at 50% 0%, rgba(12,84,48,.07), transparent 62%),
        linear-gradient(180deg, #ffffff 0%, var(--gray-25, #fbfcfd) 100%);
    border: 2px dashed var(--border, #cbd5e1);
    border-radius: 16px;
    transition: border-color .18s ease, background .18s ease, transform .15s ease, box-shadow .18s ease;
}

.cbt-upload:hover,
.cbt-upload.is-dragover {
    border-color: var(--primary, #0c5430);
    background:
        radial-gradient(circle at 50% 0%, rgba(12,84,48,.13), transparent 65%),
        var(--primary-mist, #e8f5ee);
    box-shadow: 0 8px 22px rgba(12,84,48,.10);
    transform: translateY(-1px);
}

.cbt-upload > input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.cbt-upload-icon {
    font-size: 2.5rem;
    color: var(--primary, #0c5430);
    line-height: 1;
    pointer-events: none;
}

.cbt-upload-prompt {
    display: flex;
    flex-direction: column;
    gap: .18rem;
    pointer-events: none;
}

.cbt-upload-prompt strong {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text, #0f172a);
}

.cbt-upload-prompt small {
    font-size: 1.05rem;
    color: var(--text-muted, #64748b);
    line-height: 1.35;
}

.cbt-upload-preview {
    display: none;
    max-width: 100%;
    max-height: 16rem;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--border-light, #e2e8f0);
    box-shadow: 0 8px 20px rgba(15,23,42,.14);
    background: #fff;
    pointer-events: none;
}

.cbt-upload.has-file {
    border-style: solid;
    border-color: var(--primary, #0c5430);
    background: linear-gradient(180deg, #ffffff, #f7fffa);
    padding: 1rem;
}

.cbt-upload.has-file .cbt-upload-preview { display: block; }
.cbt-upload.has-file .cbt-upload-icon,
.cbt-upload.has-file .cbt-upload-prompt { display: none; }

.cbt-upload-name {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--primary-dark, #083b22);
    pointer-events: none;
}

.cbt-upload-clear {
    position: absolute;
    top: .55rem;
    right: .55rem;
    z-index: 3;
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid #fecaca;
    border-radius: 50%;
    background: #fff;
    color: #dc2626;
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(220,38,38,.16);
}

.cbt-upload-clear:hover { background: #fee2e2; }

.cbt-upload-sm {
    min-height: 8.2rem;
    padding: .9rem .8rem;
    border-radius: 12px;
}

.cbt-upload-sm .cbt-upload-icon { font-size: 1.8rem; }
.cbt-upload-sm .cbt-upload-prompt strong { font-size: 1.12rem; }
.cbt-upload-sm .cbt-upload-prompt small { font-size: .98rem; }
.cbt-upload-sm .cbt-upload-preview { max-height: 8.5rem; }

/* Existing image shown inside the edit modal */
.cbt-current-image {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    max-width: 100%;
    padding: .9rem 1.1rem;
    margin: 0 0 .9rem;
    background: var(--gray-25, #fbfcfd);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 12px;
}

.cbt-current-image img {
    max-width: 22rem;
    max-height: 13rem;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border-light, #e2e8f0);
    background: #fff;
}

.cbt-current-image .cbt-current-label {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .8rem;
    border-radius: 999px;
    background: var(--primary-mist, #e8f5ee);
    color: var(--primary-dark, #083b22);
    font-size: 1.05rem;
    font-weight: 800;
    white-space: nowrap;
}

/* ── Practice-bank upload zone polish ──────────────────────── */
.pq-img-z {
    position: relative;
    overflow: hidden;
    min-height: 10rem;
    border-radius: 16px !important;
    background:
        radial-gradient(circle at 50% 0%, rgba(12,84,48,.07), transparent 62%),
        linear-gradient(180deg, #fff 0%, var(--gray-25, #fbfcfd) 100%) !important;
}

.pq-img-z:hover { box-shadow: 0 8px 22px rgba(12,84,48,.10); transform: translateY(-1px); }

.pq-img-prev {
    display: none;
    max-width: 100%;
    max-height: 18rem;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--border-light, #e2e8f0);
    box-shadow: 0 8px 20px rgba(15,23,42,.14);
    background: #fff;
}

.pq-img-z.has-file .pq-img-prev { display: block; }
.pq-img-z.has-file .pq-img-icon,
.pq-img-z.has-file .pq-img-text { display: none; }

.pq-current-img-wrap {
    display: none;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
    padding: .8rem 1rem;
    margin-bottom: .8rem;
    background: var(--gray-25, #fbfcfd);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 12px;
}

.pq-current-img-wrap.is-shown { display: flex; }

.pq-current-img {
    max-width: 22rem;
    max-height: 13rem;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border-light, #e2e8f0);
    background: #fff;
}

.pq-img-icon-sm { font-size: 1.5rem; }

/* Question images in the student exam / review screens */
.question-image,
.option-image,
.sr-q-image,
.teq-q-image {
    max-width: min(100%, 520px);
    border-radius: 12px;
    border: 1px solid var(--border-light, #e2e8f0);
    box-shadow: 0 6px 18px rgba(15,23,42,.10);
    background: #fff;
}
