/**
 * Inkstone
 * Location: /assets/css/inkstone.css
 * Description: Giao diện Inkstone 3.0 — tổng quan tác giả, danh sách dự án, form truyện, trang quản lý chương,
 *              tab Thu nhập. Chỉ nạp ở trang dùng template Inkstone (core/inkstone-utils.php).
 *              Dựng trên component UIkit nên chế độ tối (.uk-light) tự ăn theo; phần riêng dùng
 *              currentColor / rgba để không phải khai màu 2 lần.
 * Version: 1.0.0 (Init Manga 4.0.2)
 */

.ink {
    --ink-line: rgba(0, 0, 0, .09);
    --ink-soft: rgba(0, 0, 0, .04);
    --ink-gap: 12px;
}

.uk-light .ink,
.uk-light .ink-modal {
    --ink-line: rgba(255, 255, 255, .14);
    --ink-soft: rgba(255, 255, 255, .06);
}

.ink-modal {
    --ink-line: rgba(0, 0, 0, .09);
    --ink-soft: rgba(0, 0, 0, .04);
}

.ink-gap {
    gap: var(--ink-gap, 12px);
}

.ink-gap-small {
    gap: 8px;
}

.ink-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Nhãn trung tính (Nháp / Riêng tư) */
.ink .uk-label {
    line-height: 20px;
    font-size: 11px;
    white-space: nowrap;
}

.ink .ink-label-muted {
    background: var(--ink-soft);
    color: inherit;
    box-shadow: inset 0 0 0 1px var(--ink-line);
}

/* Số đếm nhỏ cạnh tiêu đề / bộ lọc */
.ink-count {
    display: inline-block;
    min-width: 20px;
    margin-left: 4px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--ink-soft);
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    vertical-align: middle;
}

.ink-count:empty {
    display: none;
}

.ink-icon-button {
    width: 30px;
    height: 30px;
    flex: none;
}

/*==============================
=           Tổng quan          =
==============================*/

.ink-stat {
    border: 1px solid var(--ink-line);
    min-width: 0;
}

.ink-stat-label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.ink-stat-label > .uk-icon {
    flex: none;
}

.ink-stat-text {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ink-stat-value {
    margin-top: 4px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ink-stat-sub {
    margin-top: 2px;
    line-height: 1.35;
}

.ink-stat-link {
    display: block;
    transition: border-color .15s ease-in-out;
}

.ink-stat-link:hover {
    border-color: var(--im-theme-color, #1e87f0);
}

/*==============================
=        Danh sách dự án       =
==============================*/

.ink-filters {
    gap: 6px;
}

.ink-filters > * {
    padding-left: 0;
}

.ink-filters > * > a {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    text-transform: none;
}

.ink-filters > .uk-active .ink-count {
    background: rgba(255, 255, 255, .25);
}

.ink-search-input {
    width: 200px;
}

.ink-search .ink-sort {
    width: auto;
    min-width: 150px;
}

.ink-project {
    border: 1px solid var(--ink-line);
    padding: 12px;
}

.ink-project-inner {
    display: flex;
    gap: 14px;
    min-width: 0;
}

.ink-project-cover {
    display: block;
    flex: none;
    width: 104px;
    align-self: flex-start;
}

.ink-project-cover > a,
.ink-project-cover img {
    display: block;
    width: 100%;
}

.ink-project-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.ink-project-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ink-project-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
}

.ink-project-stats li {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.ink-project-actions {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 6px;
}

.ink-empty {
    border: 1px dashed var(--ink-line);
    border-radius: 8px;
}

/*==============================
=          Form truyện         =
==============================*/

.ink-modal {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.ink-modal > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ink-modal .uk-modal-header,
.ink-modal .uk-modal-footer {
    background: transparent;
}

.ink-modal .uk-modal-header {
    padding-right: 56px;
    border-bottom: 1px solid var(--ink-line);
}

.ink-modal .uk-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--ink-line);
}

.ink-modal .uk-modal-title {
    margin: 0;
    font-size: 1.35rem;
}

.ink-form-basics {
    display: flex;
    gap: 20px;
}

.ink-cover-field {
    flex: none;
    width: 168px;
}

.ink-form-main {
    flex: 1;
    min-width: 0;
}

.ink-cover-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border: 1px dashed var(--ink-line);
    background: var(--ink-soft);
    cursor: pointer;
    transition: border-color .15s ease-in-out;
}

.ink-cover-preview:hover,
.ink-cover-field input:focus-visible + .uk-text-meta,
.ink-cover-field:focus-within .ink-cover-preview {
    border-color: var(--im-theme-color, #1e87f0);
}

.ink-cover-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ink-cover-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px;
    font-size: 13px;
    text-align: center;
    opacity: .7;
}

/* Đã có ảnh: chữ "Đổi ảnh" nằm đè phía dưới */
.ink-cover-preview.has-image .ink-cover-placeholder {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    flex-direction: row;
    justify-content: center;
    padding: 6px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    opacity: 1;
}

.ink-cover-preview.has-image .ink-cover-placeholder .uk-icon {
    display: none;
}

.ink-form-heading {
    margin: 22px 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    opacity: .65;
}

.ink-form-more .uk-accordion-title.ink-form-heading {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-family: inherit;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
}

.ink-form-more .uk-accordion-title.ink-form-heading::after {
    content: "+";
    float: right;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
}

.ink-form-more .uk-open > .uk-accordion-title.ink-form-heading::after {
    content: "\2212";
}

.ink-form-more .uk-accordion-content {
    margin-top: 12px;
}

.ink-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ink-options label {
    cursor: pointer;
}

/* Thể loại / nhà xuất bản: nhãn bấm thay cho <select multiple> */
select.ink-chips-source {
    display: none !important;
}

.ink-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 148px;
    padding: 8px;
    overflow-y: auto;
    margin-bottom: 10px;
    border: 1px solid var(--ink-line);
    border-radius: 6px;
}

