/**
 * 파일명: helpdesk-attachments.css
 * 설명: 헬프데스크 첨부 업로더 + 본문 상단 이미지 + 첨부 목록 공통 스타일
 */

/* ========== 글쓰기 모달: 업로더 ========== */
.helpdesk-attach-group {
    border: 1px dashed var(--hc-border, #E2E4F0);
    border-radius: var(--hc-radius-md, 10px);
    padding: 14px 16px;
    background: var(--hc-bg-tertiary, #F7F8FE);
}

.helpdesk-attach-group__label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    color: var(--hc-text-primary, #1A1A2E);
    margin-bottom: 10px;
}

.helpdesk-attach-group__label i {
    color: var(--hc-accent, #4541FF);
}

.helpdesk-attach-group__hint {
    font-weight: 400;
    font-size: 12px;
    color: var(--hc-text-tertiary, #9999BB);
    margin-left: auto;
}

.helpdesk-attach-warn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fef3c7;
    color: #92400e;
    font-size: 13px;
}

.helpdesk-attach-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.helpdesk-attach-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    border: 1px solid var(--hc-border, #E2E4F0) !important;
    background: #ffffff !important;
    color: var(--hc-text-primary, #1A1A2E) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all .15s ease;
}

.helpdesk-attach-btn:hover {
    border-color: var(--hc-accent, #4541FF) !important;
    color: var(--hc-accent, #4541FF) !important;
}

.helpdesk-attach-btn--image i,
.helpdesk-attach-btn--file i {
    font-size: 16px;
}

.helpdesk-attach-progress {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--hc-text-secondary, #555577);
}

.ri-spin {
    animation: helpdesk-attach-spin 1s linear infinite;
}

@keyframes helpdesk-attach-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========== 글쓰기 모달: 미리보기 목록 ========== */
.helpdesk-attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.helpdesk-attach-list:empty {
    display: none;
}

.helpdesk-attach-list[data-section="file"] {
    flex-direction: column;
}

.helpdesk-attach-item {
    position: relative;
    border: 1px solid var(--hc-border, #E2E4F0);
    background: #ffffff;
    border-radius: 10px;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.helpdesk-attach-item--image {
    flex-direction: column;
    width: 130px;
    padding: 0;
    overflow: hidden;
}

.helpdesk-attach-item--image .helpdesk-attach-item__thumb {
    display: block;
    width: 100%;
    height: 100px;
    overflow: hidden;
    background: #f3f4f6;
}

.helpdesk-attach-item--image .helpdesk-attach-item__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.helpdesk-attach-item--image .helpdesk-attach-item__meta {
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--hc-text-secondary, #555577);
    width: 100%;
    box-sizing: border-box;
}

.helpdesk-attach-item--file {
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
}

.helpdesk-attach-item--file > i {
    font-size: 18px;
    color: var(--hc-accent, #4541FF);
}

.helpdesk-attach-item__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--hc-text-primary, #1A1A2E);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.helpdesk-attach-item__size {
    font-size: 11px;
    color: var(--hc-text-tertiary, #9999BB);
    flex-shrink: 0;
}

.helpdesk-attach-item__remove {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: rgba(239, 68, 68, .1);
    color: #ef4444;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease;
}

.helpdesk-attach-item__remove:hover {
    background: rgba(239, 68, 68, .2);
}

.helpdesk-attach-item--image .helpdesk-attach-item__remove {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    border: none;
}

.helpdesk-attach-item--image .helpdesk-attach-item__remove:hover {
    background: rgba(0, 0, 0, .8);
}

/* ========== 게시글 본문 상단: 그림 첨부 표시 ========== */
.helpdesk-header-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 0 0 22px 0;
}

.helpdesk-header-image {
    margin: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #f3f4f6;
    border: 1px solid var(--hc-border, #E2E4F0);
}

.helpdesk-header-image__link {
    display: block;
}

.helpdesk-header-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 540px;
    object-fit: contain;
    background: #ffffff;
}

.helpdesk-header-image__caption {
    padding: 6px 10px;
    font-size: 12px;
    color: var(--hc-text-tertiary, #9999BB);
    background: #ffffff;
    border-top: 1px solid var(--hc-border, #E2E4F0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 단일 그림 1장이면 한 줄 가운데 정렬 */
.helpdesk-header-images:has(> :only-child) {
    grid-template-columns: minmax(0, 720px);
    justify-content: center;
}

/* ========== 게시글 하단: 일반 첨부 파일 목록 ========== */
.helpdesk-attach-section {
    margin-top: 20px;
    padding: 14px 16px;
    border: 1px solid var(--hc-border, #E2E4F0);
    border-radius: 12px;
    background: var(--hc-bg-tertiary, #F7F8FE);
}

.helpdesk-attach-section__title {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--hc-text-primary, #1A1A2E);
    display: flex;
    align-items: center;
    gap: 6px;
}

.helpdesk-attach-section__title i {
    color: var(--hc-accent, #4541FF);
    font-size: 16px;
}

.helpdesk-attach-section__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.helpdesk-attach-section__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid var(--hc-border, #E2E4F0);
    border-radius: 8px;
    transition: border-color .15s ease;
}

.helpdesk-attach-section__item:hover {
    border-color: var(--hc-accent, #4541FF);
}

.helpdesk-attach-section__item > i {
    font-size: 18px;
    color: var(--hc-accent, #4541FF);
    flex-shrink: 0;
}

.helpdesk-attach-section__item a {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: var(--hc-text-primary, #1A1A2E);
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.helpdesk-attach-section__item a:hover {
    color: var(--hc-accent, #4541FF);
    text-decoration: underline;
}

.helpdesk-attach-section__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.helpdesk-attach-section__size {
    font-size: 11px;
    color: var(--hc-text-tertiary, #9999BB);
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .helpdesk-attach-item--image {
        width: calc(50% - 5px);
    }

    .helpdesk-header-images {
        grid-template-columns: 1fr;
    }
}

/* ========== HTML 본문 업로더 (글쓰기 모달) ========== */
.helpdesk-htmlbody-group {
    border: 1px dashed #c084fc;
    border-radius: var(--hc-radius-md, 10px);
    padding: 14px 16px;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    margin-bottom: 14px;
}

.helpdesk-htmlbody-group__label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-weight: 700;
    font-size: 14px;
    color: #5b21b6;
    margin-bottom: 10px;
}

.helpdesk-htmlbody-group__label i {
    color: #7c3aed;
    font-size: 18px;
}

.helpdesk-htmlbody-group__hint {
    font-weight: 400;
    font-size: 12px;
    color: #7c3aed;
    margin-left: auto;
}

.helpdesk-htmlbody-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.helpdesk-htmlbody-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    border: 1px solid #7c3aed !important;
    background: #7c3aed !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all .15s ease;
}

.helpdesk-htmlbody-btn:hover {
    background: #6d28d9 !important;
    border-color: #6d28d9 !important;
}

.helpdesk-htmlbody-btn i {
    font-size: 16px;
}

.helpdesk-htmlbody-clear {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: #6b7280 !important;
    border: 1px solid #d1d5db !important;
    font-size: 12px !important;
    cursor: pointer;
}

.helpdesk-htmlbody-clear:hover {
    color: #ef4444 !important;
    border-color: #ef4444 !important;
}

.helpdesk-htmlbody-progress {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #7c3aed;
}

.helpdesk-htmlbody-status {
    margin-top: 6px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #e9d5ff;
    border-radius: 8px;
    font-size: 13px;
    color: #5b21b6;
    display: flex;
    align-items: center;
    gap: 6px;
}

.helpdesk-htmlbody-status i {
    color: #16a34a;
    font-size: 16px;
}

.helpdesk-htmlbody-status__size {
    color: #6b7280;
    font-size: 11px;
}

.helpdesk-htmlbody-help {
    margin: 8px 0 0;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
}

/* ========== 편집 모드 — 기존 HTML 본문 상태 ========== */
.helpdesk-htmlbody-existing {
    margin-top: 8px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid #d8b4fe;
    border-radius: 8px;
}

.helpdesk-htmlbody-existing__row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: #5b21b6;
}

.helpdesk-htmlbody-existing__row > i {
    font-size: 18px;
    color: #7c3aed;
    flex-shrink: 0;
}

.helpdesk-htmlbody-existing__label {
    flex: 1;
    min-width: 0;
    word-break: break-all;
}

.helpdesk-htmlbody-existing__size {
    color: #9ca3af;
    font-weight: 400;
    font-size: 11px;
}

.helpdesk-htmlbody-existing__view {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 4px 10px !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    color: #7c3aed !important;
    background: #faf5ff !important;
    border: 1px solid #e9d5ff !important;
    text-decoration: none !important;
}

.helpdesk-htmlbody-existing__view:hover {
    background: #f3e8ff !important;
}

.helpdesk-htmlbody-existing__remove {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 5px 10px !important;
    border-radius: 6px !important;
    background: #fff !important;
    color: #ef4444 !important;
    border: 1px solid #fecaca !important;
    font-size: 12px !important;
    cursor: pointer;
}

.helpdesk-htmlbody-existing__remove:hover {
    background: #fef2f2 !important;
    border-color: #ef4444 !important;
}

.helpdesk-htmlbody-existing__row--marked {
    color: #b45309;
    background: #fef3c7;
    margin: -10px -12px;
    padding: 10px 12px;
    border-radius: 7px;
}

.helpdesk-htmlbody-existing__row--marked > i {
    color: #d97706;
}

.helpdesk-htmlbody-existing__undo {
    margin-left: auto;
    padding: 4px 10px !important;
    background: #ffffff !important;
    color: #b45309 !important;
    border: 1px solid #fcd34d !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    cursor: pointer;
}

.helpdesk-htmlbody-existing__hint {
    margin: 8px 0 0;
    font-size: 11px;
    color: #6b7280;
}

/* ========== HTML 본문 — 게시글 보기에서 다운로드 링크 ========== */
.helpdesk-htmlbody-download {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border: 1px solid #d8b4fe;
    border-radius: 10px;
    margin-bottom: 16px;
    color: #5b21b6;
    font-size: 13px;
}

.helpdesk-htmlbody-download > i {
    font-size: 22px;
    color: #7c3aed;
    flex-shrink: 0;
}

.helpdesk-htmlbody-download__label {
    flex: 1;
    min-width: 0;
    font-weight: 600;
}

.helpdesk-htmlbody-download__btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 6px 12px !important;
    border-radius: 8px !important;
    background: #7c3aed !important;
    color: #fff !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    text-decoration: none !important;
    border: none !important;
}

.helpdesk-htmlbody-download__btn:hover {
    background: #6d28d9 !important;
    color: #fff !important;
}

.helpdesk-htmlbody-download__btn i {
    font-size: 14px;
}

.helpdesk-htmlbody-download__size {
    opacity: .85;
    font-weight: 400;
}

/* HTML 본문 iframe 컨테이너 — 조인자료실 동일 격리 방식 (별도 문서 컨텍스트, 누수 없음) */
.helpdesk-html-body-iframe-wrap {
    position: relative;
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--hc-border, #E2E4F0);
    border-radius: 12px;
    overflow: hidden;
    margin: 0;
}

.helpdesk-html-body-iframe {
    display: block;
    width: 100%;
    /* 본문 분량을 충분히 보여주도록 모달/단일 페이지에서 큰 높이 사용 */
    height: 75vh;
    min-height: 520px;
    border: 0;
    background: #ffffff;
}

/* 단일 글 페이지에서는 좀 더 여유 있게 */
.helpdesk-html-body-iframe-wrap--single .helpdesk-html-body-iframe {
    height: 85vh;
    min-height: 640px;
}

@media (max-width: 768px) {
    .helpdesk-html-body-iframe {
        height: 70vh;
        min-height: 480px;
    }
    .helpdesk-html-body-iframe-wrap--single .helpdesk-html-body-iframe {
        height: 80vh;
        min-height: 520px;
    }
}

@media (max-width: 640px) {
    .helpdesk-htmlbody-download {
        flex-direction: column;
        align-items: stretch;
    }

    .helpdesk-htmlbody-download__btn {
        justify-content: center;
    }
}
