/* AI工作流独立页面样式 */

.ai-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px;
}

.ai-card {
    width: 100%;
}

.ai-form {
    max-width: 600px;
}

.batch-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 12px;
    flex-wrap: wrap;
}

.batch-concurrency {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-2);
}

.batch-concurrency label {
    margin: 0;
    white-space: nowrap;
}

.batch-concurrency input {
    width: 72px;
    padding: 6px 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.ai-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-lg {
    height: 48px;
    padding: 0 28px;
    font-size: 15px;
}

.ai-status-panel {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.ai-status-detail {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 8px;
    line-height: 1.6;
}

.ai-progress-fill.done {
    animation: none;
    width: 100%;
    margin-left: 0;
}

.ai-result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.ai-result-item {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    background: var(--card);
}

.ai-result-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.ai-result-item {
    position: relative;
}

.slot-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    z-index: 2;
}

.ai-slot-loading {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    color: var(--text-2);
    font-size: 13px;
}

.slot-loading-text {
    text-align: center;
    padding: 8px 12px;
}

.mask-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--success);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.no-mask-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--text-3);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.ai-detail-list {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-2);
}

.ai-detail-list div {
    margin: 2px 0;
}

/* AI素材库 日期折叠分组 */
.ai-date-group {
    grid-column: 1 / -1;
    margin-bottom: 4px;
}

.ai-date-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border: 1px solid #dbeafe;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: #1d4ed8;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.ai-date-summary::-webkit-details-marker { display: none; }

.ai-date-summary::before {
    content: "▶";
    font-size: 10px;
    transition: transform .2s;
    color: #93c5fd;
}

details.ai-date-group[open] > .ai-date-summary::before {
    transform: rotate(90deg);
}

.ai-date-count {
    font-weight: 400;
    font-size: 12px;
    color: #6b7280;
    margin-left: 4px;
}

.ai-date-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 12px 0 0;
}

/* 文件上传区域增强 */
.file-upload-zone {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ==========================================================
   四房间一键生成: 配置组(组数 / 并行批次 / 自动重试)
   ========================================================== */
.four-rooms-config {
    display: inline-flex;
    align-items: stretch;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
}

.four-rooms-field {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    padding: 4px 8px;
    border-radius: 6px;
    background: #fff;
}

.four-rooms-field label {
    font-size: 11px;
    color: var(--text-3);
    margin-bottom: 2px;
    white-space: nowrap;
}

.four-rooms-field input {
    width: 70px;
    text-align: center;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    -moz-appearance: textfield;
}

.four-rooms-field input::-webkit-outer-spin-button,
.four-rooms-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ==========================================================
   素材库 范围选择 / 打包下载
   ========================================================== */
.card-title-sub {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-3);
    margin-left: 8px;
}

.materials-toolbar-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

#aiSelectModeBtn.on {
    background: #eef2ff;
    border-color: #a5b4fc;
    color: #4338ca;
}

.ai-selection-bar {
    margin: 12px 0 0;
    padding: 10px 12px;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    border: 1px solid #c7d2fe;
    border-radius: 10px;
}

.ai-selection-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ai-selection-row .btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }

.ai-selection-divider {
    width: 1px;
    height: 22px;
    background: #c7d2fe;
}

.ai-selection-range {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-2);
}

.ai-selection-range input {
    width: 70px;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    background: #fff;
}

.ai-selection-count {
    margin-left: auto;
    font-size: 12px;
    color: #4338ca;
    font-weight: 600;
}

/* 选择模式下的文件夹卡片 */
.folder-card.selectable {
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.folder-card.selectable:hover {
    transform: translateY(-1px);
    border-color: #818cf8;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .15);
}
.folder-card.checked {
    border-color: #6366f1 !important;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, .2);
}

.folder-check {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 3;
}
.folder-check.on {
    background: #6366f1;
    border-color: #6366f1;
}

/* ==========================================================
   分享链接 对话框
   ========================================================== */
.share-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.share-modal.show { display: flex; }

.share-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
}

.share-modal-card {
    position: relative;
    width: min(560px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
    display: flex;
    flex-direction: column;
    animation: shareModalIn .18s ease-out;
}
@keyframes shareModalIn {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.share-modal-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px 14px;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}
.share-modal-head h3 {
    margin: 0 0 4px;
    font-size: 16px;
    color: #1f2937;
}
.share-modal-sub {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
}
.share-modal-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .3);
}
.share-modal-icon .icon { width: 22px; height: 22px; }

.share-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.share-modal-close:hover { background: #f3f4f6; color: #1f2937; }

.share-modal-body {
    padding: 18px 22px;
}

.share-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.share-info-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
}
.share-info-label {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
}
.share-info-value {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    word-break: break-all;
}

