/* tskman AdminLTE tweaks */
.content-wrapper {
    min-height: calc(100vh - 57px);
}

/* Sidebar brand */
.main-sidebar .tskman-brand-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    height: 3.5rem;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.15);
    text-decoration: none;
    transition: background 0.2s ease;
}

.main-sidebar .tskman-brand-link:hover {
    background: rgba(0, 0, 0, 0.25);
    text-decoration: none;
}

.main-sidebar .tskman-brand-link .brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #3d8bfd 0%, #0d6efd 100%);
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.45);
}

.main-sidebar .tskman-brand-link .brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.main-sidebar .tskman-brand-link .brand-title {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #f8f9fa;
}

.main-sidebar .tskman-brand-link .brand-accent {
    color: #6ea8fe;
    font-weight: 700;
}

.main-sidebar .tskman-brand-link .brand-tagline {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 0.15rem;
}

.sidebar-mini.sidebar-collapse .main-sidebar .tskman-brand-link .brand-text {
    display: none;
}

.system-prompt-field__head .custom-control-label {
    cursor: pointer;
    user-select: none;
}

.task-template-pick-list .btn-block {
    white-space: normal;
    text-align: left;
}

.main-header .dropdown-menu.nav-user-dropdown {
    min-width: 12rem;
    max-width: min(20rem, calc(100vw - 2rem));
}

/* 顶栏项目下拉：列表区域限高滚动，底部操作固定（勿对未展开菜单设 display，否则会无法关闭） */
.main-header .dropdown-menu.nav-project-dropdown {
    padding: 0;
    width: max-content;
    min-width: 10rem;
    max-width: min(36rem, calc(100vw - 2rem));
    max-height: 20rem;
    overflow: hidden;
}

.main-header .dropdown-menu.nav-project-dropdown.show {
    display: flex;
    flex-direction: column;
}

.main-header .nav-project-dropdown__list {
    flex: 1 1 auto;
    min-height: 0;
    width: max-content;
    min-width: 100%;
    max-width: min(36rem, calc(100vw - 2rem));
    max-height: 14rem;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

.main-header .nav-project-dropdown__list .dropdown-item {
    white-space: nowrap;
    line-height: 1.35;
}

.main-header .nav-project-dropdown__footer .dropdown-item {
    white-space: nowrap;
}

.main-header .nav-project-dropdown__footer {
    flex-shrink: 0;
    background: #fff;
}

.main-header .nav-project-dropdown__footer .dropdown-divider {
    margin: 0;
}

.main-header .nav-project-dropdown__footer .dropdown-item:last-child {
    border-radius: 0 0 0.25rem 0.25rem;
}

.task-create-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.task-create-type-card .card-body {
    min-height: 12rem;
}

@media (min-width: 992px) {
    .task-create-page .task-create-type-row > [class*="col-"] {
        margin-bottom: 0;
    }
}

.task-create-template-card .card-title {
    font-size: 0.9rem;
    line-height: 1.35;
    word-break: break-word;
}

.task-create-template-card .card-body {
    min-height: 9.5rem;
    padding: 0.75rem;
}

.task-create-template-card .badge {
    font-size: 0.65rem;
}

.task-create-template-grid .btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.4rem;
    white-space: normal;
}

.sidebar-mini.sidebar-collapse .main-sidebar .tskman-brand-link {
    justify-content: center;
    padding: 0;
}

.sidebar .nav-treeview.task-sidebar-tasks {
    max-height: calc(100vh - 11rem);
    overflow-y: auto;
}

