/* src/css/cloud.css – đăng nhập & lá số đã lưu (sidebar desktop) */
.cloud-panel {
    margin: 0 0 12px;
    padding: 10px 12px;
    background: var(--ui-side-the);
    border: 1px solid var(--ui-side-line);
    border-radius: 10px;
    font: 12px/1.45 Arial, sans-serif;
    color: var(--ui-side-fg);
  }
  .cl-head { font-size: 10px; font-weight: bold; letter-spacing: .5px; text-transform: uppercase; color: var(--ui-side-fg-2); margin-bottom: 6px; }
  .cl-hint { color: var(--ui-side-fg-2); margin-bottom: 8px; }
  .cl-btns { display: flex; gap: 6px; flex-wrap: wrap; }
  .cl-btn {
    flex: 1 1 auto; padding: 6px 10px;
    border: 1px solid var(--ui-side-pri); border-radius: 8px;
    background: var(--ui-side-pri); color: var(--ui-side-on-pri);
    font: bold 12px Arial, sans-serif; cursor: pointer;
  }
  .cl-btn:hover { background: var(--ui-side-pri-h); }
  .cl-btn-2 { background: transparent; color: var(--ui-side-fg); }
  .cl-btn-2:hover { background: var(--ui-side-hover); }
  .cl-user { display: flex; align-items: center; gap: 8px; }
  .cl-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold; }
  .cl-link { border: 0; background: none; padding: 0; color: var(--ui-side-pri); text-decoration: underline; cursor: pointer; font: inherit; }
  .cl-warn { margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: #fff6e0; color: #7a5c2a; }
  
  
  /* Hộp đăng nhập email (dùng chung khung .rc-overlay/.rc-box của hộp "Tải lại trang"); màu theo theme (--ui-side-*) */
  .cl-dialog { width: min(400px, 100%); padding: 22px 22px 16px; }
  .cl-dialog .cl-tabs { display: flex; gap: 4px; margin-bottom: 16px; padding: 4px; border: 1px solid var(--ui-side-line); border-radius: 12px; background: var(--ui-side-in); }
  .cl-dialog .cl-tabs button {
    flex: 1; height: 34px; padding: 0 4px; border: 0; border-radius: 9px;
    background: transparent; color: var(--ui-side-fg-2); font: 600 13px Arial, sans-serif; cursor: pointer;
  }
  .cl-dialog .cl-tabs button.on { background: var(--ui-side-the); color: var(--ui-side-fg); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .18), inset 0 0 0 1px var(--ui-side-line); }
  .cl-dialog .cl-field { display: block; margin-bottom: 12px; font: 600 12px Arial, sans-serif; color: var(--ui-side-fg-2); }
  .cl-dialog .cl-field input {
    display: block; width: 100%; box-sizing: border-box; height: 42px; margin-top: 5px; padding: 0 12px;
    border: 1px solid var(--ui-side-line); border-radius: 10px; background: var(--ui-side-in);
    font: 14px Arial, sans-serif; color: var(--ui-side-fg);
  }
  .cl-dialog .cl-field input:focus { outline: 2px solid var(--ui-side-pri); outline-offset: 1px; }
  .cl-dialog .cl-msg { min-height: 18px; color: #e5533d; font-size: 12.5px; }
  .cl-dialog .cl-msg.ok { color: var(--ui-ok, #2e8b57); }
  .cl-dialog .rc-actions { margin-top: 10px; }
  .cl-dialog .rc-ok {                                    /* như nút "Lập lá số": nền tối, chữ vàng (không chữ trắng trên nền nâu) */
    border: 0; background: linear-gradient(180deg, #2b2016, #16100a); color: #f6dfa6;
    box-shadow: inset 0 0 0 1px rgba(246, 223, 166, .3);
  }
  .cl-dialog .rc-ok:hover { filter: brightness(1.15); }
  .cl-dialog .rc-ok:disabled { opacity: .6; cursor: wait; }
  
  .cl-toast {
    position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
    z-index: 10001; max-width: min(460px, 92vw);
    padding: 8px 14px; border-radius: 8px;
    background: #1c2834; color: #fff; font: 13px/1.4 Arial, sans-serif;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
  }
  
  /* ── Danh sách lá số đã lưu ─────────────────────────────────── */
  .cl-search {
    display: block; width: 100%; box-sizing: border-box;
    margin: 8px 0 6px; padding: 6px 9px;
    border: 1px solid var(--ui-side-line); border-radius: 8px; background: var(--ui-side-in);
    font: 12px Arial, sans-serif; color: var(--ui-side-fg);
  }
  .cl-search:focus { outline: none; border-color: var(--ui-side-pri); }
  .cl-items { max-height: 320px; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; }
  .cl-item {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 6px; border-radius: 6px; cursor: pointer;
  }
  .cl-item:hover { background: var(--ui-side-hover); }
  .cl-item.active { background: var(--ui-side-pri); color: var(--ui-side-on-pri); }
  .cl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cl-gt, .cl-year { color: var(--ui-side-fg-2); font-variant-numeric: tabular-nums; }
  .cl-gt { flex: 0 0 2.6em; text-align: center; }               /* cột giới tính, rộng cố định cho thẳng hàng */
  .cl-item.active .cl-gt, .cl-item.active .cl-year { color: var(--ui-side-on-pri); opacity: .8; }
  .cl-dirty { color: #e67e22; font-size: 10px; }
  .cl-del {
    border: 0; background: none; padding: 0 2px; cursor: pointer;
    font-size: 13px; opacity: 0; transition: opacity .1s;
  }
  .cl-item:hover .cl-del, .cl-item.active .cl-del { opacity: .7; }
  .cl-del:hover { opacity: 1 !important; }
  .cl-empty { padding: 6px 4px; color: var(--ui-side-fg-2); font-style: italic; }
  .cl-group {
    position: sticky; top: 0; z-index: 1;
    display: flex; align-items: center; gap: 6px;
    margin: 6px 0 2px; padding: 4px 6px;
    background: var(--ui-side-tab); border-radius: 6px; cursor: pointer; user-select: none;
    font-size: 10px; font-weight: bold; letter-spacing: .5px; text-transform: uppercase; color: var(--ui-side-fg-2);
  }
  .cl-group:hover { background: var(--ui-side-hover); }
  .cl-group:first-child { margin-top: 0; }
  .cl-group svg { flex: 0 0 auto; transition: transform .15s ease; }
  .cl-group.dong svg { transform: rotate(-90deg); }
  .cl-group span { margin-left: auto; font-weight: normal; letter-spacing: 0; }
  
  /* Popup hỏi (lưu / cập nhật / xóa) */
  .cl-ask { width: min(440px, 92vw); }
  .cl-ask .rc-actions { flex-wrap: wrap; }
  .cl-ask .cl-ok { border-color: #1f4e79; background: #1f4e79; }
  .cl-ask .cl-ok:hover { background: #163a5c; }
  
  /* Nút Lưu lá số (dưới nút Lập lá số) */
  #formWrap .fg-save-laso { grid-column: 1 / -1; }
  #formWrap .fg-save-laso .btn { width: 100%; background: transparent; color: var(--ui-side-fg); border: 1px solid var(--ui-side-fg-2); }
  #formWrap .fg-save-laso .btn:hover { background: var(--ui-side-hover); }
  /* body[data-layout="mobile"] .fg-save-laso { display: none; } */
  
  /* ── Ảnh của lá số (dải ảnh cuối cột note + ảnh trong note) ──── */
  .note-editor img.note-img { max-width: 100%; height: auto; border-radius: 4px; margin: 4px 0; display: block; }
  .note-editor img.note-img:not([src]) { display: inline-block; padding: 2px 6px; border: 1px dashed #c8b88a; color: #999; font-size: 11px; }
  .note-gallery {
    flex: 0 0 auto;
    border-top: 1px solid #f0f1f3;
    background: #fafbfc;
    padding: 8px 12px 10px;
  }
  .ng-head { display: flex; align-items: center; gap: 6px; font: 500 12px Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; color: #6b7280; margin-bottom: 6px; }
  .ng-head span { flex: 1; }
  .ng-add { height: 26px; padding: 0 10px; border: 1px solid #e5e7eb; border-radius: 7px; background: #fff; color: #374151; font: 500 12px Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; cursor: pointer; }
  .ng-add:hover:not(:disabled) { background: #f3f4f6; border-color: #d1d5db; } 
  .ng-add:disabled { opacity: .5; cursor: not-allowed; }
  .ng-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
  .ng-item {
    position: relative; flex: 0 0 auto;
    width: 64px; height: 64px;
    border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; background: #fff; cursor: zoom-in;
  }
  .ng-item.new { border-color: #f59e0b; }                       /* ảnh chưa lưu */
  .ng-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .ng-btn {
    position: absolute; top: 2px; width: 18px; height: 18px; padding: 0;
    border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff;
    font: 11px/18px Arial, sans-serif; cursor: pointer; opacity: 0; transition: opacity .1s;
  }
  .ng-item:hover .ng-btn { opacity: 1; }
  .ng-ins { left: 2px; }
  .ng-del { right: 2px; }
  .ng-empty { font: italic 12px Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; color: #9ca3af; padding: 2px 0; }
  .cl-lightbox {
    position: fixed; inset: 0; z-index: 10002;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .8); cursor: zoom-out;
  }
  .cl-lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 4px; background: #fff; }



  /* Sidebar desktop: form cao theo nội dung, khối "Lá số đã lưu" chiếm phần còn lại */
body[data-layout="desktop"] #formArea { flex: 0 0 auto; }
body[data-layout="desktop"] #cloudPanel:not(:empty) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 160px;
}
body[data-layout="desktop"] #cloudPanel #cloudList {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
body[data-layout="desktop"] #cloudPanel .cl-items { flex: 1 1 auto; max-height: none; min-height: 0; }


/* Sidebar desktop: vùng form cao vừa nội dung, không cuộn riêng */
body[data-layout="desktop"] #formArea,
body[data-layout="desktop"] #formArea #formAreaLaso {
  flex: 0 0 auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}
body[data-layout="desktop"] #formArea #formWrap,
body[data-layout="desktop"] #formArea #searchPanel,
body[data-layout="desktop"] #formArea #cfgPanel {
  flex: none !important;
  overflow: visible !important;
}


/* ── Desktop: thu gọn tạm 1 trong 2 khung (side-fold.js) ───────── */
.side-fold-btn {
  flex: 0 0 26px; width: 26px; height: 26px; margin-left: auto; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; align-self: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--ui-side-fg-2); cursor: pointer;
}
.side-fold-btn:hover { background: var(--ui-side-hover); color: var(--ui-side-fg); }
.side-fold-btn svg { transition: transform .15s ease; }
body.fold-form .side-fold-btn[data-fold="form"] svg,
body.fold-cloud .side-fold-btn[data-fold="cloud"] svg { transform: rotate(-90deg); }
#cloudPanel [data-fold-head] { display: flex; align-items: center; cursor: pointer; user-select: none; }
body[data-layout="mobile"] .side-fold-btn { display: none; }

body[data-layout="desktop"].fold-form #formArea .tab-bar ~ * { display: none !important; }
body[data-layout="desktop"].fold-cloud #cloudPanel [data-fold-head] ~ * { display: none !important; }
body[data-layout="desktop"].fold-cloud #cloudPanel:not(:empty) { flex: 0 0 auto; min-height: 0; }
body[data-layout="desktop"].fold-cloud #formArea {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

/* ── Tìm kiếm mở rộng, sắp xếp, phím mũi tên ─────────────────── */
.cl-row { display: flex; gap: 6px; margin-top: 6px; }
.cl-row .cl-search { flex: 1 1 auto; min-width: 0; margin: 0; }
.cl-row select {
    flex: 1 1 0; min-width: 0;
    height: 28px; box-sizing: border-box;
    padding: 0 22px 0 8px;
    border: 1px solid var(--ui-side-line); border-radius: 8px;
    background: var(--ui-side-in) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235b6b7c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    font: 12px Arial, sans-serif; color: var(--ui-side-fg);
    text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
    cursor: pointer;
  }
  .cl-row select:hover { border-color: var(--ui-side-fg-2); }
  .cl-row select:focus { outline: none; border-color: var(--ui-side-pri); }
  .cl-row .cl-sort { flex: 0 0 auto; max-width: 130px; }
  .cl-row .cl-search { height: 28px; padding: 0 9px; }
.cl-count { margin: 6px 2px 2px; font-size: 11px; color: var(--ui-side-fg-2); }
.cl-tim-note { padding: 0; border: 0; background: none; color: var(--ui-side-pri); font: inherit; text-decoration: underline; cursor: pointer; }
.cl-tim-note:hover { color: var(--ui-side-pri-h); }
.cl-items:focus { outline: none; }
.cl-items:focus .cl-item.cursor { box-shadow: inset 0 0 0 2px #e67e22; }
.cl-item.cursor { box-shadow: inset 0 0 0 1px var(--ui-side-line); }
.cl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cl-snip { font-size: 11px; color: var(--ui-side-fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-item.active .cl-snip { color: var(--ui-side-on-pri); opacity: .8; }
.cl-snip mark { background: #fff3a0; color: inherit; padding: 0 1px; border-radius: 2px; }
.cl-item.active .cl-snip mark { background: #f5c542; color: #1c2834; }

.cl-export.ui-btn-row { margin-top: 8px; display: grid; grid-template-columns: 1fr 1fr; }
.cl-export > [data-xuat="nhap"] { grid-column: 1 / -1; }
.cl-nhap-ds { max-height: 40vh; overflow: auto; margin: 4px 0 0; padding-left: 18px; }
body[data-layout="mobile"] .cl-export.ui-btn-row { display: none; }


/* ── Xóa lá số: hộp xác nhận + thông báo "Hoàn tác" ─────────── */
.cl-ask .cl-danger { border-color: #c0392b; background: #c0392b; color: #fff; }
.cl-ask .cl-danger:hover { background: #a93226; }
.cl-del-name { font-size: 14px; }
.cl-del-meta { margin-top: 2px; color: #5b6b7c; font-size: 12px; }
.cl-del-note { margin-top: 8px; color: #5b6b7c; font-size: 12px; }
.cl-toast-undo {
  display: flex; align-items: center; gap: 12px;
  width: min(380px, 92vw); box-sizing: border-box;
  padding: 8px 8px 8px 14px; overflow: hidden;
}
.cl-toast-undo span { flex: 1; min-width: 0; }
.cl-toast-undo button {
  flex: 0 0 auto; padding: 5px 12px;
  border: 1px solid #f5c542; border-radius: 6px;
  background: transparent; color: #f5c542;
  font: bold 13px Arial, sans-serif; cursor: pointer;
}
.cl-toast-undo button:hover { background: rgba(245, 197, 66, .15); }
.cl-toast-undo i {                                  /* vạch đếm ngược */
  position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background: #f5c542; transform-origin: left;
  animation: clUndoBar linear forwards;
}
@keyframes clUndoBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }


/* ── Khung hộp thoại dùng chung (không phụ thuộc note.css, chạy cả mobile); màu theo theme (--ui-side-*) ── */
.rc-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; box-sizing: border-box;
  background: rgba(0, 0, 0, .5);
}
.rc-box {
  width: min(380px, 100%); max-height: calc(100% - 32px); overflow-y: auto;
  box-sizing: border-box; padding: 20px 22px 16px;
  background: var(--ui-side); border: 1px solid var(--ui-side-line); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
  font: 13px/1.5 Arial, sans-serif; color: var(--ui-side-fg); text-align: left;
}
.rc-title { margin-bottom: 8px; font: 700 17px 'Playfair Display', Georgia, serif; color: var(--ui-side-fg); }
.rc-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.rc-actions button { padding: 8px 18px; border-radius: 10px; cursor: pointer; font: bold 13px Arial, sans-serif; }
.rc-cancel { border: 1px solid var(--ui-side-line); background: var(--ui-side-in); color: var(--ui-side-fg); }
.rc-ok { border: 1px solid #c0392b; background: #c0392b; color: #fff; }
.cl-ask { width: min(440px, 100%); }
  

.cl-del-meta { margin-top: 2px; color: var(--ui-side-fg-2); font-size: 12px; }
.cl-del-note { margin-top: 8px; color: var(--ui-side-fg-2); font-size: 12px; }
  /* Mobile: nút to hơn, dễ chạm */
  body[data-layout="mobile"] .rc-box { font-size: 14px; }
  body[data-layout="mobile"] .rc-actions button { padding: 10px 18px; font-size: 15px; }

  /* Ô Họ tên còn trống khi bấm Lưu */
#hoTen.cl-missing {
    border-color: #c0392b !important;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, .25) !important;
    background: #fff6f5 !important;
  }



  /* ── Desktop: tab Tìm lá số / Cấu hình → vùng form cuộn riêng, ẩn "Lá số đã lưu" ── */
body[data-layout="desktop"]:has(#tabSEARCH.tab-active, #tabCFG.tab-active) #cloudPanel {
    display: none !important;
  }
  body[data-layout="desktop"]:has(#tabSEARCH.tab-active, #tabCFG.tab-active) #formArea {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    padding-bottom: 56px !important;      /* chừa chỗ cho các nút ⇤ ✎ ⚙ ở góc dưới */
    box-sizing: border-box;
  }