/* ============================================================
   리브레토 마케팅 — 도서 메타/보도자료 통합 작성기 (Phase 3 / T3)
   - 모든 색/간격 = styles.css CSS 변수
   - 모바일 = PC 동일 동작 (3섹션 탭/아코디언, sticky 액션, 풀스크린)
   - .pr-* 네임스페이스
   ============================================================ */

/* ===== 패널 컨테이너 ===== */
#panelPressrelease {
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

.pr-root {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100%;
    font-family: var(--font-sans);
    position: relative;
}

/* ===== 좌측 사이드 (프로젝트 리스트) ===== */
.pr-side {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}
.pr-side__header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
    position: sticky; top: 0; z-index: 1;
}
.pr-side__title {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.pr-new-btn {
    width: 100%;
    height: 38px;
    font-size: 13px;
}
.pr-side__list {
    padding: 8px 8px 24px;
    flex: 1;
}
.pr-side__empty {
    padding: 24px 12px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}
.pr-side__group {
    margin-bottom: 14px;
}
.pr-side__group-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin: 8px 8px 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
    line-height: 1.4;
}
.pr-side__item {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background .12s, border-color .12s;
    font-family: inherit;
}
.pr-side__item:hover {
    background: var(--bg-white);
}
.pr-side__item.is-active {
    background: var(--bg-white);
    border-color: var(--sage);
    box-shadow: 0 0 0 2px rgba(111, 143, 114, .12);
}
.pr-side__item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.pr-side__item-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 10px;
}
.pr-side__status {
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-muted);
}
.pr-side__status--draft     { background: var(--bg-tertiary); color: var(--text-muted); }
.pr-side__status--generated { background: var(--blue-light);  color: var(--blue); }
.pr-side__status--saved     { background: var(--sage-light);  color: var(--sage-dark); }
.pr-side__status--published { background: var(--amber-light); color: var(--amber); }
.pr-side__date {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

/* 모바일 — 사이드 토글 버튼 (데스크톱은 숨김) */
.pr-side-toggle {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + 12px);
    left: 12px;
    z-index: 10;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}
.pr-side-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 19;
}

/* ===== 우측 메인 ===== */
.pr-main {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

.pr-empty {
    padding: 80px 32px;
    text-align: center;
    color: var(--text-muted);
}
.pr-empty__icon { font-size: 48px; opacity: .6; margin-bottom: 14px; }
.pr-empty__title {
    font-family: var(--font-serif);
    font-size: 18px;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.pr-empty__desc {
    font-size: 13px;
    line-height: 1.6;
    margin: 0 0 18px;
}

.pr-work {
    padding: 24px 28px 120px;
    max-width: 920px;
    margin: 0 auto;
}

/* 작업 헤더 */
.pr-work__header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.pr-title-input {
    flex: 1;
    min-width: 240px;
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    transition: border-color .12s, background .12s;
}
.pr-title-input:hover { background: var(--bg-secondary); }
.pr-title-input:focus {
    outline: none;
    border-color: var(--sage);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(111,143,114,.18);
}
.pr-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}
.pr-delete-btn {
    color: var(--red);
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

/* 책 메타 점검 카드 */
.pr-meta-check {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 18px;
}
.pr-meta-check__head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.pr-meta-check__cover {
    width: 56px;
    height: 75px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}
.pr-meta-check__cover--ph {
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: var(--text-muted); opacity: .4;
}
.pr-meta-check__title-wrap { flex: 1; min-width: 0; }
.pr-meta-check__title {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text-primary);
}
.pr-meta-check__subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 8px;
}
.pr-meta-check__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.pr-meta-check__chip {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    font-family: var(--font-mono);
}
.pr-meta-check__missing {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-light);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.pr-meta-check__missing-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--red);
}
.pr-meta-check__missing-item {
    font-size: 11px;
    padding: 2px 7px;
    background: var(--red-light, #fde8e8);
    color: var(--red);
    border-radius: 999px;
}
.pr-meta-check__edit {
    font-size: 11px;
    height: 26px;
    padding: 0 10px;
    margin-left: auto;
}
.pr-meta-check__ok {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-light);
    font-size: 11px;
    color: var(--sage-dark);
    font-weight: 600;
}
.pr-meta-check__row--missing {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--red);
    font-size: 13px;
}

/* 인풋 영역 */
.pr-input { margin-bottom: 20px; }
.pr-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.pr-textarea {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 120px;
}
.pr-textarea:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(111,143,114,.18);
}
.pr-input__actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}
.pr-suggest-excerpt {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

/* ===== 결과 영역 (3섹션 탭) ===== */
.pr-output {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    overflow: hidden;
}
.pr-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
}
.pr-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: color .12s, border-color .12s, background .12s;
}
.pr-tab:hover { background: var(--bg-white); color: var(--text-primary); }
.pr-tab.is-active {
    color: var(--text-primary);
    border-bottom-color: var(--sage);
    background: var(--bg-white);
    font-weight: 600;
}
.pr-tab__num {
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--sage);
    color: white;
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
}
.pr-tab:not(.is-active) .pr-tab__num {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.pr-section {
    display: none;
    padding: 20px;
}
.pr-section.is-active { display: block; }

.pr-section__cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.pr-section__blocks {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pr-section__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border-light);
}
.pr-section__toolbar .btn {
    height: 30px;
    padding: 0 10px;
    font-size: 11px;
}