.sidebar .nav-treeview.task-sidebar-tasks .nav-link {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.sidebar .nav-treeview.task-sidebar-tasks .nav-link p {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap !important;
}

.sidebar .nav-treeview.task-sidebar-tasks .task-sidebar-type-icon {
    font-size: 0.85rem;
    width: 1.6rem;
    text-align: center;
}

.sidebar .nav-treeview.task-sidebar-tasks .task-sidebar-type-icon--success {
    color: #52c962 !important;
}

.sidebar .nav-treeview.task-sidebar-tasks .task-sidebar-type-icon--danger {
    color: #ff6b6b !important;
}

.sidebar .nav-treeview.task-sidebar-tasks .task-sidebar-type-icon--info {
    color: #5dabff !important;
}

.sidebar .nav-treeview.task-sidebar-tasks .task-sidebar-type-icon--warning {
    color: #ffc857 !important;
}

.sidebar .nav-treeview.task-sidebar-tasks .task-sidebar-type-icon--secondary {
    color: rgba(255, 255, 255, 0.45) !important;
}

.login-page {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #1e3c72 100%);
}

.login-box {
    width: 400px;
    margin: 7% auto;
}

.login-logo a {
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.login-card-body {
    border-radius: 0.25rem;
}

.table td,
.table th {
    vertical-align: middle !important;
}

.card .card-title {
    margin-bottom: 0;
}

/* Task form: radio groups (content width, light gray) */
.task-image-options .task-option-radio {
    display: inline-flex;
    width: auto;
    max-width: 100%;
    vertical-align: top;
}

.task-image-options .task-option-radio .task-option-radio-btn {
    float: none;
    background-color: #f4f4f5;
    border-color: #dee2e6;
    color: #495057;
    box-shadow: none;
}

.task-image-options .task-option-radio .task-option-radio-btn:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
    color: #212529;
}

.task-image-options .task-option-radio .task-option-radio-btn.active,
.task-image-options .task-option-radio .task-option-radio-btn:active {
    background-color: #e2e3e5 !important;
    border-color: #adb5bd !important;
    color: #212529 !important;
    box-shadow: none;
}

/* Task form: reference images grid */
.ref-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 12px;
    align-items: start;
}

.ref-items-grid .ref-empty-hint {
    grid-column: 1 / -1;
}

.ref-item-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #fff;
}

.ref-item-card__preview {
    position: relative;
    aspect-ratio: 1;
    background: #f4f4f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ref-item-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ref-item-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.ref-item-card__body {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ref-item-card__field .form-control {
    width: 100%;
}

.ref-item-card__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
}

.ref-item-card__toolbar .badge {
    flex-shrink: 0;
}

.ref-item-card__toolbar .ref-remove-btn {
    flex-shrink: 0;
    padding: 0.15rem 0.4rem;
    line-height: 1;
}

/* Task list grid */
.task-view-toggle .btn.active,
.task-category-toggle .btn-primary,
.resource-view-toggle .btn.active {
    background-color: #007bff !important;
    border-color: #007bff !important;
    color: #fff !important;
}

.task-category-toggle .btn-primary:hover,
.task-category-toggle .btn-primary:focus,
.task-view-toggle .btn.active:hover,
.task-view-toggle .btn.active:focus,
.resource-view-toggle .btn.active:hover,
.resource-view-toggle .btn.active:focus {
    background-color: #0069d9 !important;
    border-color: #0062cc !important;
    color: #fff !important;
}

.task-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.task-card {
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: 0.35rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.15s ease;
}

.task-card:has(.dropdown.show) {
    z-index: 20;
}

.task-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.task-card__media {
    position: relative;
    height: 150px;
    flex-shrink: 0;
    background: #e9ecef;
    overflow: hidden;
    border-radius: 0.35rem 0.35rem 0 0;
}

.task-card__convert-video {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 3;
    padding: 0.2rem 0.45rem;
    line-height: 1.2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.task-card__media-el {
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
}

.task-card__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 2.5rem;
}

.task-card__overlay {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
}

.task-card__overlay--meta {
    bottom: 0;
    padding: 0.5rem 0.55rem 0.45rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
}

.task-card__overlay-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
}

.task-card__progress {
    height: 0.35rem;
    background: rgba(255, 255, 255, 0.25);
}

.task-card__progress .progress-bar {
    font-size: 0;
    line-height: 0;
}

.task-card__overlay--error {
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: rgba(220, 53, 69, 0.82);
    color: #fff;
    text-align: center;
}

.task-card__error-inner {
    max-height: 100%;
    overflow: auto;
    font-size: 0.75rem;
    line-height: 1.35;
}

.task-card__error-inner p {
    word-break: break-word;
}

.task-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.55rem;
    min-height: 2.5rem;
}

.task-card__footer-text {
    flex: 1;
    min-width: 0;
}

