/* Bảng nộp bài – giao diện */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok-bg: #e7f7ec; --ok-text: #166534;
  --err-bg: #fde8e8; --err-text: #991b1b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: .2em 0 .4em; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: .2em 0 .6em; }
code { background: #eef; padding: 1px 5px; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.inline { display: inline; }

/* Thanh trên */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.topbar nav a { text-decoration: none; color: var(--text); }
.topbar nav a:hover { color: var(--primary); }
.muted-link { color: var(--muted) !important; font-size: .85rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--text); font: inherit; cursor: pointer; }
.linkbtn:hover { color: var(--danger); }

/* Khung */
.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.narrow { max-width: 560px; margin: 0 auto; padding: 24px 16px 60px; }
.narrow-ish { max-width: 820px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 16px 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.tabs { display: flex; gap: 4px; background: #e5e7eb; padding: 4px; border-radius: 10px; }
.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: .9rem; }
.tabs a.active { background: #fff; box-shadow: var(--shadow); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Thông báo */
.flash { max-width: 1100px; margin: 12px auto; padding: 10px 14px; border-radius: 10px; }
body > .flash { margin: 12px 16px; }
@media (min-width: 1132px) { body > .flash { margin: 12px auto; } }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-err { background: var(--err-bg); color: var(--err-text); }

/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  color: var(--text); font: inherit; font-size: .95rem; cursor: pointer; text-decoration: none;
  white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f3c4c4; }
.btn-danger:hover { background: #fdeaea; }
.btn-small { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; padding: 12px; font-size: 1.05rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: rgba(0,0,0,.08); }

/* Biểu mẫu */
.form label { display: block; margin: 0 0 12px; font-size: .92rem; font-weight: 600; }
.form label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.form input:not([type=checkbox]):not([type=hidden]), .form textarea, .form select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-weight: 400;
  border: 1px solid #d1d5db; border-radius: 10px; background: #fff; color: var(--text);
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.form input[type=file] { padding: 8px; background: #f9fafb; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }
.req { color: var(--danger); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.login-box { margin-top: 40px; }
.checks td { padding: 3px 8px 3px 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table details summary { list-style: none; }
.inline-form { display: flex; gap: 6px; margin-top: 6px; }
.inline-form input { margin: 0 !important; }

/* Tạo bảng + danh sách bảng */
.create-board summary { list-style: none; cursor: pointer; }
.create-board summary::-webkit-details-marker { display: none; }
.create-board[open] summary { margin-bottom: 14px; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.board-tile {
  display: flex; flex-direction: column; gap: 8px; min-height: 140px; padding: 18px; border-radius: var(--radius);
  color: #fff; text-decoration: none; box-shadow: var(--shadow); transition: transform .15s;
}
.board-tile:hover { transform: translateY(-2px); }
.tile-title { font-weight: 700; font-size: 1.1rem; line-height: 1.3; }
.tile-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: .9rem; margin-top: auto; }
.tile-meta .badge, .board-head .badge { background: rgba(255,255,255,.25); }
.tile-sub { font-size: .8rem; opacity: .9; }

/* Màu nền bảng */
.bg-blue   { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.bg-green  { background: linear-gradient(135deg, #22c55e, #0d9488); }
.bg-orange { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.bg-pink   { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.bg-purple { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.bg-teal   { background: linear-gradient(135deg, #06b6d4, #14b8a6); }
.bg-gray   { background: linear-gradient(135deg, #64748b, #334155); }
body.board-page { background-attachment: fixed; min-height: 100vh; }

/* Trang bảng */
.board-wrap { padding: 16px 16px 100px; max-width: 1600px; margin: 0 auto; }
.board-head {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start;
  color: #fff; margin-bottom: 18px; text-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.board-head h1 { font-size: 1.8rem; }
.board-desc { max-width: 760px; opacity: .95; }
.board-desc a { color: #fff; }
.board-stats { margin-top: 6px; font-size: .9rem; opacity: .95; }
.board-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; text-shadow: none; }
.board-tools .btn { background: rgba(255,255,255,.92); border-color: transparent; }
.board-tools .btn:hover { background: #fff; }
#search {
  padding: 9px 12px; border-radius: 10px; border: 0; font: inherit; min-width: 200px;
  background: rgba(255,255,255,.92);
}
@media (max-width: 600px) {
  .board-head h1 { font-size: 1.4rem; }
  .board-tools { width: 100%; }
  #search { flex: 1 1 100%; }
}

/* Tường kiểu Padlet: xếp cột so le */
.wall { column-width: 290px; column-gap: 16px; }
.wall-empty { color: #fff; column-span: all; font-size: 1.05rem; }
.card {
  break-inside: avoid; -webkit-column-break-inside: avoid; display: inline-block; width: 100%;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  margin: 0 0 16px; overflow: hidden; animation: pop .25s ease-out;
}
.card.hidden { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.card-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px 10px; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: #e0e7ff; color: #3730a3; font-weight: 700;
}
.student { font-weight: 700; line-height: 1.2; word-break: break-word; }
.meta { font-size: .8rem; color: var(--muted); }
.class-badge { background: #eef2ff; color: #3730a3; padding: 0 7px; border-radius: 99px; font-weight: 600; }
.card .media { display: block; width: 100%; background: #000; }
.card a.media { background: #f3f4f6; }
.card img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: contain; }
.card video { max-height: 420px; }
.card .media + .media { margin-top: 2px; }
.media-audio { width: calc(100% - 28px); margin: 4px 14px; }
.note { padding: 10px 14px 0; white-space: normal; word-break: break-word; }
.link-chip {
  display: block; margin: 10px 14px 0; padding: 8px 10px; background: #f3f4f6; border-radius: 10px;
  text-decoration: none; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.files { list-style: none; margin: 10px 0 0; padding: 0 8px; }
.files li { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 8px; font-size: .9rem; }
.files li:hover { background: #f9fafb; }
.ficon { flex: none; }
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
a.fname { color: var(--primary); }
.fsize { flex: none; color: var(--muted); font-size: .8rem; }
.fdl { flex: none; text-decoration: none; padding: 2px 8px; border-radius: 6px; background: #eef2ff; font-weight: 700; }
.feedback { margin: 10px 14px 0; padding: 10px; background: #fef9c3; border-radius: 10px; font-size: .92rem; }
.card-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); margin-top: 12px; }
.card > :last-child:not(.card-actions) { margin-bottom: 14px; }
.fb-edit { flex: 1 1 100%; order: 2; }
.fb-edit summary { cursor: pointer; font-size: .88rem; color: var(--primary); }
.fb-edit textarea { margin: 8px 0; }

/* Nút nộp bài nổi */
.fab {
  position: fixed; right: 22px; bottom: 22px; width: 64px; height: 64px; border-radius: 50%;
  border: 0; background: #fff; color: var(--primary); font-size: 2.2rem; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 30; transition: transform .15s;
}
.fab:hover { transform: scale(1.07); }

/* Hộp thoại */
.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-box {
  position: relative; background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  padding: 22px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.modal-close {
  position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: #f3f4f6; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--text);
}
@media (max-width: 520px) { .modal { padding: 0; } .modal-box { border-radius: 0; min-height: 100%; } }
.qr-box { text-align: center; max-width: 520px; }
#qr svg, #qr img { width: 100%; max-width: 380px; height: auto; }
.share-url { font-family: ui-monospace, Consolas, monospace; word-break: break-all; font-size: 1.05rem; background: #f3f4f6; padding: 8px; border-radius: 8px; }
.file-list { list-style: none; padding: 0; margin: -4px 0 8px; font-size: .88rem; }
.file-list li { padding: 3px 0; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.file-list li span { min-width: 0; overflow-wrap: anywhere; }
.file-rm { flex: none; border: 0; background: #f3f4f6; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; color: var(--danger); }
.file-list .bad { color: var(--danger); }
.progress { position: relative; height: 26px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin: 8px 0 12px; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #16a34a); transition: width .2s; }
.progress .ptext { position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; font-weight: 700; }

/* Xem ảnh lớn */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.9); display: grid; place-items: center; padding: 20px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .modal-close { position: fixed; top: 14px; right: 14px; background: #fff; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw;
}
.toast[hidden] { display: none; }

/* Trang chung cho học sinh */
.board-tile.hidden { display: none; }
.home-search { max-width: 320px; width: 100%; }
.home-group { margin: 22px 0; }
.home-teacher { font-size: 1.1rem; margin: 0 0 10px; }
.home-link { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.home-link .share-url { margin-top: 6px; }
.home-link-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.back-home { display: inline-block; margin-bottom: 6px; color: inherit; opacity: .85; text-decoration: none; font-size: .9rem; }
.back-home:hover { opacity: 1; text-decoration: underline; }
