/* admin.css — giao diện trang quản trị (chạy trên trình duyệt hiện đại của
   quản trị viên, KHÔNG phải khung IE11 của launcher — nên dùng CSS mới thoải mái). */

:root {
    --bg:      #14100c;
    --panel:   #1e1811;
    --panel2:  #262019;
    --line:    #3b3125;
    --gold:    #e0b354;
    --gold-dk: #8a6a34;
    --text:    #ece3d2;
    --muted:   #9b8e7a;
    --red:     #d15448;
    --green:   #59a06a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 "Segoe UI", Roboto, Tahoma, sans-serif;
}

code { font-family: Consolas, monospace; font-size: 12px; color: var(--gold); }
h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 15px; margin: 0; letter-spacing: .3px; }
.muted { color: var(--muted); font-weight: normal; }

/* ------------------------------------------------ màn hình đăng nhập/cài đặt */
.gate {
    max-width: 380px;
    margin: 12vh auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 26px 28px 30px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
.gate p { margin: 0 0 16px; font-size: 13px; }
.gate label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.gate input { margin-top: 6px; }
.gate .btn { width: 100%; }

input[type=text], input[type=password], input[type=number], input[type=date], select {
    width: 100%;
    padding: 8px 10px;
    background: #100d09;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
}
input:focus, select:focus { outline: none; border-color: var(--gold-dk); box-shadow: 0 0 0 2px rgba(224, 179, 84, .15); }
input.warn { border-color: var(--red); }

/* ------------------------------------------------------------------- nút */
.btn {
    padding: 8px 14px;
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover  { border-color: var(--gold-dk); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: #8a2f22; border-color: #b4503c; color: #fff; font-weight: 600; }
.btn.primary:hover { background: #a33a2a; }
.btn.ghost  { background: none; color: var(--muted); }
.btn.small  { padding: 5px 10px; font-size: 12px; }
.btn.icon   { padding: 4px 8px; font-size: 12px; background: none; color: var(--muted); }
.btn.icon:hover { color: var(--gold); }
.btn.del:hover  { color: var(--red); border-color: var(--red); }
.inline { display: inline; }

/* ---------------------------------------------------------------- thông báo */
.msg { padding: 9px 12px; border-radius: 5px; font-size: 13px; margin-bottom: 14px; }
.msg.err  { background: rgba(209, 84, 72, .13); border: 1px solid rgba(209, 84, 72, .5); color: #f0b3ab; }
.msg.good { background: rgba(89, 160, 106, .13); border: 1px solid rgba(89, 160, 106, .5); color: #b9e0c2; }
.msg.bar  { margin: 0; border-radius: 0; }

/* -------------------------------------------------------------- thanh trên */
#top {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { font-weight: 700; letter-spacing: .3px; color: var(--gold); }
.status { flex: 1; font-size: 12px; color: var(--muted); }
.status b { color: var(--text); font-weight: 600; }
.status .dirty { color: var(--gold); }
.acts { display: flex; gap: 8px; align-items: center; }

/* ------------------------------------------------------------- bố cục 2 cột */
#wrap {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 16px;
    max-width: 1360px;
    margin: 0 auto;
}
#editor { flex: 1; min-width: 0; }
#side   { width: 452px; flex: none; position: sticky; top: 64px; }

/* --------------------------------------------------------------- tab trái */
#tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tb {
    padding: 9px 16px;
    background: none;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    margin-bottom: -1px;
}
.tb:hover { color: var(--text); }
.tb.on { background: var(--panel); border-color: var(--line); color: var(--gold); font-weight: 600; }

.pane { display: none; }
.pane.on { display: block; }
.paneHead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.paneHead h2 { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 14px; line-height: 1.6; }
.hint b { color: var(--gold); }

.inlineField { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.inlineField input { width: 90px; }
#p-misc .inlineField { display: flex; }
#p-misc .inlineField input { width: 320px; }

.infoBox {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.8;
}

/* ------------------------------------------------------------ danh sách hàng */
.rows { display: flex; flex-direction: column; gap: 8px; }

.row {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.row.dragging { opacity: .4; }
.row.over     { border-color: var(--gold); }
.row.off      { opacity: .55; }
.row.hidden-row { border-style: dashed; border-color: #5c3a34; }

.grab { cursor: grab; color: var(--muted); user-select: none; padding-top: 6px; letter-spacing: 2px; }
.grab:active { cursor: grabbing; }

.num {
    width: 24px; height: 24px; flex: none;
    margin-top: 3px;
    border-radius: 50%;
    background: var(--panel2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    display: flex; align-items: center; justify-content: center;
}
.row.hidden-row .num { background: #3a231f; border-color: #6b3b33; color: #e0a094; }

.fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.fieldRow { display: flex; gap: 8px; align-items: center; }
.fieldRow > input[type=text] { flex: 1; min-width: 0; }
.fieldRow .lbl { font-size: 12px; color: var(--muted); flex: none; }
.fieldRow input[type=date] { width: 150px; flex: none; }
.rowActs { display: flex; flex-direction: column; gap: 2px; }

.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.chk input { accent-color: var(--gold); }

.counter { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.counter.bad { color: var(--red); font-weight: 600; }

.styleSel { width: 120px; flex: none; }

.cutLine {
    display: flex; align-items: center; gap: 10px;
    margin: 4px 0 2px;
    font-size: 11px; color: #e0a094;
}
.cutLine::before, .cutLine::after { content: ""; flex: 1; height: 1px; background: #5c3a34; }

.empty { color: var(--muted); font-size: 13px; padding: 18px; text-align: center;
         border: 1px dashed var(--line); border-radius: 8px; }

/* ------------------------------------------------------------ thanh đo tab */
.gauge { position: relative; height: 22px; background: #100d09; border: 1px solid var(--line);
         border-radius: 5px; margin-bottom: 14px; overflow: hidden; }
.gauge i { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(89, 160, 106, .35); }
.gauge.bad i { background: rgba(209, 84, 72, .4); }
.gauge span { position: absolute; left: 8px; top: 0; line-height: 20px; font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- xem trước */
.sideHead { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--gold); }
.frameWrap {
    width: 428px; padding: 8px;
    background: #0b0906;
    border: 1px solid var(--line);
    border-radius: 8px;
}
#preview { width: 505px; height: 317px; border: 0; display: block; background: #100c08; }

.warns { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.warns div {
    font-size: 12px; line-height: 1.5;
    padding: 8px 10px;
    background: rgba(224, 179, 84, .1);
    border-left: 3px solid var(--gold-dk);
    border-radius: 0 4px 4px 0;
    color: #e3d4b4;
}

/* --------------------------------------------------------------- hộp thoại */
.modal { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; }
.modal.on { display: flex; align-items: center; justify-content: center; }
.modalBox { width: 360px; background: var(--panel); border: 1px solid var(--line);
            border-radius: 10px; padding: 22px 24px; }
.modalBox label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.modalBox input { margin-top: 6px; }
.modalActs { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ------------------------------------------------------------------- toast */
#toast {
    position: fixed; right: 18px; bottom: 18px; z-index: 60;
    display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
#toast div {
    padding: 10px 16px; border-radius: 6px; font-size: 13px;
    background: #2b2419; border: 1px solid var(--gold-dk); color: var(--text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    animation: pop .18s ease-out;
}
#toast div.err  { border-color: var(--red); color: #f0b3ab; }
#toast div.good { border-color: var(--green); color: #b9e0c2; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
    #wrap { flex-direction: column-reverse; }
    #side { position: static; width: 100%; }
}