.task-card__name {
    display: block;
    min-width: 0;
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-card__menu {
    flex-shrink: 0;
}

.task-card__menu .dropdown-menu {
    z-index: 1050;
}

.task-card__menu .btn {
    line-height: 1;
    padding: 0.2rem 0.45rem;
}

.task-card__menu.dropup .dropdown-menu {
    margin-bottom: 0.25rem;
}

.resource-card-grid {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}

.resource-card {
    min-width: 0;
    overflow: hidden;
}

.resource-card__preview {
    position: relative;
    height: 140px;
    flex-shrink: 0;
    background: #e9ecef;
    overflow: hidden;
    line-height: 0;
}

.resource-card__media {
    width: 100% !important;
    height: 140px !important;
    max-width: 100%;
    object-fit: cover;
    display: block;
}

.resource-card__placeholder {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 2rem;
    line-height: 1;
}

.resource-card__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0.65rem 0.7rem 0.7rem !important;
    gap: 0.45rem;
}

.resource-card__name {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.35;
    word-break: break-word;
}

.resource-card__meta {
    font-size: 0.75rem;
    line-height: 1.5;
}

.resource-card__meta li + li {
    margin-top: 0.15rem;
}

.resource-card__meta .text-muted {
    display: inline-block;
    min-width: 3.5rem;
}

.resource-card__preview.resource-preview-trigger {
    cursor: pointer;
}

.resource-card__preview.resource-preview-trigger:hover .resource-card__media {
    opacity: 0.92;
}

.resource-preview-trigger {
    cursor: pointer;
}

.resource-preview-modal__body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #f8f9fa;
}

.resource-preview-modal__media {
    max-width: 100%;
    max-height: calc(100vh - 180px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.resource-card__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: auto;
    padding-top: 0.25rem;
}

.card-footer.clearfix {
    padding: 0;
    background: transparent;
}

.tskman-pager .page-link,
.tskman-pager > li > a,
.tskman-pager > li > span {
    min-width: 1.75rem;
    min-height: 1.75rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tskman-pager .page-item.active .page-link {
    z-index: 1;
}

.tskman-pager .page-item.disabled .page-link,
.tskman-pager > li.disabled > span {
    opacity: 0.65;
}

/* Task detail view */
.task-view-page .card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.task-view-page .card-header::after {
    display: none;
}

.task-view-page .card-title {
    float: none;
    flex: 1 1 auto;
    min-width: 0;
}

.task-view-page .card-tools {
    float: none;
    margin-left: auto;
    margin-right: 0;
    justify-content: flex-end;
}

.task-view-result {
    border: 1px solid #dee2e6;
    border-radius: 0.35rem;
    background: #f8f9fa;
    overflow: hidden;
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-view-result__link {
    display: block;
    width: 100%;
    line-height: 0;
}

.task-view-result__media {
    display: block;
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    background: #000;
}

.task-view-result__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
}

.task-view-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1.25rem;
}

@media (max-width: 575.98px) {
    .task-view-meta {
        grid-template-columns: 1fr;
    }
}

.task-view-meta__item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.task-view-meta__item--full {
    grid-column: 1 / -1;
}

.task-view-meta__label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.task-view-meta__value {
    font-size: 0.9375rem;
    word-break: break-word;
}

.task-view-meta__value code {
    font-size: 0.8125rem;
}

.task-view-progress {
    height: 0.5rem;
}

.task-view-section {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e9ecef;
}

.task-view-section__title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.65rem;
}

.task-view-text {
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}

.task-view-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.task-view-ref {
    width: 100px;
    text-align: center;
}

.task-view-ref__img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
    display: block;
}

.task-view-ref__placeholder {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    border-radius: 0.25rem;
    color: #adb5bd;
    font-size: 1.5rem;
}

.task-view-ref__name {
    font-size: 0.75rem;
    margin: 0.35rem 0 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-view-logs {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.task-view-log {
    padding: 0.65rem 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 0.35rem;
    background: #fafbfc;
}

.task-view-log__head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.task-view-log__time {
    font-size: 0.75rem;
}

.task-view-log__message {
    font-size: 0.875rem;
    line-height: 1.45;
    word-break: break-word;
}

.task-view-log__meta {
    margin-top: 0.5rem;
    padding: 0.5rem 0.65rem;
    background: #f1f3f5;
    border-radius: 0.25rem;
    max-height: 160px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

