/* ═══════════════════════════════════════════════════
   AnhNBT Copy History — Styles
   CSS variables fallback về theme anhnbt.com
═══════════════════════════════════════════════════ */
:root {
    --ach-ac:       var(--ac,       #d24b41);
    --ach-ac-light: var(--ac-light, #fdf1f0);
    --ach-ac-mid:   var(--ac-mid,   #f0c4c1);
    --ach-ac-dark:  var(--ac-dark,  #a8342b);
    --ach-bg:       var(--bg-box,   #f7f7f8);
    --ach-border:   var(--border,   #e2e2e6);
    --ach-text:     var(--text,     #1a1a1a);
    --ach-text-s:   var(--text-s,   #555);
    --ach-text-m:   var(--text-m,   #888);
    --ach-r:        var(--r,        6px);
}

/* ── FLOATING BADGE ───────────────────────────── */
.anhnbt-ch-badge {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 11px 13px 11px 11px;
    background: var(--ach-ac);
    color: #fff;
    border-radius: 10px 0 0 10px;
    box-shadow: -3px 3px 18px rgba(210,75,65,.25);
    text-decoration: none;
    font-family: inherit;
    font-size: .85em;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background .2s, transform .2s, box-shadow .2s;
}
.anhnbt-ch-badge:hover {
    background: var(--ach-ac-dark);
    transform: translateY(-50%) translateX(-3px);
    box-shadow: -5px 4px 24px rgba(210,75,65,.35);
    color: #fff;
    text-decoration: none;
}
.achb-icon { font-size: 1.15em; line-height: 1; flex-shrink: 0; }
.achb-text {
    font-size: .78em;
    letter-spacing: .3px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    line-height: 1.2;
}
.achb-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #fff;
    color: var(--ach-ac);
    border-radius: 10px;
    font-size: .72em;
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0;
}

/* Animations */
@keyframes achb-pulse {
    0%   { transform: translateY(-50%) scale(1); }
    40%  { transform: translateY(-50%) scale(1.07); }
    100% { transform: translateY(-50%) scale(1); }
}
.achb--pulse { animation: achb-pulse .5s ease-out; }

@keyframes achb-flash {
    0%   { background: var(--ach-ac); }
    35%  { background: #27ae60; }
    100% { background: var(--ach-ac); }
}
.achb--flash { animation: achb-flash 1.8s ease-out; }

/* Tip bubble */
.anhnbt-ch-tip {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1a1a1a;
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--ach-r);
    font-size: .82em;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 2px 10px rgba(0,0,0,.18);
    pointer-events: none;
    animation: ach-tip-in .2s ease;
}
.anhnbt-ch-tip::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right: none;
    border-left-color: #1a1a1a;
}
@keyframes ach-tip-in {
    from { opacity:0; transform: translateY(-50%) translateX(6px); }
    to   { opacity:1; transform: translateY(-50%) translateX(0);   }
}

/* ── TRANG LỊCH SỬ ────────────────────────────── */
.anhnbt-ch-page {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px 56px;
    font-family: inherit;
    color: var(--ach-text);
}

/* Header */
.ach-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.ach-page-title { display: flex; align-items: center; gap: 13px; }
.ach-page-icon  { font-size: 2em; line-height: 1; }
.ach-h2  { margin: 0 0 4px; font-size: 1.35em; font-weight: 800; color: var(--ach-text); }
.ach-sub { margin: 0; font-size: .83em; color: var(--ach-text-m); }

.ach-page-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ach-stat-badge {
    display: flex; align-items: baseline; gap: 4px;
    background: var(--ach-ac-light);
    border: 1px solid var(--ach-ac-mid);
    border-radius: var(--ach-r);
    padding: 7px 13px;
}
.ach-stat-badge span:first-child { font-size: 1.25em; font-weight: 800; color: var(--ach-ac); line-height: 1; }
.ach-stat-label { font-size: .78em; color: var(--ach-text-s); }

/* Toolbar */
.ach-toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.ach-search-wrap { flex: 1; min-width: 180px; position: relative; }
.ach-search-ico  { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: .9em; pointer-events: none; }
.ach-search-input {
    width: 100%; padding: 10px 13px 10px 36px;
    border: 1px solid var(--ach-border); border-radius: var(--ach-r);
    font-size: .93em; color: var(--ach-text); background: #fff;
    box-sizing: border-box; outline: none;
    transition: border-color .2s, box-shadow .2s;
    font-family: inherit;
}
.ach-search-input:focus { border-color: var(--ach-ac); box-shadow: 0 0 0 3px rgba(210,75,65,.1); }
.ach-sort-wrap  { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.ach-sort-label { font-size: .83em; color: var(--ach-text-s); white-space: nowrap; }
.ach-sort-select {
    padding: 9px 11px; border: 1px solid var(--ach-border); border-radius: var(--ach-r);
    font-size: .88em; color: var(--ach-text); background: #fff;
    cursor: pointer; outline: none; font-family: inherit;
}

/* Empty state */
.ach-empty {
    display: flex; flex-direction: column; align-items: center;
    gap: 10px; padding: 60px 24px; text-align: center;
}
.ach-empty-ico   { font-size: 2.6em; opacity: .5; }
.ach-empty-title { font-size: 1.05em; font-weight: 700; color: var(--ach-text); margin: 0; }
.ach-empty-sub   { font-size: .88em; color: var(--ach-text-m); margin: 0; }
.ach-empty-sub a { color: var(--ach-ac); text-decoration: underline; }

/* Card grid */
.ach-list { display: grid; grid-template-columns: 1fr; gap: 9px; }

.ach-card {
    display: flex;
    align-items: center;
    flex-wrap: wrap;          /* cho phép xuống dòng */
    gap: 10px 13px;
    background: #fff; border: 1px solid var(--ach-border);
    border-radius: var(--ach-r); padding: 12px 14px;
    transition: border-color .15s, box-shadow .15s, opacity .28s, transform .28s;
}
.ach-card:hover { border-color: var(--ach-ac-mid); box-shadow: 0 2px 8px rgba(0,0,0,.07); }
.ach-card--removing { opacity: 0; transform: translateX(20px); }

.ach-char-preview {
    min-width: 50px; height: 50px;
    background: var(--ach-ac-light); border: 1px solid var(--ach-ac-mid);
    border-radius: var(--ach-r);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.45em; line-height: 1;
    overflow: hidden; word-break: break-all; flex-shrink: 0;
    color: var(--ach-ac-dark);
}

.ach-card-info  { flex: 1; min-width: 0; }
.ach-card-label {
    font-weight: 600; font-size: .93em; color: var(--ach-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 4px;
}
.ach-card-meta  { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: .78em; color: var(--ach-text-m); }
.ach-page-link  {
    color: var(--ach-ac); text-decoration: none;
    max-width: 200px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; display: inline-block; vertical-align: bottom;
}
.ach-page-link:hover { text-decoration: underline; }

/* Actions — hàng riêng khi wrap */
.ach-card-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    width: 100%;                /* luôn full width → xuống hàng riêng */
    justify-content: flex-end;
    border-top: 1px solid var(--ach-border);
    padding-top: 9px;
    margin-top: 2px;
}

/* Buttons */
.ach-btn-copy {
    background: var(--ach-ac); border: none; border-radius: var(--ach-r);
    padding: 7px 13px; color: #fff; font-size: .82em; font-weight: 700;
    cursor: pointer; white-space: nowrap; font-family: inherit;
    transition: background .15s, transform .1s;
}
.ach-btn-copy:hover  { background: var(--ach-ac-dark); }
.ach-btn-copy:active { transform: scale(.97); }
.ach-btn-copy--done  { background: #27ae60 !important; }

.ach-btn-del {
    background: transparent; border: 1px solid var(--ach-border); border-radius: var(--ach-r);
    width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
    color: var(--ach-text-m); font-size: .85em; cursor: pointer; font-family: inherit;
    transition: border-color .15s, color .15s, background .15s;
}
.ach-btn-del:hover { border-color: #e74c3c; color: #e74c3c; background: #fff5f5; }

.ach-btn-danger {
    background: transparent; border: 1px solid var(--ach-border); border-radius: var(--ach-r);
    padding: 8px 13px; color: var(--ach-text-s); font-size: .83em; font-weight: 600;
    cursor: pointer; white-space: nowrap; font-family: inherit;
    transition: border-color .15s, color .15s, background .15s;
}
.ach-btn-danger:hover { border-color: #e74c3c; color: #e74c3c; background: #fff5f5; }

.ach-btn-ghost {
    background: transparent; border: 1px solid var(--ach-border); border-radius: var(--ach-r);
    padding: 11px 18px; color: var(--ach-text-s); font-size: .93em; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: background .15s;
}
.ach-btn-ghost:hover { background: var(--ach-bg); }

.ach-btn-danger-fill {
    background: #e74c3c; border: 1px solid #e74c3c; border-radius: var(--ach-r);
    padding: 11px 18px; color: #fff; font-size: .93em; font-weight: 700;
    cursor: pointer; font-family: inherit; transition: background .15s;
}
.ach-btn-danger-fill:hover { background: #c0392b; border-color: #c0392b; }

/* Pagination */
.ach-pagination { display: flex; justify-content: center; align-items: center; gap: 5px; margin-top: 22px; flex-wrap: wrap; }
.ach-pg-btn {
    min-width: 36px; height: 36px; padding: 0 11px;
    background: #fff; border: 1px solid var(--ach-border); border-radius: var(--ach-r);
    font-size: .88em; font-weight: 600; cursor: pointer; color: var(--ach-text); font-family: inherit;
    transition: border-color .15s, color .15s;
}
.ach-pg-btn:hover:not(:disabled) { border-color: var(--ach-ac); color: var(--ach-ac); }
.ach-pg-btn:disabled  { opacity: .38; cursor: default; }
.ach-pg-active        { background: var(--ach-ac); border-color: var(--ach-ac); color: #fff; pointer-events: none; }
.ach-pg-ellipsis      { color: var(--ach-text-m); padding: 0 3px; }

/* Modal */
.ach-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.48); z-index: 999999;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    backdrop-filter: blur(3px);
    animation: ach-overlay-in .18s ease;
}
@keyframes ach-overlay-in { from { opacity: 0; } to { opacity: 1; } }

.ach-modal {
    background: #fff; border-radius: 10px; padding: 26px 26px 22px;
    max-width: 360px; width: 100%; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    animation: ach-modal-in .18s ease;
}
@keyframes ach-modal-in { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ach-modal-ico   { font-size: 2.4em; margin-bottom: 10px; }
.ach-modal-title { margin: 0 0 7px; font-size: 1.1em; font-weight: 800; color: var(--ach-text); }
.ach-modal-sub   { margin: 0 0 20px; font-size: .88em; color: var(--ach-text-s); line-height: 1.6; }
.ach-modal-btns  { display: flex; gap: 9px; }
.ach-modal-btns .ach-btn-ghost,
.ach-modal-btns .ach-btn-danger-fill { flex: 1; }

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 600px) {
    .anhnbt-ch-badge {
        bottom: 72px; top: auto; right: 0;
        transform: none; border-radius: 8px 0 0 8px;
        padding: 9px 11px;
    }
    .anhnbt-ch-badge:hover { transform: translateX(-3px); }
    .achb-text { writing-mode: horizontal-tb; transform: none; font-size: .74em; }

    .ach-page-header  { flex-direction: column; gap: 10px; }
    .ach-page-actions { width: 100%; justify-content: space-between; }

    /* Card: preview nhỏ hơn chút, label cho phép xuống dòng */
    .ach-char-preview { min-width: 44px; height: 44px; font-size: 1.15em; }
    .ach-card-label   { white-space: normal; word-break: break-word; }
    .ach-page-link    { max-width: 100%; }

    /* Actions hàng dưới: nút copy chiếm hết, nút xoá nhỏ bên phải */
    .ach-card-actions { justify-content: space-between; }
    .ach-btn-copy     { flex: 1; text-align: center; font-size: .85em; }
}