/* ===== 카드 (메타/채널 공용) ===== */
.pr-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}
.pr-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.pr-card__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}
.pr-card__mark {
    font-size: 14px;
    color: var(--sage);
}
.pr-counter {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
.pr-counter.is-good { color: var(--sage-dark); font-weight: 700; }
.pr-counter.is-warn { color: var(--amber); font-weight: 700; }

.pr-output-edit {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    resize: vertical;
    min-height: 76px;
}
.pr-output-edit:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(111,143,114,.18);
}
.pr-output-edit--block { min-height: 140px; }

.pr-card__actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.pr-card__actions .btn {
    height: 30px;
    padding: 0 10px;
    font-size: 11px;
}

/* 채널별 색상 변주 */
.pr-channel--aladin .pr-card__mark { color: #d4940f; }
.pr-channel--aladin { border-left: 3px solid #d4940f; }
.pr-channel--yes24  .pr-card__mark { color: var(--sage-dark); }
.pr-channel--yes24  { border-left: 3px solid var(--sage); }
.pr-channel--kyobo  .pr-card__mark { color: var(--blue); }
.pr-channel--kyobo  { border-left: 3px solid var(--blue); }

/* ===== 보도자료 6블록 ===== */
.pr-block {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}
.pr-block__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.pr-block__icon {
    font-size: 16px;
    color: var(--sage);
}
.pr-block__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}
.pr-block__actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.pr-block__actions .btn {
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
}

/* ===== sticky 액션 (모바일에서 더 두드러짐) ===== */
.pr-actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--bg-primary) 0%, var(--bg-primary) 60%, transparent 100%);
    padding: 18px 0 14px;
    margin-top: 24px;
    display: flex;
    justify-content: center;
    z-index: 5;
}
.pr-generate-all {
    min-width: 240px;
    height: 48px;
    font-size: 14px;
    font-weight: 700;
}
.pr-generate-all:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* ===== 책 선택 모달 (picker) ===== */
.pr-picker {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.pr-picker__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(2px);
}
.pr-picker__panel {
    position: relative;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 460px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}
.pr-picker__header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pr-picker__header h3 {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 15px;
    font-weight: 700;
}
.pr-picker__close {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px; height: 32px;
}
.pr-picker__search {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
}
.pr-picker__input {
    width: 100%;
    box-sizing: border-box;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
}
.pr-picker__input:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(111,143,114,.18);
}
.pr-picker__list {
    list-style: none;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.pr-picker__list li { margin: 0; }
.pr-picker__item {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: inherit;
}
.pr-picker__item:hover {
    background: var(--bg-secondary);
    border-color: var(--sage);
}
.pr-picker__item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.pr-picker__item-meta {
    font-size: 11px;
    color: var(--text-muted);
}
.pr-picker__empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

body.pr-picker-open { overflow: hidden; }

/* ===== 모바일 (≤768px) ===== */
@media (max-width: 768px) {
    #panelPressrelease {
        left: 0;
    }
    .pr-root {
        grid-template-columns: 1fr;
    }
    .pr-side {
        position: fixed;
        top: var(--header-height);
        bottom: 0;
        left: 0;
        width: 280px;
        max-width: 84vw;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform .22s ease;
    }
    .pr-side.is-open { transform: translateX(0); }
    .pr-side-toggle { display: inline-flex; }
    .pr-side-overlay.is-visible { display: block; }

    .pr-main {
        padding-top: 50px; /* 사이드 토글 자리 확보 */
    }
    .pr-work {
        padding: 16px 14px 120px;
    }
    .pr-title-input {
        font-size: 16px;            /* iOS 줌 방지 */
        min-height: 44px;
    }
    .pr-status {
        margin-left: 0;
        order: 3;
        flex-basis: 100%;
    }
    .pr-textarea {
        font-size: 16px;             /* iOS 줌 방지 */
        min-height: 100px;
    }
    .pr-output-edit {
        font-size: 16px;
    }

    /* 탭 → 아코디언 (3섹션 모두 노출) */
    .pr-tabs {
        position: sticky;
        top: 0;
        z-index: 4;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    .pr-tab {
        min-width: 110px;
        scroll-snap-align: start;
        font-size: 12px;
        padding: 12px 8px;
    }
    .pr-tab__label { font-size: 12px; }
    .pr-section { padding: 16px 14px; }

    .pr-meta-check__head { gap: 10px; }
    .pr-meta-check__cover { width: 48px; height: 64px; }

    .pr-actions {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        margin: 0;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
        background: var(--bg-primary);
        border-top: 1px solid var(--border-light);
    }
    .pr-generate-all {
        width: 100%;
        min-width: 0;
    }

    .pr-card__actions .btn,
    .pr-block__actions .btn {
        height: 36px;
        padding: 0 12px;
        font-size: 12px;
        flex: 1;
        min-width: 100px;
    }
}