.share-link-section {
    margin-bottom: 8px;
}
.share-link-label {
    display: block;
    font-size: 12px;
    color: #4b5563;
    margin-bottom: 6px;
    font-weight: 500;
}
.share-link-input {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.share-link-input input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
    color: #4b5563;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 12px;
}
.share-link-input input:focus {
    outline: none;
    border-color: #8b5cf6;
    background: #fff;
}
.share-copy-btn {
    flex-shrink: 0;
    padding: 9px 16px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.share-copy-btn:hover { background: #4f46e5; }
.share-copy-btn.copied { background: #10b981; }

.share-link-extra {
    margin-top: 10px;
}
.share-link-extra summary {
    cursor: pointer;
    font-size: 12px;
    color: #6366f1;
    user-select: none;
    padding: 4px 0;
}
.share-link-extra summary:hover { color: #4f46e5; }

.share-modal-foot {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 14px 22px 18px;
    border-top: 1px solid #e5e7eb;
}

@media (max-width: 480px) {
    .share-modal-card { border-radius: 14px; }
    .share-modal-head { padding: 14px 16px 12px; }
    .share-modal-body { padding: 14px 16px; }
    .share-modal-foot { padding: 12px 16px 14px; }
    .share-info-grid { grid-template-columns: 1fr; }
    .share-link-input { flex-direction: column; gap: 6px; }
    .share-copy-btn { width: 100%; }
    .share-modal-head h3 { font-size: 15px; }
    .share-modal-icon { width: 36px; height: 36px; }
}

/* ==========================================================
   AI工作流页面 移动端适配
   ========================================================== */

/* ===== 平板及以下 ===== */
@media (max-width: 768px) {
    .ai-container { padding: 16px 12px; }
    .ai-form { max-width: 100%; }
    .ai-actions { gap: 8px; flex-wrap: wrap; }
    .ai-actions .btn-lg { height: 44px; padding: 0 18px; font-size: 14px; }
    .ai-actions > div { flex: 1 1 100%; justify-content: center; }
    .batch-tools { flex-direction: column; align-items: stretch; gap: 8px; }
    .batch-concurrency { justify-content: space-between; }
    .four-rooms-config { flex: 1 1 100%; justify-content: space-between; }
    .four-rooms-field { flex: 1; min-width: 0; }
    .four-rooms-field input { width: 100%; }
    .ai-selection-row { gap: 8px; }
    .ai-selection-divider { display: none; }
    .ai-selection-count { width: 100%; text-align: right; }
    .ai-result-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
    .ai-result-item img { height: 170px; }
    .ai-slot-loading { height: 170px; font-size: 12px; }
    .ai-date-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .ai-date-summary { font-size: 13px; padding: 9px 12px; }
}

/* ===== 主流手机 ===== */
@media (max-width: 480px) {
    .ai-container { padding: 12px 10px; }
    .ai-actions { gap: 8px; }
    .ai-actions .btn-lg { width: 100%; flex: 1 1 100%; }
    .ai-actions > div { width: 100%; }
    .ai-actions #aiFourRoomsCount { width: 80px !important; }
    .four-rooms-config { padding: 6px; gap: 6px; }
    .four-rooms-field label { font-size: 10px; }
    .ai-selection-bar { padding: 8px 10px; }
    .ai-selection-row { gap: 6px; }
    .ai-selection-row .btn-sm { flex: 1; min-width: 0; }
    .ai-selection-range { width: 100%; flex-wrap: wrap; }
    .ai-selection-range input { flex: 1; min-width: 50px; }
    .ai-result-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .ai-result-item img { height: 140px; }
    .ai-slot-loading { height: 140px; }
    .slot-label { font-size: 11px; padding: 2px 6px; top: 6px; left: 6px; }
    .mask-badge, .no-mask-badge { font-size: 10px; padding: 2px 6px; top: 6px; right: 6px; }
    .ai-date-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .ai-date-summary { font-size: 12px; padding: 8px 10px; gap: 4px; }
    .ai-date-count { font-size: 11px; }
    .ai-status-panel { padding: 12px; }
    .ai-status-text { font-size: 12px; }
    .ai-detail-list { font-size: 11px; padding: 8px 10px; }
    .ai-batch-header { font-size: 12px !important; padding: 6px 10px !important; }
}

/* ===== 小屏手机 ===== */
@media (max-width: 360px) {
    .ai-result-grid,
    .ai-date-grid { gap: 6px; }
    .ai-result-item img { height: 120px; }
    .ai-slot-loading { height: 120px; }
}

/* ===== 历史记录模态框 / 图片 Lightbox: 覆盖动态 inline 样式 ===== */
@media (max-width: 768px) {
    /* 历史记录弹窗在手机上变成半屏抽屉 */
    #aiHistoryModal { align-items: flex-end !important; }
    #aiHistoryModal > div:last-child {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 90vh !important;
        border-radius: 14px 14px 0 0 !important;
    }
    #aiHistoryBody { padding: 10px 14px !important; }
    #aiHistoryModal .row,
    #aiHistoryModal [data-row] { font-size: 12px; }
    /* 弹窗头部按钮组允许横滚 */
    #aiHistoryModal > div:last-child > div:first-child > div:last-child {
        flex-wrap: wrap;
        gap: 6px !important;
    }
    #aiHistoryModal > div:last-child > div:first-child > div:last-child button {
        font-size: 12px !important;
        padding: 4px 10px !important;
    }
    /* Lightbox: 安全的内边距 + 关闭按钮可点 */
    #aiImageLightbox { padding: 16px !important; }
    #aiImageLightbox button {
        top: 12px !important;
        right: 12px !important;
        width: 44px !important;
        height: 44px !important;
    }
}
