/*
 * 저장한 보고서 목록 (/saved/)
 */

/* hidden 속성이 display:flex/grid 클래스에 덮여 무력화되는 것 방지 */
[hidden] {
    display: none !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
    background: #f9fafb;
    color: #111827;
    line-height: 1.6;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 64px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn-link {
    color: #2563eb;
    text-decoration: none;
    font-size: 14px;
}

.btn-link:hover {
    text-decoration: underline;
}

.summary-bar {
    margin-bottom: 16px;
    font-size: 14px;
    color: #6b7280;
}

/* --- 카드 --- */

.saved-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.saved-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 18px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.card-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    /* 길이 예측 불가한 배지 묶음이 우측 저장일시를 밀어내지 않게 */
    min-width: 0;
}

.kind-badge,
.category-badge,
.missing-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.kind-badge {
    background: #e0e7ff;
    color: #3730a3;
}

.category-badge {
    background: #f3f4f6;
    color: #374151;
}

.category-market {
    background: #dbeafe;
    color: #1e40af;
}

.category-company {
    background: #dcfce7;
    color: #166534;
}

.category-industry {
    background: #fef3c7;
    color: #92400e;
}

.missing-badge {
    background: #fee2e2;
    color: #991b1b;
}

.saved-at {
    flex: 0 0 auto;
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
}

/* 종목 — 카드에서 가장 먼저 눈에 들어와야 하는 정보 */
.card-stock {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    min-width: 0;
    overflow-wrap: anywhere;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    /* 줄바꿈 없는 초장문 제목도 카드를 넘치게 하지 않는다 */
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 종목이 있으면 제목은 보조 정보로 한 단 낮춘다 */
.card-stock + .card-title {
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
}

.card-meta {
    margin-top: 4px;
    font-size: 13px;
    color: #6b7280;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* --- 요약 블록 (자동 / 내 요약) --- */

.card-block {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    min-width: 0;
}

.auto-summary-block {
    background: #f3f4f6;
    border-left: 3px solid #6366f1;
}

.my-summary-block {
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
}

.block-label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    letter-spacing: 0.02em;
}

.source-tag {
    padding: 1px 6px;
    border-radius: 4px;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.auto-summary-text {
    font-size: 14px;
    color: #374151;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.auto-summary-pending {
    font-size: 13px;
    color: #6b7280;
}

.auto-summary-failed {
    font-size: 13px;
    color: #b91c1c;
    overflow-wrap: anywhere;
}

.btn-link-sm {
    margin-top: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: #2563eb;
    font-size: 12px;
    cursor: pointer;
}

.btn-link-sm:hover:not(:disabled) {
    text-decoration: underline;
}

.card-summary {
    min-width: 0;
}

.summary-text {
    font-size: 14px;
    color: #374151;
    overflow-wrap: anywhere;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.summary-empty {
    font-size: 13px;
    color: #9ca3af;
}

/* --- 인라인 편집 --- */

.card-summary-edit {
    margin-top: 10px;
}

.summary-input {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
}

.summary-input:focus {
    outline: none;
    border-color: #2563eb;
}

.edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* --- 액션 --- */

.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.btn-pdf,
.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 6px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn-pdf {
    background: #2563eb;
    color: #ffffff;
}

.btn-pdf:hover {
    background: #1d4ed8;
}

.btn-primary {
    background: #111827;
    color: #ffffff;
}

.btn-primary:hover {
    background: #1f2937;
}

.btn-secondary {
    background: #ffffff;
    border-color: #d1d5db;
    color: #374151;
}

.btn-secondary:hover {
    background: #f9fafb;
}

.btn-danger {
    background: #ffffff;
    border-color: #fca5a5;
    color: #b91c1c;
}

.btn-danger:hover {
    background: #fef2f2;
}

button:disabled {
    opacity: 0.6;
    cursor: default;
}

/* --- 빈 상태 / 페이지네이션 --- */

.empty-state {
    padding: 48px 20px;
    text-align: center;
    color: #6b7280;
    background: #ffffff;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
}

.empty-state .btn-primary {
    margin-top: 12px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    font-size: 14px;
}

.page-link {
    color: #2563eb;
    text-decoration: none;
}

.page-current {
    color: #6b7280;
}
