/* ══════════════════════════════════════════
   Data Management 페이지 전용 스타일 (v5)
   — 1줄 툴바 + 서버 사이드 페이징
   ══════════════════════════════════════════ */

/* ═══════════════════════════════
   상단 1줄 툴바
   ═══════════════════════════════ */
.dm-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.625rem;
    margin-bottom: 0.375rem;
    flex-wrap: wrap;
}

.dm-tb-file {
    display: flex;
    align-items: center;
    min-width: 180px;
    max-width: 260px;
    height: 34px;
    padding: 0 0.625rem;
    border: 1.5px dashed #e5e7eb;
    border-radius: 0.5rem;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.dm-tb-file:hover { border-color: #e6007e; background: rgba(230,0,126,.02); }
.dm-tb-file.drag-over { border-color: #e6007e; background: rgba(230,0,126,.05); }

.dm-tb-file-placeholder {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    white-space: nowrap;
}
.dm-tb-file-selected {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    width: 100%;
    min-width: 0;
}
.dm-tb-file-selected .truncate { flex: 1; min-width: 0; }

/* 툴바 버튼 */
.dm-tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    height: 32px;
    padding: 0 0.75rem;
    border-radius: 0.375rem;
    font-size: 11.5px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.dm-tb-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.dm-tb-btn.upload {
    color: #fff;
    background: linear-gradient(135deg, #e6007e, #c4006a);
    box-shadow: 0 1px 4px rgba(230,0,126,.15);
}
.dm-tb-btn.upload:hover:not(:disabled) { box-shadow: 0 2px 8px rgba(230,0,126,.25); }

.dm-tb-btn.analyze {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 1px 4px rgba(37,99,235,.15);
}
.dm-tb-btn.analyze:hover:not(:disabled) { box-shadow: 0 2px 8px rgba(37,99,235,.25); }

.dm-tb-btn.stop {
    color: #dc2626;
    background: #fff;
    border: 1px solid #fca5a5;
}
.dm-tb-btn.stop:hover { background: #fef2f2; border-color: #ef4444; }

/* 상태 숫자 */
.dm-tb-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex: 1;
    justify-content: center;
    min-width: 0;
}
.dm-tb-stat {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
}
.dm-tb-stat b {
    font-size: 13px;
    font-weight: 800;
}
.dm-tb-dot {
    color: #d1d5db;
    font-size: 10px;
}

/* 우측 액션 */
.dm-tb-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}
.dm-tb-auto {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 10.5px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    white-space: nowrap;
}
.dm-tb-auto input[type="checkbox"] {
    width: 13px;
    height: 13px;
    accent-color: #e6007e;
    cursor: pointer;
}
.dm-tb-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 5px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: all .12s;
}
.dm-tb-icon:hover { background: #f9fafb; color: #374151; border-color: #d1d5db; }
.dm-tb-icon.danger { color: #ef4444; border-color: #fca5a5; }
.dm-tb-icon.danger:hover { background: #fef2f2; }

/* ── 진행률 바 ── */
.dm-progress-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0 0.25rem;
}
.dm-progress-track {
    flex: 1;
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}
.dm-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, #e6007e, #f472b6);
}
.dm-progress-fill.animated {
    background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6);
    background-size: 200% 100%;
    animation: dm-shimmer 2s ease-in-out infinite;
}
@keyframes dm-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── 메시지 ── */
.dm-msg-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.dm-inline-msg {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    white-space: nowrap;
}
.dm-inline-msg.success { background: #ecfdf5; color: #059669; }
.dm-inline-msg.error   { background: #fef2f2; color: #dc2626; }

/* ═══════════════════════════════
   필터 바
   ═══════════════════════════════ */
.dm-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.dm-filter-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.dm-filter-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.dm-filter-count {
    font-size: 10.5px;
    color: #9ca3af;
    white-space: nowrap;
}

/* ── 필터 탭 ── */
.filter-tabs {
    display: flex;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}
.filter-tab {
    padding: 0.25rem 0.5rem;
    font-size: 10.5px;
    font-weight: 600;
    color: #6b7280;
    background: #fff;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 1px solid #e5e7eb;
}
.filter-tab:first-child { border-left: none; }
.filter-tab:hover { background: #f9fafb; }
.filter-tab.active            { background: #1f2937; color: #fff; }
.filter-tab.active.pending    { background: #f59e0b; color: #fff; }
.filter-tab.active.completed  { background: #10b981; color: #fff; }
.filter-tab.active.failed     { background: #ef4444; color: #fff; }
.filter-tab.active.topic      { background: #7c3aed; color: #fff; }
.filter-count { opacity: 0.7; margin-left: 2px; }
.topic-tabs { margin-right: 0.25rem; }

/* ── 검색 ── */
.dm-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.dm-search-icon {
    position: absolute;
    left: 8px;
    width: 14px;
    height: 14px;
    color: #9ca3af;
    pointer-events: none;
}
.dm-search-input {
    width: 200px;
    height: 30px;
    padding: 0 28px 0 26px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 11.5px;
    color: #374151;
    background: #fafafa;
    outline: none;
    transition: all 0.15s;
}
.dm-search-input::placeholder { color: #b0b0b0; }
.dm-search-input:focus { border-color: #e6007e; background: #fff; box-shadow: 0 0 0 2px rgba(230,0,126,.06); }
.dm-search-clear {
    position: absolute;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
}
.dm-search-clear:hover { background: #f3f4f6; color: #374151; }

/* ── 벌크 액션 바 ── */
.dm-bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, #fdf4ff, #fce7f3);
    border: 1px solid #f9a8d4;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.dm-bulk-info { font-size: 12px; font-weight: 600; color: #9d174d; }
.dm-bulk-count { font-size: 14px; font-weight: 800; color: #e6007e; }
.dm-bulk-actions { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.dm-bulk-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all .12s;
    border: 1px solid;
}
.dm-bulk-btn.analyze-selected {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-color: #2563eb;
}
.dm-bulk-btn.analyze-selected:hover:not(:disabled) { box-shadow: 0 2px 6px rgba(37,99,235,.3); }
.dm-bulk-btn.analyze-selected:disabled { opacity: 0.4; cursor: not-allowed; }

.dm-bulk-btn.reanalyze { color: #2563eb; background: #fff; border-color: #93c5fd; }
.dm-bulk-btn.reanalyze:hover { background: #eff6ff; }
.dm-bulk-btn.cancel { color: #d97706; background: #fff; border-color: #fcd34d; }
.dm-bulk-btn.cancel:hover { background: #fffbeb; }
.dm-bulk-btn.delete { color: #dc2626; background: #fff; border-color: #fca5a5; }
.dm-bulk-btn.delete:hover { background: #fef2f2; }
.dm-bulk-btn.dismiss { color: #6b7280; background: #fff; border-color: #d1d5db; }
.dm-bulk-btn.dismiss:hover { background: #f9fafb; }

/* ═══════════════════════════════
   테이블
   ═══════════════════════════════ */
.dm-table-wrap {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
}
.dm-thead {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    border-bottom: 1px solid #f3f4f6;
    background: #fafafa;
}
.dm-th {
    padding: 0.5rem 0.375rem;
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.dm-th-check   { width: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.dm-th-id      { width: 80px; flex-shrink: 0; }
.dm-th-topic   { width: 68px; flex-shrink: 0; }
.dm-th-content { flex: 1; min-width: 0; }
.dm-th-status  { width: 64px; flex-shrink: 0; }
.dm-th-score   { width: 78px; flex-shrink: 0; text-align: center; }
.dm-th-action  { width: 44px; flex-shrink: 0; text-align: center; }
.dm-th-expand  { width: 28px; flex-shrink: 0; }

.dm-row-wrap {
    border-bottom: 1px solid #f3f4f6;
    transition: background .15s;
}
.dm-row-wrap:last-child { border-bottom: none; }
.dm-row-wrap:hover { background: #fafafe; }
.dm-row-expanded { background: #f8f9fb !important; border-bottom-color: #e5e7eb; }
.dm-row-selected { background: rgba(230,0,126,.02) !important; }

.dm-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background .12s;
}
.dm-td { flex-shrink: 0; padding: 0 0.375rem; }
.dm-td-check   { width: 36px; display: flex; align-items: center; justify-content: center; }
.dm-td-id      { width: 80px; }
.dm-td-topic   { width: 68px; }
.dm-td-content { flex: 1; min-width: 0; }
.dm-td-status  { width: 64px; }
.dm-td-score   { width: 78px; text-align: center; }
.dm-td-action  { width: 44px; display: flex; align-items: center; justify-content: center; }
.dm-td-expand  { width: 28px; display: flex; align-items: center; justify-content: center; }

.dm-td-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #e6007e;
    cursor: pointer;
}

.dm-row-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: all .12s;
}
.dm-row-action-btn:hover { background: #f9fafb; color: #e6007e; border-color: #e6007e; }

/* ═══════════════════════════════
   상태·주제 배지
   ═══════════════════════════════ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1.5px 6px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}
.status-pending    { background: #fef3c7; color: #d97706; }
.status-processing { background: #dbeafe; color: #2563eb; animation: pulse-soft 2s ease-in-out infinite; }
.status-completed  { background: #d1fae5; color: #059669; }
.status-failed     { background: #fee2e2; color: #dc2626; }

@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.tag-badge {
    display: inline-flex;
    padding: 1.5px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    background: #ede9fe;
    color: #7c3aed;
    white-space: nowrap;
}

.dm-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    font-size: 10.5px;
    font-weight: 800;
}
.dm-grade-s { background: rgba(230,0,126,.12); color: #e6007e; }
.dm-grade-a { background: rgba(245,158,11,.1); color: #d97706; }
.dm-grade-b { background: rgba(59,130,246,.1); color: #2563eb; }
.dm-grade-c { background: rgba(107,114,128,.08); color: #6b7280; }
.dm-grade-d { background: rgba(209,213,219,.15); color: #9ca3af; }

.dm-grade-lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 20px;
    font-weight: 800;
}

/* ═══════════════════════════════
   펼침 상세
   ═══════════════════════════════ */
.dm-detail {
    padding: 0 20px 16px;
    background: #fff;
    border-top: 1px solid #eef0f2;
}

.dm-d-status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 12px;
    font-weight: 600;
}
.dm-d-banner-pending    { background: #fef3c7; color: #92400e; }
.dm-d-banner-processing { background: #dbeafe; color: #1e40af; }
.dm-d-banner-completed  { background: #d1fae5; color: #065f46; }
.dm-d-banner-failed     { background: #fee2e2; color: #991b1b; }

.dm-d-banner-inner { display: flex; align-items: center; gap: 6px; }
.dm-d-banner-time { margin-left: 6px; font-size: 10.5px; font-weight: 500; opacity: 0.7; }
.dm-d-banner-err { margin-left: 8px; font-size: 10.5px; font-weight: 500; opacity: 0.8; max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-d-banner-actions { flex-shrink: 0; }

.dm-d-section { margin-bottom: 12px; }
.dm-d-section-analysis { margin-top: 4px; padding-top: 12px; border-top: 1px dashed #e5e7eb; }
.dm-d-section-title {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f3f4f6;
}

.dm-d-meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dm-d-meta { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: #f9fafb; border: 1px solid #f3f4f6; border-radius: 5px; }
.dm-d-meta-label { font-size: 9.5px; font-weight: 600; color: #9ca3af; white-space: nowrap; }
.dm-d-meta-val { font-size: 11px; font-weight: 600; color: #374151; white-space: nowrap; }
.dm-d-meta-topic { color: #7c3aed; background: rgba(124,58,237,.06); padding: 1px 5px; border-radius: 3px; }

.dm-d-raw-content { padding: 10px 12px; background: #fafafa; border: 1px solid #f0f0f0; border-radius: 6px; margin-bottom: 8px; }
.dm-d-raw-label { font-size: 9.5px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.dm-d-raw-text { font-size: 12.5px; color: #1f2937; line-height: 1.75; word-break: break-word; white-space: pre-wrap; }

.dm-d-file-info { display: flex; align-items: center; gap: 8px; font-size: 10px; color: #9ca3af; padding-top: 4px; }
.dm-d-file-row { font-variant-numeric: tabular-nums; font-size: 9.5px; color: #b0b0b0; }

/* ── AI 분석 결과 블록 ── */
.dm-detail-block { padding: 8px 10px; background: #f9fafb; border-radius: 6px; border: 1px solid #f3f4f6; }
.dm-detail-label { font-size: 10.5px; font-weight: 700; color: #6b7280; margin-bottom: 4px; }
.dm-detail-text { font-size: 12px; color: #374151; line-height: 1.6; }

.dm-detail-mini { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; background: #f9fafb; border-radius: 5px; border: 1px solid #f3f4f6; }
.dm-detail-mini-label { font-size: 9.5px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.03em; }
.dm-detail-mini-val { font-size: 12px; font-weight: 600; color: #374151; }

.dm-detail-score-block { display: flex; align-items: center; justify-content: center; }

.dm-dept-tag { display: inline-flex; padding: 2px 6px; border-radius: 3px; font-size: 10px; font-weight: 600; background: rgba(99,102,241,.08); color: #6366f1; }
.dm-kw-tag { display: inline-flex; padding: 2px 6px; border-radius: 3px; font-size: 10px; font-weight: 600; background: rgba(230,0,126,.06); color: #e6007e; }

.dm-btn-reanalyze {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    background: #fff;
    border: 1px solid #d1d5db;
    cursor: pointer;
    transition: all .15s;
}
.dm-btn-reanalyze:hover { background: #f9fafb; border-color: #e6007e; color: #e6007e; }

/* ═══════════════════════════════
   페이지네이션
   ═══════════════════════════════ */
.dm-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0;
}
.dm-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 0.375rem;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    background: #fff;
    color: #6b7280;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .12s;
}
.dm-page-btn:hover:not(:disabled) { background: #f3f4f6; color: #374151; }
.dm-page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.dm-page-btn.active {
    background: #e6007e;
    color: #fff;
    border-color: #e6007e;
}
.dm-page-info {
    font-size: 11px;
    color: #9ca3af;
    margin-left: 0.5rem;
    white-space: nowrap;
}

/* ═══════════════════════════════
   반응형
   ═══════════════════════════════ */
@media (max-width: 1024px) {
    .dm-tb-status { display: none; }
    .dm-th-id, .dm-td-id { display: none; }
    .dm-th-topic, .dm-td-topic { display: none; }
    .dm-th-score, .dm-td-score { display: none; }
}
@media (max-width: 768px) {
    .dm-toolbar { gap: 0.375rem; }
    .dm-tb-file { min-width: 140px; max-width: 200px; }
    .dm-th-action, .dm-td-action { display: none; }
    .dm-search-input { width: 140px; }
    .dm-d-status-banner { flex-direction: column; gap: 6px; align-items: flex-start; }
}
@media (max-width: 640px) {
    .dm-search-input { width: 120px; font-size: 10.5px; }
    .dm-filter-bar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
}