/* UIkit đặt margin: 0 cho .uk-input và nạp sau file này → cần độ ưu tiên cao hơn */
.ink-modal input.ink-chips-filter {
    margin-bottom: 10px;
}

/* Thanh cuộn mảnh cho thân modal và khung chọn thể loại */
.ink-modal-body,
.ink-chips {
    scrollbar-width: thin;
    scrollbar-color: var(--ink-line) transparent;
}

.ink-modal-body::-webkit-scrollbar,
.ink-chips::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.ink-modal-body::-webkit-scrollbar-track,
.ink-chips::-webkit-scrollbar-track {
    background: transparent;
}

.ink-modal-body::-webkit-scrollbar-thumb,
.ink-chips::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--ink-line);
}

.ink-chip {
    padding: 3px 12px;
    border: 1px solid var(--ink-line);
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 13px;
    line-height: 20px;
    cursor: pointer;
    transition: background-color .12s ease-in-out, border-color .12s ease-in-out, color .12s ease-in-out;
}

.ink-chip:hover {
    border-color: var(--im-theme-color, #1e87f0);
}

.ink-chip[aria-pressed="true"] {
    border-color: var(--im-theme-color, #1e87f0);
    background: var(--im-theme-color, #1e87f0);
    color: #fff;
}

.ink-chip[hidden] {
    display: none;
}

.ink-chips-summary {
    margin-top: 4px;
}

.ink-modal-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .7);
}

.uk-light .ink-modal-loading {
    background: rgba(0, 0, 0, .55);
}

.ink-modal-loading[hidden] {
    display: none;
}

/*==============================
=        Quản lý chương        =
==============================*/

.ink-manga-head {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ink-manga-cover {
    flex: none;
    width: 64px;
}

.ink-manga-cover img {
    display: block;
    width: 100%;
}

.ink-manga-info {
    flex: 1;
    min-width: 0;
}

.ink-manga-info h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ink-back {
    font-size: 13px;
}

.ink-manga-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.ink-manga-actions {
    display: flex;
    flex: none;
    gap: 6px;
}

.ink-card {
    padding: 16px;
    border: 1px solid var(--ink-line);
    border-radius: 8px;
}

.ink-form-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.ink-form-state [hidden] {
    display: none;
}

/* Đang sửa 1 chương cũ: viền form đổi màu để không nhầm với thêm chương mới */
#imc-form.is-editing {
    border-color: var(--im-theme-color, #1e87f0);
    box-shadow: 0 0 0 1px var(--im-theme-color, #1e87f0);
}

.ink-draft-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
    padding: 8px 12px;
    font-size: 13px;
}

.ink-draft-notice[hidden] {
    display: none;
}

.ink-editor {
    position: relative;
}

.ink-editor textarea {
    display: block;
    min-height: 260px;
    resize: vertical;
}

.ink-editor .pell-content {
    min-height: 260px;
    max-height: 60vh;
}

.ink-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed var(--im-theme-color, #1e87f0);
    border-radius: 4px;
    background: rgba(255, 255, 255, .88);
    color: var(--im-theme-color, #1e87f0);
    font-weight: 600;
    pointer-events: none;
}

.uk-light .ink-drop-overlay {
    background: rgba(0, 0, 0, .7);
}

.ink-editor.is-dragover .ink-drop-overlay {
    display: flex;
}

.ink-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ink-form-actions-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.ink-list-head {
    margin-bottom: 12px;
}

.ink-list-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.ink-chapter .imc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--ink-line);
}

.ink-chapter .imc-item:last-child {
    border-bottom: 0;
}

.ink-chapter .imc-item.is-current {
    margin: 0 -8px;
    padding: 8px 12px;
    border-radius: 6px;
    border-bottom-color: transparent;
    background: var(--ink-soft);
    box-shadow: inset 3px 0 0 var(--im-theme-color, #1e87f0);
}

.imc-item-number {
    flex: none;
    min-width: 44px;
    font-weight: 700;
    white-space: nowrap;
}

.imc-item-main {
    flex: 1;
    min-width: 0;
}

.imc-item-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.imc-item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 3px;
}

.imc-item-badges:empty {
    display: none;
}

.imc-item-actions {
    display: flex;
    flex: none;
    gap: 2px;
}

.imc-item-actions .uk-icon-button {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.imc-item-actions .uk-icon-button:hover {
    background: var(--ink-soft);
}

.imc-item-actions .imc-delete:hover {
    color: #f0506e;
}

.imc-item-actions .uk-icon-button[disabled] {
    opacity: .35;
    cursor: not-allowed;
}

.ink-chapter .imc-pagination .uk-pagination {
    flex-wrap: wrap;
}

/*==============================
=           Thu nhập           =
==============================*/

.ink-table th {
    font-size: 11px;
}

.ink-table td {
    font-size: 14px;
}

.ink-withdraw-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 28px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.ink-withdraw-facts li {
    display: flex;
    flex-direction: column;
}

/*==============================
=           Responsive         =
==============================*/

@media (max-width: 959px) {
    /* Danh sách chương nằm dưới form: giới hạn chiều cao không cần thiết */
    .ink-list-card {
        margin-top: 4px;
    }
}

@media (min-width: 960px) {
    /* Danh sách chương luôn trong tầm mắt khi soạn chương dài */
    .ink-list-card {
        position: sticky;
        top: 90px;
        max-height: calc(100vh - 110px);
        overflow-y: auto;
    }
}

@media (max-width: 639px) {
    .ink-toolbar,
    .ink-search {
        width: 100%;
    }

    .ink-search .uk-inline {
        flex: 1;
    }

    .ink-search-input {
        width: 100%;
    }

    .ink-search .ink-sort {
        min-width: 0;
        max-width: 46%;
    }

    .ink-project-cover {
        width: 84px;
    }

    .ink-form-basics {
        flex-direction: column;
        gap: 14px;
    }

    .ink-cover-field {
        width: 132px;
    }

    .ink-manga-head {
        flex-wrap: wrap;
    }

    .ink-manga-cover {
        width: 48px;
    }

    .ink-manga-info h1 {
        white-space: normal;
        font-size: 1.15rem;
    }

    .ink-manga-actions {
        width: 100%;
    }

    .ink-card {
        padding: 12px;
    }

    .ink-form-actions > .uk-button,
    .ink-form-actions-main > .imc-save-button {
        flex: 1 1 auto;
    }
}

/* ==========================================================================
   v4.0.4 — Ảnh bìa cũ & ảnh nền trong form truyện
   ========================================================================== */
.ink-covers-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.ink-covers-list .ink-covers-empty {
    grid-column: 1 / -1;
}

.ink-cover-thumb {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ink-cover-thumb img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 6px;
    background: rgba(0, 0, 0, .05);
}

.ink-cover-thumb .uk-input {
    padding: 0 6px;
    font-size: .75rem;
}

.ink-cover-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    cursor: pointer;
}

.ink-cover-remove:hover {
    background: #f0506e;
}

.ink-file-input {
    height: auto;
    padding: 6px 10px;
    line-height: 1.4;
}

.ink-background-preview img,
.ink-background-preview video {
    display: block;
    width: 100%;
    max-height: 180px;
    object-fit: cover;
}
