/**
 * ============================================================
 * LINKS ACCORDION (링크 아코디언 시스템)
 * ============================================================
 *
 * 역할: 링크 편집 UI의 아코디언 컴포넌트 전체
 *
 * 포함:
 * - 아코디언 컨테이너 (.links-accordion)
 * - 링크 아이템 (.link-item, .link-header, .link-body)
 * - 드래그 핸들 (.link-drag-handle)
 * - 폼 요소 (input, label, button)
 * - 토글 스위치 (.toggle-switch)
 * - 표시방식 선택 (.display-type-btn)
 * - 액션 버튼 (.btn-save, .btn-delete)
 *
 * 출처:
 * - dashboard-main.css (Lines 2806-3338, 533 lines)
 *
 * 의존성:
 * - 1-foundation-variables.css (필수)
 *   - var(--border-color)
 *   - var(--primary-color)
 *   - var(--primary-hover)
 * - Dragula.js (드래그앤드롭)
 *
 * 추출 날짜: 2025-11-05
 * 추출자: Claude Code (css-separation-policy.md 준수)
 * ============================================================
 */

/* 아코디언 컨테이너 */
.links-accordion {
    display: flex;
    flex-direction: column;
    gap: 12px;
    touch-action: pan-y;  /* 🔥 세로 스크롤 허용 */
}

/* 링크 아이템 (아코디언) */
.link-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    touch-action: none;  /* 🔥 드래그 중 스크롤 차단 */
}

.link-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 펼쳐진 아코디언 - 강조 스타일 */
.link-item.expanded {
    border: 2px solid var(--primary-color);
    box-shadow: 0 4px 16px rgba(255, 46, 122, 0.15);
}

/* 아코디언 헤더 - 양쪽 정렬 */
.link-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.link-header:hover {
    background: #f8f9fa;
}

/* 아코디언 열렸을 때 헤더 배경색 */
.link-item.expanded .link-header,
.social-icon-accordion.expanded .link-header {
    background: #f7edea;
}

/* 왼쪽 그룹 */
.link-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.link-header-right {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.link-drag-handle {
    cursor: grab;
    color: #999;
    font-weight: bold;
    font-size: 16px;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.link-drag-handle:hover {
    color: #666;
}

.link-drag-handle:active {
    cursor: grabbing;
}


.link-title {
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
    margin-right: auto;
}

.link-type-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    margin-right: 8px;
}

/* 오른쪽 아이콘 */
.expand-icon {
    width: 18px;
    height: 18px;
    color: #bbbbbb;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.link-type-badge.basic {
    background: #e3f2fd;
    color: #1976d2;
}

.link-type-badge.special {
    background: #f3e5f5;
    color: #7b1fa2;
}

.link-item.expanded .expand-icon {
    transform: rotate(90deg);
}

/* 아코디언 바디 */
.link-body {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    box-sizing: border-box;
}

.link-item.expanded .link-body {
    padding: 16px 20px 20px 20px;
    max-height: 1200px;
}

.link-body .form-group {
    margin-bottom: 16px;
}

/* 세로 배치 폼 그룹 */
.link-body .form-group-stacked {
    margin-bottom: 16px;
    width: 100%;
}

.link-body .form-group-stacked label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #666;
    font-size: 13px;
}

.link-body .form-group-stacked input {
    width: 100% !important;
    max-width: none !important;
    padding: 12px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: #f8f9fa;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.link-body .form-group-stacked input:focus {
    outline: none;
    border-color: #999;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.link-body label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
}

.link-body input[type="text"],
.link-body input[type="url"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.link-body input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* URL 입력 그룹 (URL + 이미지 버튼) */
.url-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.url-input-group input {
    flex: 1;
}

.btn-upload-image-inline {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-upload-image-inline i {
    flex-shrink: 0;
}

.btn-upload-image-inline:hover {
    background: #e5e5e5;
    border-color: #999;
}

.btn-upload-image-inline:active {
    transform: scale(0.98);
}

/* 이미지 썸네일 미리보기 */
.image-thumbnail-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.image-thumbnail-preview img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.btn-delete-thumbnail {
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-delete-thumbnail:hover {
    background: #fee;
    border-color: #f55;
    color: #f55;
}

.btn-delete-thumbnail i {
    width: 16px;
    height: 16px;
}

/* 표시방식 라디오 버튼 (한 줄) */
.display-type-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.display-type-label {
    font-weight: 500;
    color: #666;
    font-size: 14px;
    white-space: nowrap;
}

.display-type-group {
    display: flex;
    gap: 16px;
}

.display-type-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    transition: all 0.2s ease;
}

.display-type-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.display-type-btn input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.display-type-btn input[type="radio"]:checked ~ i {
    color: var(--primary-color);
}

.display-type-btn:has(input[type="radio"]:checked) {
    background: #fff0f6;
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(255, 46, 122, 0.1);
}

.display-type-btn i {
    flex-shrink: 0;
    color: #666;
    transition: color 0.2s ease;
}

.display-type-btn span {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* 링크 액션 버튼 */
.link-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.btn-save {
    flex: 1;
    min-width: 80px;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-save:hover {
    background: var(--primary-hover);
}

.btn-save:active {
    transform: scale(0.98);
}

.btn-save:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-delete {
    padding: 10px 16px;
    background: #fff;
    color: #e74c3c;
    border: 1px solid #e74c3c;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete:hover {
    background: #e74c3c;
    color: white;
}

/* 빨간 삭제 버튼 (이미지 링크용) */
.btn-delete-red {
    flex: 1;
    padding: 10px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete-red:hover {
    background: #c0392b;
}

/* 토글 스위치 */
.toggle-switch-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    vertical-align: middle;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}

.toggle-slider {
    position: relative;
    width: 30px;
    height: 16px;
    background: #ccc;
    border-radius: 16px;
    transition: background 0.3s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::after {
    transform: translateX(14px);
}

.toggle-label {
    font-weight: 600;
    color: #333;
}

.toggle-hint {
    color: #666;
    font-size: 12px;
    margin-left: 62px;
}

/* 컨텐츠 링크 그룹 */
.content-link-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-input-content {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: #f8f9fa;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.link-input-content:focus {
    outline: none;
    border-color: #999;
    background: #fff;
}

.content-link-actions {
    display: flex;
    gap: 8px;
}

.btn-content-edit,
.btn-content-delete {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-content-edit:hover {
    background: #f0f0f0;
    border-color: #999;
}

.btn-content-delete:hover {
    background: #ffe5e5;
    border-color: #e74c3c;
    color: #e74c3c;
}
