@import url("design-tokens.css");

/* ==========================================================================
   GIAO DIỆN CÁC TRANG NỘI BỘ BTT: Kho ảnh & Hệ thống (ĐX-12, ĐX-25)
   ========================================================================== */
:root {
  --primary: var(--mdc-deep-blue, #312E81);
  --primary-2: var(--mdc-neon-pink, #818CF8);
  --muted: var(--mdc-muted-blue, #6366F1);
  --bg: var(--bg-page, #F8FAFC);
  --surface: var(--surface-card, #FFFFFF);
  --border: var(--border-color, #E2E8F0);
  --text: var(--text-main, #312E81);
  --ok: #1F5E43;
  --warn: #B45309;
  --bad: #B03A48;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body, "Inter", -apple-system, sans-serif); background: var(--bg); color: var(--text); }
a { color: var(--primary-2); }

.btt-topbar {
  position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); padding: 10px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.btt-topbar img { height: 36px; }
.btt-topbar h1 { font-size: 18px; margin: 0; color: var(--primary); font-weight: 800; }
.btt-topbar .spacer { flex: 1; }
.btt-topbar .who { font-size: 13px; color: var(--muted); }
.btt-container { max-width: 1400px; margin: 0 auto; padding: 20px; }

.btt-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid #E2E8F0;
  background: #FFFFFF; color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; font-family: inherit;
}
.btt-btn:hover { border-color: #4F46E5; background: #F8FAFC; }
.btt-btn.primary { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }
.btt-btn.primary:hover { background: #0F172A; }
.btt-btn.danger { color: var(--bad); border-color: #FCECEE; }
.btt-btn.small { padding: 5px 9px; font-size: 12px; }
.btt-btn:disabled { opacity: .5; cursor: not-allowed; }

.btt-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(15, 23, 42,.03); }
.btt-card h2 { margin: 0 0 4px; font-size: 18px; color: var(--primary); }
.btt-card .sub { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }

.btt-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btt-filters select, .btt-filters input, .btt-form input, .btt-form select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid #E2E8F0; font-size: 13.5px; font-family: inherit; background: #FFFFFF;
}
.btt-filters input[type="search"] { min-width: 240px; flex: 1; }
.btt-filters label { font-size: 13px; color: #312E81; display: inline-flex; align-items: center; gap: 5px; }

.btt-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.btt-stat { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: #F8FAFC; }
.btt-stat .label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.btt-stat .value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.btt-stat .note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.btt-stat.ok .value { color: var(--ok); } .btt-stat.warn .value { color: var(--warn); } .btt-stat.bad .value { color: var(--bad); }
.btt-bar { height: 10px; background: #F1F5F9; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.btt-bar > div { height: 100%; background: var(--primary-2); }

.btt-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.btt-table th, .btt-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.btt-table th { background: #F8FAFC; color: #312E81; font-size: 12.5px; }
.btt-table td.num, .btt-table th.num { text-align: right; }
.btt-tag { display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: #F1F5F9; color: #312E81; }
.btt-tag.super { background: #F1F5F9; color: #312E81; } .btt-tag.off { background: #F1F5F9; color: #B03A48; }

.btt-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; align-items: end; }
.btt-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: #312E81; }

/* --- Kho ảnh --- */
.kho-group { margin-bottom: 26px; }
.kho-group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.kho-group-head h3 { margin: 0; font-size: 16px; }
.kho-group-head .meta { color: var(--muted); font-size: 13px; }
.kho-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kho-item { background: #FFFFFF; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.kho-item.sel { border-color: #F59E0B; box-shadow: 0 0 0 2px #FDE68A; }
.kho-thumb { position: relative; height: 150px; background: #F1F5F9; cursor: zoom-in; display: flex; align-items: center; justify-content: center; color: #4F46E5; font-weight: 800; }
.kho-thumb img { width: 100%; height: 100%; object-fit: cover; }
.kho-thumb .play { position: absolute; width: 38px; height: 38px; border-radius: 50%; background: rgba(15, 23, 42,.6); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.kho-flags { position: absolute; top: 6px; left: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.kho-flag { font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.92); }
.kho-flag.sel { color: #92400E; } .kho-flag.restr { color: #B03A48; } .kho-flag.dup { color: #312E81; }
.kho-meta { padding: 8px 10px; font-size: 12px; color: var(--muted); }
.kho-meta .name { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kho-actions { display: flex; gap: 4px; padding: 0 8px 8px; }
.kho-actions .btt-btn { flex: 1; justify-content: center; padding: 5px 4px; font-size: 12px; }
.kho-actions .btt-btn.on { background: #FEF3C7; border-color: #F59E0B; color: #92400E; }
.kho-actions .btt-btn.warn { background: #F1F5F9; border-color: #F6C3CA; color: #B03A48; }

.kho-lightbox { position: fixed; inset: 0; background: rgba(15, 23, 42,.94); z-index: 200; display: none; flex-direction: column; }
.kho-lightbox.open { display: flex; }
.kho-lb-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: #F1F5F9; font-size: 14px; }
.kho-lb-top .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kho-lb-body { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; padding: 10px 60px; }
.kho-lb-body img, .kho-lb-body video { max-width: 100%; max-height: 82vh; border-radius: 6px; }
.kho-lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: none; background: rgba(255,255,255,.15); color: #FFFFFF; font-size: 24px; cursor: pointer; }
.kho-lb-nav.prev { left: 10px; } .kho-lb-nav.next { right: 10px; }

.btt-center-card { max-width: 440px; margin: 12vh auto; background: #FFFFFF; border-radius: 16px; padding: 32px; text-align: center; box-shadow: 0 8px 30px rgba(15, 23, 42,.08); }
.btt-center-card h2 { color: var(--primary); }
.btt-center-card p { color: #312E81; line-height: 1.6; }

.btt-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(30px); background: #0F172A; color: #FFFFFF; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: all .25s; z-index: 300; font-size: 14px; }
.btt-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.btt-toast.error { background: var(--bad); }
.btt-empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* --- Chọn nhiều / xoá hàng loạt --- */
.kho-bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.kho-bulk > span { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kho-bulk-info { font-size: 13px; color: var(--muted); font-weight: 600; }
.btt-btn.danger:not(:disabled) { background: #F8FAFC; }
.kho-check { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 7px; background: rgba(255,255,255,.92); border: 2px solid #94A3B8; display: flex; align-items: center; justify-content: center; font-weight: 900; color: #FFFFFF; }
.kho-item.picked { border-color: var(--bad); box-shadow: 0 0 0 2px #FCECEE; }
.kho-item.picked .kho-check { background: var(--bad); border-color: var(--bad); }
.selecting .kho-thumb { cursor: pointer; }
.kho-item.locked .kho-check { opacity: .35; }

/* Dark Mode Overrides (ĐX-25) */
[data-theme="dark"], .dark-theme {
  --bg: var(--bg-page, #0F172A);
  --surface: var(--surface-card, #0F172A);
  --border: var(--border-color, #312E81);
  --text: var(--text-main, #F8FAFC);
  --muted: var(--color-text-muted, #94A3B8);
}

[data-theme="dark"] .btt-topbar,
.dark-theme .btt-topbar {
  background: rgba(15, 23, 42, 0.95);
  border-bottom-color: #312E81;
}

[data-theme="dark"] .btt-card,
.dark-theme .btt-card {
  background: #0F172A;
  border-color: #312E81;
  color: #F8FAFC;
}

[data-theme="dark"] .btt-btn,
.dark-theme .btt-btn {
  background: #0F172A;
  border-color: #312E81;
  color: #F8FAFC;
}

[data-theme="dark"] .btt-btn:hover,
.dark-theme .btt-btn:hover {
  background: #4F46E5;
  border-color: #6366F1;
}

[data-theme="dark"] .btt-btn.primary,
.dark-theme .btt-btn.primary {
  background: var(--mdc-deep-blue, #312E81);
  border-color: var(--mdc-deep-blue, #312E81);
  color: #FFFFFF;
}

[data-theme="dark"] .btt-table th,
.dark-theme .btt-table th {
  background: #0F172A;
  color: #F8FAFC;
  border-bottom-color: #312E81;
}

[data-theme="dark"] .btt-table td,
.dark-theme .btt-table td {
  border-bottom-color: #312E81;
  color: #F8FAFC;
}


/* ---------- Kho: xem theo album (mỗi sự kiện 1 hàng xem trước) ---------- */
.kho-group-head .kho-open { margin-left: auto; }
.kho-group-head .stat-sel { color: #92400E; font-weight: 700; }
.kho-grid.preview { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.kho-grid.preview .kho-item:nth-child(n+7) { display: none; }
.kho-more { border: 2px dashed var(--border); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-height: 150px; cursor: pointer; color: var(--text); font-weight: 700; text-align: center; padding: 10px; background: #F8FAFC; }
.kho-more:hover { border-color: #EC4899; background: #EEF2FF; }
.kho-more .n { font-size: 26px; font-family: var(--font-heading, inherit); }
.kho-album { position: sticky; top: 0; z-index: 30; }
.kho-album-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.kho-album-top h2 { margin: 0; font-size: 18px; flex: 1; min-width: 220px; }
.kho-album-stats { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; }
.kho-pill { padding: 4px 10px; border-radius: 999px; background: #F1F5F9; font-weight: 700; color: #334155; }
.kho-pill.st { background: #E0E7FF; color: #4F46E5; }
.kho-pill.sel { background: #FEF3C7; color: #92400E; }
.kho-progress { flex: 1; min-width: 160px; height: 8px; border-radius: 99px; background: #F1F5F9; overflow: hidden; }
.kho-progress div { height: 100%; background: linear-gradient(90deg, #EC4899, #FBCFE8); }
.kho-folders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.kho-folders button { border: 1px solid var(--border); background: #FFFFFF; border-radius: 999px; padding: 4px 11px; font: 600 12.5px inherit; font-family: inherit; cursor: pointer; color: var(--text); }
.kho-folders button:hover { border-color: #EC4899; }
.kho-hint { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.kho-folder-head { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 8px; font-size: 15px; scroll-margin-top: 190px; }
.kho-folder-head .meta { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.kho-lb-count { font-size: 13px; opacity: .85; white-space: nowrap; }
.kho-lb-star.on { background: #FEF3C7 !important; color: #92400E !important; border-color: #F59E0B !important; }
#lbRestrict.on { background: #F6C3CA !important; color: #7E2433 !important; }
@media (max-width: 700px) {
  .kho-album { position: static; }
  .kho-lb-top { flex-wrap: wrap; }
  .kho-lb-top .title { flex-basis: 100%; }
}
.kho-bulk [hidden], .kho-bulk[hidden] { display: none !important; }

/* Kéo thả tệp vào album (2026-11-19) */
.kho-drop { position: fixed; inset: 0; z-index: 9997; background: rgba(79,70,229,.12); border: 4px dashed #6366F1; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.kho-drop[hidden] { display: none; }
.kho-drop div { background: #fff; color: #3730A3; font-weight: 800; font-size: 20px; padding: 18px 28px; border-radius: 14px; box-shadow: 0 10px 30px rgba(15,23,42,.18); }
