/*
 * Custom overrides on top of the vendor theme.
 * Story cover upload preview: constrain to the same portrait ratio the
 * image pipeline outputs (600x900) instead of the theme's wide default
 * upload box, and cap the width so it renders as a reasonable thumbnail.
 */

.upload-image {
    max-width: 320px;
}
.upload-image .uploadfile {
    height: auto;
    aspect-ratio: 2 / 3;
}

/*
 * Toast thông báo (flash message).
 *
 * Dùng chung markup với trang người dùng (resources/views/partials/toasts.blade.php).
 * Bo góc, đổ bóng và nền lấy đúng theo .wg-box của template quản trị để toast
 * trông như một thẻ nữa của dashboard; màu trạng thái lấy từ bảng Palette.
 *
 * Icon vẽ bằng CSS thay vì font icon để hai bên dùng chung được một partial:
 * tên class icon của hai template không trùng nhau.
 */

.app-toast-stack {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 380px;
    max-width: calc(100vw - 32px);
    /* Để khoảng trống quanh toast không chắn thao tác trên trang. */
    pointer-events: none;
}

.app-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-left: 4px solid var(--Icon);
    border-radius: 12px;
    background: var(--White);
    box-shadow: 0px 4px 24px 2px rgba(10, 10, 12, 0.12);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.app-toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.app-toast.is-leaving {
    opacity: 0;
    transform: translateX(20px);
}

.app-toast__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border-radius: 50%;
    background-color: var(--Icon);
    color: var(--White);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.app-toast__body {
    flex: 1;
    margin: 0;
    color: var(--Heading);
    font-size: 14px;
    font-weight: 500;
    line-height: 22px;
}

.app-toast__close {
    flex-shrink: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--Icon);
    font-size: 20px;
    line-height: 20px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.app-toast__close:hover {
    color: var(--Heading);
}

/* Trạng thái ----------------------------------------------------------- */

.app-toast--success {
    border-left-color: var(--Palette-Green-500);
}

.app-toast--success .app-toast__icon {
    background-color: var(--Palette-Green-500);
}

