/* ============================================================
   Óc Eo Heritage - Trang quản trị
   ============================================================ */

body { background: var(--sand); min-height: 100vh; }

.a-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--clay-deep), var(--clay-dark));
  color: var(--cream);
  box-shadow: var(--shadow-soft);
}
.a-header .container {
  display: flex; align-items: center; gap: 14px; height: 62px;
}
.a-header .brand-mark { width: 36px; height: 36px; font-size: 17px; }
.a-header h1 { font-family: var(--font-heading); font-size: 18px; flex: 1; }
.a-header h1 small { display: block; font-family: var(--font-body); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-soft); font-weight: 500; }
.a-header .actions { display: flex; gap: 8px; }
.a-hbtn {
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid rgba(253,250,242,.25);
  background: rgba(253,250,242,.1); color: var(--cream); font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 6px;
}
.a-hbtn:hover { background: rgba(253,250,242,.22); }

.a-main { padding: 26px 0 60px; }

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 62px); display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--cream); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); border: 1px solid var(--sand-dark);
  padding: 40px 36px; text-align: center;
}
.login-card .brand-mark { width: 64px; height: 64px; font-size: 30px; border-radius: 18px; margin: 0 auto 18px; }
.login-card h2 { font-family: var(--font-heading); color: var(--clay-deep); margin-bottom: 6px; }
.login-card p { font-size: 13.5px; color: var(--ink-faint); margin-bottom: 24px; }
.login-card input {
  width: 100%; padding: 13px 16px; font-size: 20px; text-align: center; letter-spacing: .35em;
  border: 1.5px solid var(--sand-dark); border-radius: var(--radius-sm);
  font-family: var(--font-body); outline: none; margin-bottom: 14px;
  background: var(--white); color: var(--ink);
}
.login-card input:focus { border-color: var(--clay); }
.login-err { color: #c0392b; font-size: 13px; min-height: 20px; margin-bottom: 6px; }

/* ---------- Form elements ---------- */
.f-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin: 14px 0 6px; letter-spacing: .04em; }
.f-input, .f-select, .f-textarea {
  width: 100%; padding: 10px 13px; font-size: 14px;
  border: 1.5px solid var(--sand-dark); border-radius: var(--radius-sm);
  font-family: var(--font-body); outline: none; background: var(--white); color: var(--ink);
  transition: border-color .15s ease;
}
.f-input:focus, .f-select:focus, .f-textarea:focus { border-color: var(--clay); }
.f-textarea { resize: vertical; min-height: 90px; }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.f-check { display: flex; align-items: center; gap: 9px; font-size: 14px; margin-top: 12px; cursor: pointer; }
.f-check input { width: 17px; height: 17px; accent-color: var(--clay); }
.f-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 4px; }
.f-inline { display: flex; gap: 8px; align-items: center; }
.f-inline .f-input { flex: 1; }

