/* ═══════════════════════════════════════════════════════════
   GIÁO DỤC STEM — Admin CMS
   ═══════════════════════════════════════════════════════════ */

:root {
  --red:      #E4223B;
  --blue:     #0078AE;
  --navy:     #17375E;
  --green:    #059669;
  --orange:   #D97706;
  --violet:   #7C3AED;
  --dark:     #1a1a1a;
  --text:     #333;
  --muted:    #666;
  --border:   #e5e7eb;
  --bg:       #f3f4f6;
  --white:    #fff;
  --nav-w:    220px;
  --nav-bg:   #111827;
  --nav-text: rgba(255,255,255,.75);
  --nav-act:  rgba(255,255,255,.12);
  --shadow:   0 1px 3px rgba(0,0,0,.1);
  --radius:   6px;
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); }
a    { color: inherit; text-decoration: none; }
h1,h2,h3 { margin: 0; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }
img { max-width: 100%; }

/* ── Layout ────────────────────────────────────────────────── */
.gda-layout  { display: flex; min-height: 100vh; }
.gda-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gda-inner   { padding: 0 24px 40px; flex: 1; }

/* ── Sidebar nav ───────────────────────────────────────────── */
.gda-nav {
  width: var(--nav-w);
  background: var(--nav-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.gda-nav-brand {
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 8px;
}
.gda-brand-link { display: flex; align-items: center; gap: 10px; }
.gda-brand-icon { width: 36px; height: 36px; background: var(--red); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: white; font-size: 13px; flex-shrink: 0; }
.gda-brand-name { font-size: 14px; font-weight: 700; color: white; }
.gda-brand-sub  { font-size: 11px; color: rgba(255,255,255,.5); }

.gda-nav-section { font-size: 10px; font-weight: 700; color: rgba(255,255,255,.35); text-transform: uppercase; letter-spacing: 1px; padding: 12px 14px 4px; }

.gda-nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  color: var(--nav-text);
  font-size: 13.5px;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
}
.gda-nav-link:hover  { background: var(--nav-act); color: white; }
.gda-nav-link.active { background: var(--red); color: white; }
.gda-nav-link svg    { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }

.gda-nav-footer { margin-top: auto; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.gda-logout { color: #f87171 !important; }
.gda-logout:hover { background: rgba(248,113,113,.1) !important; }

/* Badge in nav */
.gda-badge { margin-left: auto; background: var(--red); color: white; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; }

/* ── Top bar ────────────────────────────────────────────────── */
.gda-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.gda-page-title   { font-size: 20px; font-weight: 700; color: var(--dark); }
.gda-topbar-left  { display: flex; align-items: center; gap: 4px; min-width: 0; }
.gda-hamburger    { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: -8px; background: none; border: none; color: var(--dark); border-radius: 8px; flex-shrink: 0; }
.gda-hamburger:hover { background: var(--bg); }
.gda-hamburger svg { width: 24px; height: 24px; }
.gda-nav-backdrop { display: none; }
.gda-topbar-right { display: flex; align-items: center; gap: 12px; }
.gda-user         { font-size: 13px; color: var(--muted); }
.gda-role-badge   { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 10px; }
.gda-role-badge.admin       { background: #fee2e2; color: #b91c1c; }
.gda-role-badge.editor      { background: #dbeafe; color: #1d4ed8; }
.gda-role-badge.contributor { background: #d1fae5; color: #065f46; }

/* ── Flash notice ───────────────────────────────────────────── */
.gda-flash { padding: 12px 16px; border-radius: var(--radius); margin: 0 24px 16px; font-weight: 500; }
.gda-flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.gda-flash-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.gda-flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Stats cards ────────────────────────────────────────────── */
.gda-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.gda-stat  { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border-left: 4px solid var(--stat-c, var(--red)); }
.gda-stat-num   { font-size: 32px; font-weight: 800; color: var(--dark); line-height: 1; }
.gda-stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .4px; }

/* ── Cards / Panels ─────────────────────────────────────────── */
.gda-card  { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.gda-card-hd { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.gda-card-hd h2 { font-size: 15px; font-weight: 700; }
.gda-card-body  { padding: 20px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn     { display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 5px; font-weight: 600; font-size: 13.5px; border: 1px solid transparent; transition: all .15s; line-height: 1.4; }
.btn-primary  { background: var(--red);  color: white; }
.btn-primary:hover  { background: #c0001f; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-success  { background: var(--green); color: white; }
.btn-success:hover  { background: #047857; }
.btn-warning  { background: var(--orange); color: white; }
.btn-warning:hover  { background: #b45309; }
.btn-danger   { background: #dc2626; color: white; }
.btn-danger:hover   { background: #b91c1c; }
.btn-sm  { padding: 4px 10px; font-size: 12px; }
.btn-xs  { padding: 2px 8px; font-size: 11px; border-radius: 3px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Table ──────────────────────────────────────────────────── */
.gda-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.gda-table th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.gda-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.gda-table tr:last-child td { border-bottom: none; }
.gda-table tr:hover td { background: #fafafa; }
.gda-table .col-title { max-width: 360px; }
.gda-table .col-title strong { display: block; font-size: 14px; font-weight: 700; color: var(--dark); }
.gda-table .col-title small  { color: var(--muted); font-size: 12px; }
.gda-table .col-actions { white-space: nowrap; text-align: right; }
.gda-table .col-actions .btn { margin-left: 4px; }

/* ── Sửa nhanh tại danh sách ─────────────────────────────────── */
.gda-edit { cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color .12s; }
.gda-edit:hover { border-bottom-color: #b8c4d4; }
.gda-inline-input { width: 100%; max-width: 200px; padding: 4px 7px; border: 1px solid var(--blue); border-radius: 5px; font-size: 13px; font-family: inherit; box-sizing: border-box; }

/* Status badges */
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.status-published { background: #d1fae5; color: #065f46; }
.status-draft     { background: #f3f4f6; color: #6b7280; }
.status-pending   { background: #fef3c7; color: #92400e; }
.status-archived  { background: #e5e7eb; color: #6b7280; }

/* ── Filter bar ─────────────────────────────────────────────── */
.gda-filter { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.gda-filter input[type="search"],
.gda-filter select { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--white); font-size: 13px; }
.gda-filter input[type="search"] { width: 240px; }
.gda-filter-count { margin-left: auto; font-size: 13px; color: var(--muted); }

/* ── Forms ──────────────────────────────────────────────────── */
.gda-form-row    { margin-bottom: 20px; }
.gda-form-row label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--dark); }
.gda-form-row .req { color: var(--red); }
.gda-form-row input[type="text"],
.gda-form-row input[type="email"],
.gda-form-row input[type="password"],
.gda-form-row input[type="url"],
.gda-form-row input[type="datetime-local"],
.gda-form-row textarea,
.gda-form-row select { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 5px; font-size: 14px; background: var(--white); color: var(--dark); transition: border-color .15s; }
.gda-form-row input:focus,
.gda-form-row textarea:focus,
.gda-form-row select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(228,34,59,.1); }
.gda-form-row textarea { resize: vertical; min-height: 80px; }
.gda-help { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Article edit layout ────────────────────────────────────── */
.gda-edit-layout  { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.gda-edit-main    { display: flex; flex-direction: column; gap: 16px; }
.gda-edit-sidebar { display: flex; flex-direction: column; gap: 16px; }

/* Quill editor */
.gda-quill-wrap  { border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.gda-quill-wrap .ql-toolbar  { border: none; border-bottom: 1px solid var(--border); background: #fafafa; }
.gda-quill-wrap .ql-container { border: none; font-size: 15px; min-height: 400px; }
.gda-quill-wrap .ql-editor p { margin-bottom: 1em; }
.gda-quill-wrap .ql-editor h2 { font-size: 1.35em; font-weight: 700; margin: 1.2em 0 .5em; }
.gda-quill-wrap .ql-editor h3 { font-size: 1.15em; font-weight: 700; margin: 1em 0 .4em; }
.gda-quill-wrap .ql-editor table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.gda-quill-wrap .ql-editor td,
.gda-quill-wrap .ql-editor th { border: 1px solid #ccc; padding: 7px 10px; min-width: 60px; vertical-align: top; }
.gda-quill-wrap .ql-editor th { background: #f5f5f5; font-weight: 700; }

/* Extra toolbar (table + AI format) */
.gda-extra-tb { display:flex; align-items:center; gap:6px; padding:6px 10px; background:#fafafa; border:1px solid var(--border); border-bottom:none; border-radius:5px 5px 0 0; flex-wrap:wrap; }
.gda-extra-tb + .gda-quill-wrap { border-radius:0 0 5px 5px; }
.gda-extra-tb + #quill-editor { border-top:none; border-radius:0 0 5px 5px; }
.gda-xtb-btn { display:inline-flex; align-items:center; gap:4px; padding:3px 10px; font-size:12px; border:1px solid #ddd; border-radius:4px; background:#fff; cursor:pointer; color:#444; font-weight:500; transition:all .15s; white-space:nowrap; }
.gda-xtb-btn:hover { border-color:#aaa; background:#f5f5f5; }
.gda-xtb-ai { border-color:#c084fc; color:#7c3aed; background:#faf5ff; }
.gda-xtb-ai:hover { background:#f3e8ff; border-color:#a855f7; }
.gda-xtb-sep { width:1px; height:18px; background:#ddd; margin:0 2px; flex-shrink:0; }
.gda-xtb-wrap { position:relative; }
/* Table grid picker popup */
.gda-tpick { position:absolute; top:calc(100% + 4px); left:0; z-index:999; background:#fff; border:1px solid #ddd; border-radius:6px; padding:10px; box-shadow:0 4px 16px rgba(0,0,0,.12); display:none; }
.gda-tpick.show { display:block; }
.gda-tpick-grid { display:grid; grid-template-columns:repeat(6,20px); gap:2px; }
.gda-tpick-cell { width:20px; height:20px; border:1px solid #ddd; border-radius:2px; cursor:pointer; background:#fff; transition:background .1s,border-color .1s; }
.gda-tpick-cell.hi { background:#dbeafe; border-color:#3b82f6; }
.gda-tpick-lbl { font-size:11px; color:#666; margin-top:6px; text-align:center; }

/* Featured image preview */
.gda-img-preview { width: 100%; aspect-ratio: 16/9; background: var(--bg); border: 2px dashed var(--border); border-radius: 5px; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; position: relative; }
.gda-img-preview img { width: 100%; height: 100%; object-fit: cover; }
.gda-img-preview .gda-img-placeholder { text-align: center; color: var(--muted); }
.gda-img-clear { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; display: none; }
.gda-img-preview:hover .gda-img-clear { display: flex; }

/* ── Login page ─────────────────────────────────────────────── */
.gda-login-wrap  { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--nav-bg); }
.gda-login-card  { background: var(--white); border-radius: 12px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.gda-login-logo  { text-align: center; margin-bottom: 28px; }
.gda-login-logo-icon { width: 56px; height: 56px; background: var(--red); border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 900; color: white; margin-bottom: 12px; }
.gda-login-title { font-size: 22px; font-weight: 800; color: var(--dark); margin-bottom: 4px; }
.gda-login-sub   { font-size: 13px; color: var(--muted); }
.gda-login-error { background: #fee2e2; color: #b91c1c; border-radius: 5px; padding: 10px 14px; margin-bottom: 16px; font-size: 13.5px; }
.gda-login-btn   { width: 100%; height: 42px; background: var(--red); color: white; border: none; border-radius: 6px; font-size: 15px; font-weight: 700; margin-top: 8px; transition: background .15s; }
.gda-login-btn:hover { background: #c0001f; }

/* ── AI Writer ──────────────────────────────────────────────── */
.gda-ai-form    { max-width: 720px; }
.gda-ai-spinner { display: none; align-items: center; gap: 10px; padding: 16px 0; color: var(--muted); }
.gda-ai-spinner.show { display: flex; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.gda-ai-step    { font-size: 13px; }

/* ── Modal ──────────────────────────────────────────────────── */
.gda-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.gda-modal   { background: var(--white); width: 960px; max-width: 96vw; max-height: 92vh; border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.gda-modal-hd { padding: 18px 24px 14px; border-bottom: 1px solid var(--border); }
.gda-modal-hd h2 { font-size: 20px; font-weight: 700; }
.gda-modal-body { overflow-y: auto; padding: 20px 24px; flex: 1; font-size: 15px; line-height: 1.8; }
.gda-modal-body h2 { font-size: 19px; margin: 1.4em 0 .6em; }
.gda-modal-body h3 { font-size: 16px; margin: 1.2em 0 .5em; }
.gda-modal-body p  { margin: 0 0 1em; }
.gda-modal-ft { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; background: #fafafa; flex-wrap: wrap; }
.gda-modal-ft .btn-close { margin-left: auto; }

/* ── Media grid ─────────────────────────────────────────────── */
.gda-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.gda-media-item { border: 2px solid var(--border); border-radius: 5px; overflow: hidden; cursor: pointer; position: relative; aspect-ratio: 1; background: var(--bg); }
.gda-media-item img { width: 100%; height: 100%; object-fit: cover; }
.gda-media-item:hover { border-color: var(--red); }
.gda-media-item.selected { border-color: var(--red); }
.gda-media-item .gda-media-select { position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; background: var(--red); border-radius: 50%; display: none; align-items: center; justify-content: center; color: white; font-size: 12px; }
.gda-media-item.selected .gda-media-select { display: flex; }
.gda-media-name { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.65); color: white; font-size: 10px; padding: 3px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gda-media-del { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; background: rgba(220,38,38,.9); color: white; border-radius: 50%; font-size: 11px; display: none; align-items: center; justify-content: center; border: none; cursor: pointer; padding: 0; line-height: 1; }
.gda-media-item:hover .gda-media-del { display: flex; }

/* Drop zone */
.gda-dropzone { border: 2px dashed var(--border); border-radius: 8px; padding: 40px 20px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .2s, background .2s; }
.gda-dropzone:hover, .gda-dropzone.drag-over { border-color: var(--red); background: rgba(228,34,59,.03); }
.gda-dropzone p { margin: 8px 0 0; font-size: 13px; }

/* ── Pagination ─────────────────────────────────────────────── */
.gda-pager { display: flex; gap: 4px; align-items: center; margin-top: 20px; }
.gda-pager a, .gda-pager span { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 13px; border-radius: 4px; background: var(--white); border: 1px solid var(--border); color: var(--dark); }
.gda-pager a:hover  { border-color: var(--red); color: var(--red); }
.gda-pager .active  { background: var(--red); color: white; border-color: var(--red); }

/* ── Tabs ────────────────────────────────────────────────────── */
.gda-tabs { display: flex; gap: 3px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.gda-tab  { padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; }
.gda-tab:hover  { color: var(--dark); }
.gda-tab.active { color: var(--red); border-color: var(--red); }

/* ── Chip input ──────────────────────────────────────────────── */
.gda-chips-box { display:flex; flex-wrap:wrap; gap:5px; min-height:22px; margin-bottom:8px; }
.gda-chip { display:inline-flex; align-items:center; gap:3px; background:#fee2e2; color:#b91c1c; border-radius:20px; padding:3px 8px 3px 11px; font-size:12px; font-weight:500; line-height:1.4; }
.gda-chip.topic { background:#ede9fe; color:#7c3aed; }
.gda-chip-x { cursor:pointer; font-size:13px; line-height:1; opacity:.55; background:none; border:none; padding:0 0 0 2px; color:inherit; }
.gda-chip-x:hover { opacity:1; }
.gda-suggest-wrap { position:relative; }
.gda-suggest-list { position:absolute; top:100%; left:0; right:0; background:#fff; border:1px solid var(--border); border-top:none; border-radius:0 0 6px 6px; box-shadow:0 4px 12px rgba(0,0,0,.08); z-index:300; max-height:180px; overflow-y:auto; }
.gda-suggest-list li { list-style:none; padding:8px 12px; cursor:pointer; font-size:13px; border-bottom:1px solid var(--border); }
.gda-suggest-list li:last-child { border-bottom:none; }
.gda-suggest-list li:hover,.gda-suggest-list li.hi { background:var(--bg); }
.gda-suggest-list li.new-item { color:var(--red); font-weight:600; }
.gda-suggest-list li.suggest-already { color:#16a34a; font-weight:600; cursor:default; pointer-events:none; }
.gda-suggest-list li.suggest-already:hover { background:none; }
.gda-suggest-list .suggest-cnt { font-size:11px; color:#aaa; margin-left:6px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .gda-stats { grid-template-columns: repeat(2, 1fr); }
  .gda-edit-layout { grid-template-columns: 1fr; }
  .gda-edit-sidebar { grid-row: 1; }
}
/* Tablet + điện thoại: sidebar thành drawer trượt, mở bằng nút hamburger */
@media (max-width: 820px) {
  .gda-nav {
    position: fixed; top: 0; left: 0; z-index: 1200;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 2px 0 24px rgba(0,0,0,.35);
  }
  .gda-layout.nav-open .gda-nav { transform: translateX(0); }
  .gda-nav-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 1150; opacity: 0; visibility: hidden; transition: opacity .25s;
  }
  .gda-layout.nav-open .gda-nav-backdrop { opacity: 1; visibility: visible; }
  .gda-hamburger { display: inline-flex; }

  .gda-topbar { padding: 10px 14px; margin-bottom: 16px; }
  .gda-page-title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .gda-inner { padding: 0 12px 24px; }
  .gda-flash { margin: 0 12px 16px; }
  .gda-card-hd { padding: 14px 16px; }
  .gda-card-body { padding: 16px; }

  /* Bảng dữ liệu: cuộn ngang trong thẻ thay vì tràn/cắt */
  .gda-card { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .gda-table { min-width: 560px; }

  /* Bộ lọc & tìm kiếm chiếm đủ chiều ngang */
  .gda-filter { gap: 8px; }
  .gda-filter input[type="search"] { width: 100%; flex: 1 1 100%; }
  .gda-filter-count { margin-left: 0; }

  .gda-modal-body { padding: 16px; }
  .gda-modal-hd { padding: 16px 18px 12px; }
  .gda-modal-hd h2 { font-size: 17px; }
}
@media (max-width: 560px) {
  .gda-stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .gda-stat  { padding: 15px; }
  .gda-stat-num { font-size: 25px; }
  .gda-user  { display: none; }
  .gda-topbar-right { gap: 8px; }
}