/* Dấu tick vẽ bằng hai cạnh viền xoay 45 độ. */
.app-toast--success .app-toast__icon::before {
    content: "";
    width: 5px;
    height: 9px;
    margin-top: -2px;
    border: solid var(--White);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.app-toast--error {
    border-left-color: var(--Palette-Red-500);
}

.app-toast--error .app-toast__icon {
    background-color: var(--Palette-Red-500);
}

.app-toast--error .app-toast__icon::before {
    content: "!";
}

.app-toast--warning {
    border-left-color: var(--Palette-Orange-400);
}

.app-toast--warning .app-toast__icon {
    background-color: var(--Palette-Orange-400);
}

.app-toast--warning .app-toast__icon::before {
    content: "!";
}

.app-toast--info {
    border-left-color: var(--Secondary);
}

.app-toast--info .app-toast__icon {
    background-color: var(--Secondary);
}

.app-toast--info .app-toast__icon::before {
    content: "i";
}

@media (max-width: 767px) {
    .app-toast-stack {
        top: 16px;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-toast {
        transition: opacity 0.25s ease;
        transform: none;
    }

    .app-toast.is-leaving,
    .app-toast.is-visible {
        transform: none;
    }
}

/*
 * Danh sách thông báo trên thanh tiêu đề quản trị.
 *
 * Mỗi mục là một nút submit (bấm vào vừa đánh dấu đã đọc vừa chuyển trang), nên
 * phải gỡ toàn bộ giao diện mặc định của <button> rồi dựng lại theo dạng hàng:
 * huy hiệu biểu tượng bên trái, tiêu đề + nội dung + tên nhóm bên phải.
 *
 * Màu (group-*) phân biệt nhóm việc theo mã `key` của Notification::display():
 * nạp xu, đăng ký dịch giả, truyện, chương mới, thanh toán, hệ thống. Trạng thái
 * trong cùng một nhóm (chờ xử lý / đã duyệt / bị từ chối) đã được biểu tượng thể
 * hiện, nên màu để dành cho việc nhận ra nhóm. Màu lấy theo bảng Palette.
 */

.popup-wrap.noti .dropdown-menu.show {
    /* Mục đã nhiều thông tin hơn nên phải chặn chiều cao, tránh menu dài quá màn hình. */
    max-height: 460px;
    overflow-y: auto;
}

.noti-button {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: none;
    text-align: start;
}

.noti-button:hover {
    background: var(--hv-item);
}

.noti-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.noti-icon i {
    font-size: 18px;
}

/* min-width:0 để tiêu đề và nội dung cắt được bằng dấu ba chấm thay vì tràn ra ngoài. */
.noti-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.noti-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.noti-head .body-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.noti-head .time {
    flex-shrink: 0;
    color: var(--Note);
    font-size: 12px;
    font-weight: 400;
}

/* Giới hạn 2 dòng: đủ để hiểu nội dung mà không làm mục cao quá. */
.noti-content {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
}

.noti-category {
    align-self: flex-start;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

.noti-icon.group-recharge,
.noti-category.group-recharge { background: #FFF0E8; color: var(--Style); }
.noti-icon.group-translator,
.noti-category.group-translator { background: #F1EAFD; color: #7047D6; }
.noti-icon.group-story,
.noti-category.group-story { background: #E9F1FE; color: var(--Secondary); }
.noti-icon.group-chapter,
.noti-category.group-chapter { background: #E4F3F1; color: #35988D; }
.noti-icon.group-payment,
.noti-category.group-payment { background: #E9F9EF; color: var(--Palette-Green-500); }
.noti-icon.group-system,
.noti-category.group-system { background: #F1F2F4; color: var(--Note); }

/*
 * Trang danh sách thông báo (admin.notifications.index).
 *
 * Dùng lại huy hiệu biểu tượng và nhãn nhóm của dropdown, chỉ khác ở chỗ nội
 * dung hiển thị đầy đủ (không cắt hai dòng) và mục chưa đọc được tô nền để phân
 * biệt với mục đã xử lý.
 */

.noti-page-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
    padding: 0;
    list-style: none;
}

.noti-page-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--Stroke);
    border-radius: 12px;
}

.noti-page-row.is-unread {
    background: var(--hv-item);
}

.noti-page-text {
    margin-top: 4px;
}

.noti-page-foot {
    margin-top: 10px;
}

/* Trong hàng này nhãn nhóm đứng cạnh các phần tử khác nên bỏ lề trên của dropdown. */
.noti-page-foot .noti-category {
    margin-top: 0;
}

/* Nhãn "Mới": cùng kiểu viên thuốc với nhãn nhóm nhưng lấy màu nhấn của template. */
.noti-new {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--Main);
    color: var(--White);
    font-size: 11px;
    font-weight: 500;
}

.noti-action {
    padding: 0;
    border: none;
    background: none;
    color: var(--Secondary);
    text-decoration: underline;
}

/*
 * Thanh lọc ở các màn danh sách quản trị.
 *
 * Ô tìm kiếm, các select lọc, nút "Tìm kiếm" và "Xóa điều kiện" nằm trên một
 * hàng, cùng cao 50px như .tf-button; màn hẹp thì tự xuống dòng.
 *
 * Không dùng .form-search của template: nó đặt icon kính lúp tuyệt đối theo cả
 * form, nên form có thêm select là icon trôi khỏi ô input. Ở đây icon định vị
 * theo chính ô tìm kiếm.
 */
.wg-filter form.form-filter {
    max-width: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.form-filter fieldset {
    width: auto;
}

.form-filter .search {
    position: relative;
    flex: 1 1 240px;
    max-width: 360px;
}

.form-filter .search i {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--Main-Dark);
    pointer-events: none;
}

.form-filter .search input {
    padding-left: 46px;
}

/* Select lấy chiều cao, nền và bo góc của ô input thay vì kiểu nhỏ của Bootstrap. */
.form-filter .form-select {
    min-width: 180px;
    height: 50px;
    padding: 0 44px 0 18px;
    font-size: 14px;
    line-height: 20px;
    color: var(--Surface-2);
    background-color: var(--Surface-3);
    background-position: right 18px center;
    border: 0;
    border-radius: 12px;
}

.form-filter .tf-button {
    flex-shrink: 0;
}

/* Nút "Thêm ..." cạnh thanh lọc: khi bị đẩy xuống dòng vẫn nằm bên phải. */
.wg-filter + .tf-button,
.wg-filter + form {
    margin-left: auto;
}

/* Dark theme: nền, chữ và mũi tên của select theo đúng ô input tối của template. */
.dark-theme .form-filter .form-select {
    color: var(--Surface);
    background-color: rgba(48, 48, 48, 0.5019607843);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23C3C1CF' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* Màn hẹp: mỗi trường một hàng, hai nút đứng cạnh nhau bên dưới. */
@media (max-width: 767px) {
    .form-filter fieldset,
    .form-filter .search {
        flex: 1 1 100%;
        max-width: none;
    }
}

/*
 * Hộp xác nhận xóa (admin.partials.confirm-modal).
 *
 * Nền, bo góc lấy theo .wg-box để trông như một thẻ của dashboard; nút xóa màu
 * đỏ trong bảng Palette để tách hẳn với các nút chính màu xanh.
 */
.confirm-modal {
    align-items: center;
    padding: 32px;
    text-align: center;
    background: var(--White);
    border: 0;
    border-radius: 14px;
}

.confirm-modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.12);
    color: var(--Palette-Red-500);
    font-size: 24px;
}

.confirm-modal-title {
    margin-bottom: 8px;
    color: var(--Main-Dark);
}

.confirm-modal-message {
    margin-bottom: 24px;
    color: var(--Body-Text);
}

.tf-button.confirm-modal-accept {
    background-color: var(--Palette-Red-500);
    border-color: var(--Palette-Red-500);
}

.tf-button.confirm-modal-accept:hover {
    background-color: var(--Palette-Red-400);
    border-color: var(--Palette-Red-400);
}

/* Form truyện: ô % giảm giá combo chỉ cần vài chữ số, không cần dài cả hàng. */
.combo-discount-field input {
    max-width: 240px;
}

/*
 * Đăng chương hàng loạt: khung hướng dẫn định dạng và phần xem trước. Nền lấy
 * theo --bg-table để tách khỏi nền .wg-box ở cả giao diện sáng lẫn tối.
 */
.bulk-chapter-box {
    padding: 16px 20px;
    background: var(--bg-table);
    border: 1px solid var(--Stroke);
    border-radius: 12px;
}

.bulk-chapter-box p + p,
.bulk-chapter-box pre + p {
    margin-top: 8px;
}

/* Template tô pre/code nền #f5f5f5 cố định, chữ nhỏ: đổi theo biến để hợp cả giao diện tối. */
.bulk-chapter-box pre,
.bulk-chapter-box code {
    background: var(--White);
    border-color: var(--Stroke);
    border-radius: 8px;
}

.bulk-chapter-box pre {
    margin: 10px 0;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 22px;
    white-space: pre-wrap;
}

.bulk-chapter-errors li,
.bulk-chapter-list li {
    font-size: 14px;
    line-height: 22px;
}

.bulk-chapter-errors li {
    color: var(--Palette-Red-500);
}

.bulk-chapter-list li {
    padding: 4px 0;
    color: var(--Body-Text);
    border-bottom: 1px solid var(--Stroke);
}

.bulk-chapter-errors:not(:empty) {
    margin-bottom: 10px;
}

/* 40 chương dài hơn một màn hình: cuộn trong khung thay vì đẩy nút Đăng xuống. */
.bulk-chapter-list {
    max-height: 320px;
    overflow-y: auto;
}

/*
 * Lỗi nhập liệu của form. Các view quản trị dùng class Tailwind .text-red-500
 * nhưng trang quản trị không nạp Tailwind, nên tự định nghĩa lại theo màu đỏ của template.
 */
.text-red-500 {
    color: var(--Palette-Red-500);
}