.btn-sm { padding: 9px 16px; font-size: 13px; border-radius: 10px; }
.btn-danger { background: #fdf0ee; color: #c0392b; border: 1.5px solid #e8c5c0; }
.btn-danger:hover { background: #c0392b; color: #fff; border-color: #c0392b; }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.dash-head h2 { font-family: var(--font-heading); font-size: 26px; color: var(--clay-deep); }

.site-rows { display: flex; flex-direction: column; gap: 12px; }
.site-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--cream); border: 1px solid var(--sand-dark);
  border-radius: var(--radius); padding: 16px 20px;
  box-shadow: var(--shadow-soft);
}
.site-row .thumb {
  width: 68px; height: 52px; border-radius: 10px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--clay), var(--gold)); overflow: hidden;
  display: grid; place-items: center; color: var(--cream); font-family: var(--font-heading); font-size: 22px;
}
.site-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.site-row .info { flex: 1; min-width: 0; }
.site-row .info b { display: block; font-size: 16px; color: var(--ink); }
.site-row .info small { font-size: 12.5px; color: var(--ink-faint); }
.site-row .tag {
  font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 600;
}
.tag.pub { background: #e5f3e9; color: #1e7c3c; }
.tag.hid { background: #f4e9e7; color: #a04030; }
.site-row .ops { display: flex; gap: 7px; }

/* ---------- Editor ---------- */
.editor-layout {
  display: grid; grid-template-columns: 440px 1fr; gap: 20px;
  height: calc(100vh - 62px - 52px);
  min-height: 520px;
}
.editor-form {
  background: var(--cream); border: 1px solid var(--sand-dark); border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column; overflow: hidden;
}
.editor-tabs { display: flex; border-bottom: 1px solid var(--sand-dark); background: var(--white); }
.editor-tabs button {
  flex: 1; padding: 13px 6px; border: none; background: none;
  font-size: 13px; font-weight: 600; color: var(--ink-faint);
  border-bottom: 2.5px solid transparent;
}
.editor-tabs button.on { color: var(--clay); border-bottom-color: var(--clay); }
.editor-body { flex: 1; overflow-y: auto; padding: 6px 20px 24px; }
.editor-body::-webkit-scrollbar { width: 8px; }
.editor-body::-webkit-scrollbar-thumb { background: var(--sand-dark); border-radius: 4px; }
.editor-foot {
  padding: 13px 20px; border-top: 1px solid var(--sand-dark);
  display: flex; gap: 10px; background: var(--white);
}
.editor-preview {
  border-radius: var(--radius); overflow: hidden; position: relative;
  border: 1px solid var(--sand-dark); box-shadow: var(--shadow-soft);
  background: #17100a;
}
.editor-preview iframe { width: 100%; height: 100%; border: none; }
.preview-badge {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  background: rgba(61,30,12,.6); color: var(--gold-soft); backdrop-filter: blur(6px);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px; pointer-events: none;
}

/* card con trong editor (tileset / hotspot) */
.sub-card {
  background: var(--white); border: 1px solid var(--sand-dark); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-top: 12px;
}
.sub-card-head { display: flex; align-items: center; gap: 10px; }
.sub-card-head .ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.sub-card-head b { flex: 1; font-size: 14px; color: var(--ink); word-break: break-all; }
.sub-card-head .mini {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--sand-dark);
  background: var(--cream); font-size: 13px; color: var(--ink-soft);
}
.sub-card-head .mini:hover { border-color: var(--clay); color: var(--clay); }
.sub-card .details { margin-top: 4px; }

.add-btn {
  width: 100%; margin-top: 14px; padding: 12px;
  border: 1.5px dashed var(--clay-light); border-radius: var(--radius-sm);
  background: rgba(180,85,45,.04); color: var(--clay-dark); font-size: 13.5px; font-weight: 600;
}
.add-btn:hover { background: rgba(180,85,45,.1); }

.pick-live {
  border: 1.5px solid var(--gold); background: rgba(201,151,47,.08);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px;
  font-size: 12.5px; color: var(--ink-soft); display: none;
}
.pick-live.on { display: block; animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { border-color: var(--clay); } }

/* ---------- Modal chung ---------- */
.a-modal {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(20,12,6,.55); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 18px;
}
.a-modal.open { display: flex; }
.a-modal-box {
  width: 100%; max-width: 560px; max-height: calc(100vh - 60px);
  background: var(--cream); border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
  display: flex; flex-direction: column; overflow: hidden;
  animation: mIn .2s ease;
}
@keyframes mIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.a-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--sand-dark);
}
.a-modal-head h3 { font-family: var(--font-heading); font-size: 18px; color: var(--clay-deep); }
.a-modal-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; }
.a-modal-foot { padding: 13px 20px; border-top: 1px solid var(--sand-dark); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- File browser ---------- */
.fb-bar { display: flex; gap: 8px; margin: 12px 0; align-items: center; flex-wrap: wrap; }
.fb-crumb { font-size: 13px; color: var(--ink-soft); flex: 1; word-break: break-all; }
.fb-crumb a { color: var(--clay); cursor: pointer; }
.fb-list { border: 1px solid var(--sand-dark); border-radius: var(--radius-sm); overflow: hidden; max-height: 330px; overflow-y: auto; background: var(--white); }
.fb-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 14px; border: none; border-bottom: 1px solid var(--sand);
  background: none; text-align: left; font-size: 13.5px; color: var(--ink);
}
.fb-item:hover { background: var(--sand); }
.fb-item .sz { margin-left: auto; font-size: 11.5px; color: var(--ink-faint); }
.fb-empty { padding: 22px; text-align: center; color: var(--ink-faint); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .editor-layout { grid-template-columns: 1fr; height: auto; }
  .editor-preview { height: 420px; order: -1; }
  .editor-form { max-height: none; }
  .editor-body { max-height: 60vh; }
}
@media (max-width: 640px) {
  .site-row { flex-wrap: wrap; }
  .site-row .ops { width: 100%; justify-content: flex-end; }
  .f-row, .f-row3 { grid-template-columns: 1fr; }
  .a-header h1 small { display: none; }
}
