/* ============================================================
   QUẢN LÝ BÀI ĐĂNG — popup lớn + nút nhấp nháy + báo phản hồi
   Dùng ở Trang chủ giáo viên, ngay dưới nút "Đăng thông tin ngay".
   ============================================================ */

/* ── Hai nút mở popup ── */
.qlbd-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.qlbd-open-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    border: 2px solid #e2e8f0;
    background: #fff;
    color: #334155;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.qlbd-open-btn:hover { border-color: #bb2649; color: #bb2649; background: #fff5f7; }
.qlbd-open-btn .material-icons-round { font-size: 20px; }

/* Huy hiệu số phản hồi chưa xem */
.qlbd-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #dc2626;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(220,38,38,.45);
}
.qlbd-open-btn.is-alert .qlbd-badge { display: flex; }

/* Nút phồng lên xẹp xuống khi có phản hồi chưa xem */
.qlbd-open-btn.is-alert {
    border-color: #dc2626;
    color: #b91c1c;
    background: #fef2f2;
    animation: qlbd-pulse 1.15s ease-in-out infinite;
}

@keyframes qlbd-pulse {
    0%,100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(220,38,38,.35); }
    50%     { transform: scale(1.045); box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

@media (prefers-reduced-motion: reduce) {
    .qlbd-open-btn.is-alert { animation: none; }
}

/* ── Popup mỏng dài góc phải ── */
.qlbd-toast {
    position: fixed;
    right: 20px;
    bottom: 28px;
    z-index: 99500;
    display: none;
    align-items: center;
    gap: 12px;
    max-width: 380px;
    padding: 14px 16px;
    border-radius: 999px;
    background: linear-gradient(135deg, #bb2649 0%, #8f1836 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 12px 34px rgba(0,0,0,.32);
    cursor: pointer;
    animation: qlbd-toast-in .32s cubic-bezier(.2,.9,.3,1);
}
.qlbd-toast.hien { display: flex; }
.qlbd-toast .material-icons-round { font-size: 20px; flex-shrink: 0; }
.qlbd-toast-text { flex: 1; line-height: 1.35; }
.qlbd-toast-x {
    background: rgba(255,255,255,.18);
    border: none;
    color: #fff;
    width: 24px; height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}
.qlbd-toast-x:hover { background: rgba(255,255,255,.32); }

@keyframes qlbd-toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Popup lớn ── */
.qlbd-overlay {
    position: fixed;
    inset: 0;
    z-index: 99000;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    animation: qlbd-fade .2s ease;
}
@keyframes qlbd-fade { from { opacity: 0; } to { opacity: 1; } }

.qlbd-modal {
    width: min(980px, 100%);
    max-height: 100%;
    background: #f8fafc;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0,0,0,.35);
    animation: qlbd-pop .24s cubic-bezier(.2,.9,.3,1);
}
@keyframes qlbd-pop { from { transform: translateY(18px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.qlbd-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    background: #bb2649;
    color: #fff;
    flex-shrink: 0;
}
/* style.css có quy tắc màu chữ chung cho h3 nên phải ghi đè, không thì
   tiêu đề ra màu đen trên nền đỏ, đọc không nổi. */
.qlbd-head h3 { margin: 0; font-size: 18px; font-weight: 800; flex: 1; color: #fff !important; }
.qlbd-head .material-icons-round { font-size: 22px; color: #fff !important; }
.qlbd-head-sub { font-size: 13px; opacity: .9; font-weight: 600; color: #fff !important; }
.qlbd-close {
    background: rgba(255,255,255,.15);
    border: none; color: #fff;
    width: 34px; height: 34px;
    border-radius: 9px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.qlbd-close:hover { background: rgba(255,255,255,.3); }

.qlbd-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px 28px;
}

/* ── Thẻ một bài đăng ── */
.qlbd-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    margin-bottom: 14px;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}
.qlbd-card.co-moi   { border-color: #fca5a5; box-shadow: 0 0 0 3px rgba(220,38,38,.08); }
.qlbd-card.dang-mo  { border-color: #bb2649; box-shadow: 0 6px 20px rgba(187,38,73,.12); }

.qlbd-card-head {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    align-items: flex-start;
}
.qlbd-card-head:hover { background: #fafafa; }

.qlbd-thumb {
    width: 74px; height: 74px;
    border-radius: 10px;
    object-fit: cover;
    background: #f1f5f9;
    flex-shrink: 0;
}
.qlbd-thumb-empty {
    width: 74px; height: 74px;
    border-radius: 10px;
    background: #f1f5f9;
    display: flex; align-items: center; justify-content: center;
    color: #cbd5e1;
    flex-shrink: 0;
}

.qlbd-card-main { flex: 1; min-width: 0; }
.qlbd-card-title {
    font-size: 15px; font-weight: 800; color: #1e293b;
    margin: 0 0 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.qlbd-card-desc {
    font-size: 13px; color: #64748b; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.qlbd-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.qlbd-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 700;
    padding: 3px 9px; border-radius: 999px;
    background: #f1f5f9; color: #475569;
}
.qlbd-chip .material-icons-round { font-size: 14px; }
.qlbd-chip-new { background: #fee2e2; color: #b91c1c; }

.qlbd-card-tools { display: flex; gap: 6px; flex-shrink: 0; }
.qlbd-tool {
    width: 34px; height: 34px;
    border-radius: 9px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: .15s;
}
.qlbd-tool:hover { border-color: #bb2649; color: #bb2649; background: #fff5f7; }
.qlbd-tool.nguy-hiem:hover { border-color: #dc2626; color: #dc2626; background: #fef2f2; }
.qlbd-tool .material-icons-round { font-size: 18px; }

/* ── Phần mở rộng: tương tác ── */
.qlbd-detail { display: none; border-top: 1px dashed #e2e8f0; padding: 16px; background: #fcfcfd; }
.qlbd-card.dang-mo .qlbd-detail { display: block; }

.qlbd-sec-title {
    font-size: 13px; font-weight: 800; color: #bb2649;
    text-transform: uppercase; letter-spacing: .4px;
    margin: 0 0 10px; display: flex; align-items: center; gap: 6px;
}
.qlbd-sec-title .material-icons-round { font-size: 16px; }
.qlbd-sec + .qlbd-sec { margin-top: 18px; }

.qlbd-rea-list { display: flex; flex-wrap: wrap; gap: 8px; }
.qlbd-rea {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fff; border: 1px solid #e2e8f0;
    border-radius: 999px; padding: 5px 12px;
    font-size: 13px; color: #334155; font-weight: 600;
}
.qlbd-rea.moi { border-color: #fca5a5; background: #fff5f5; }

.qlbd-cmt { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.qlbd-cmt:last-child { border-bottom: none; }
.qlbd-cmt-av {
    width: 34px; height: 34px; border-radius: 50%;
    background: #bb2649; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 14px; flex-shrink: 0;
    object-fit: cover;
}
.qlbd-cmt-body { flex: 1; min-width: 0; }
.qlbd-cmt-name { font-size: 13px; font-weight: 800; color: #1e293b; }
.qlbd-cmt-name .qlbd-moi-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: #dc2626; margin-left: 6px; vertical-align: middle;
}
.qlbd-cmt-text { font-size: 14px; color: #334155; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.qlbd-cmt-time { font-size: 11px; color: #94a3b8; margin-top: 3px; }
.qlbd-cmt-del {
    background: none; border: none; color: #cbd5e1; cursor: pointer;
    padding: 2px; align-self: flex-start;
}
.qlbd-cmt-del:hover { color: #dc2626; }
.qlbd-cmt-del .material-icons-round { font-size: 17px; }

.qlbd-empty { text-align: center; color: #94a3b8; font-size: 14px; padding: 34px 10px; }
.qlbd-empty .material-icons-round { font-size: 42px; display: block; margin-bottom: 8px; color: #cbd5e1; }

/* ── Form sửa bài ── */
.qlbd-edit { display: none; border-top: 1px dashed #e2e8f0; padding: 16px; background: #fffbfc; }
.qlbd-card.dang-sua .qlbd-edit   { display: block; }
.qlbd-card.dang-sua .qlbd-detail { display: none; }

.qlbd-edit label { display: block; font-size: 13px; font-weight: 700; color: #334155; margin: 0 0 6px; }
.qlbd-edit .qlbd-field + .qlbd-field { margin-top: 14px; }
.qlbd-edit input[type=text], .qlbd-edit select {
    width: 100%; box-sizing: border-box; height: 42px;
    border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 0 12px; font-family: inherit; font-size: 14px;
    background: #fff; color: #1e293b; outline: none;
}
.qlbd-edit input[type=text]:focus, .qlbd-edit select:focus { border-color: #bb2649; }

.qlbd-img-now { display: flex; align-items: center; gap: 12px; }
.qlbd-img-now img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid #e2e8f0; }

.qlbd-edit-actions { display: flex; gap: 10px; margin-top: 18px; }
.qlbd-btn {
    height: 42px; padding: 0 18px; border-radius: 10px;
    font-family: inherit; font-size: 14px; font-weight: 700;
    cursor: pointer; border: 1px solid #e2e8f0; background: #fff; color: #475569;
    display: inline-flex; align-items: center; gap: 6px;
}
.qlbd-btn:hover { border-color: #94a3b8; }
.qlbd-btn-chinh { background: #bb2649; border-color: #bb2649; color: #fff; }
.qlbd-btn-chinh:hover { background: #a01f3e; border-color: #a01f3e; }
.qlbd-btn .material-icons-round { font-size: 18px; }

/* ── Máy hẹp ── */
@media (max-width: 700px) {
    .qlbd-row { grid-template-columns: 1fr; }
    .qlbd-overlay { padding: 0; }
    .qlbd-modal { border-radius: 0; height: 100%; width: 100%; }
    .qlbd-thumb, .qlbd-thumb-empty { width: 56px; height: 56px; }
    .qlbd-toast { left: 14px; right: 14px; max-width: none; border-radius: 14px; }

    /* ⚠ TAI THỎ (24/08/2026) — popup phủ kín màn hình nên thanh đỏ nằm sát mép
       trên; trên iPhone mép trên chính là tai thỏ / Dynamic Island + đồng hồ,
       thành ra tiêu đề bị che và nút X bấm không trúng. Chừa đúng phần vùng an
       toàn máy báo về. Máy không có tai thỏ thì inset = 0, không đổi gì. */
    .qlbd-head { padding: calc(13px + env(safe-area-inset-top, 0px)) 16px 13px; }
    .qlbd-head h3 { font-size: 16px; }
    .qlbd-body { padding: 14px 16px calc(28px + env(safe-area-inset-bottom, 0px)); }
}
