/**
 * ============================================================================
 * assets/css/tool-image-edit.css - [이미지 편집] 전용 격리 스타일시트
 * ============================================================================
 * 스크린샷 1, 2, 3, 4번 100% 일치 디자인 시스템
 */

/* --------------------------------------------------------------------------
   1. 메인 작업 영역 및 상단 카드 그리드 (스크린샷 4번)
   -------------------------------------------------------------------------- */
.tool-image-edit .image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    width: 100%;
    padding: 10px 0;
}

/* 개별 사진 카드 */
.tool-image-edit .image-card {
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
}

.tool-image-edit .image-card:hover {
    border-color: #8b5cf6;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* 선택된 카드 (스크린샷 4번 보라색 테두리) */
.tool-image-edit .image-card.selected {
    border: 2px solid #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.tool-image-edit .image-thumb-wrap {
    width: 100%;
    height: 100px;
    background-color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid #f1f5f9;
}

.tool-image-edit .image-thumb {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.tool-image-edit .card-body {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #ffffff;
}

.tool-image-edit .card-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-image-edit .card-resolution {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-image-edit .card-btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 4px;
}

.tool-image-edit .btn-card-action {
    padding: 4px 6px;
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.tool-image-edit .btn-card-action:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.tool-image-edit .btn-card-action.btn-del:hover {
    background: #fee2e2;
    color: var(--color-danger);
    border-color: #fca5a5;
}

/* --------------------------------------------------------------------------
   2. 사진 클릭 시 아래쪽에 크게 나오는 [대형 뷰어] 영역 (스크린샷 4번)
   -------------------------------------------------------------------------- */
.tool-image-edit .bottom-preview-container {
    width: 100%;
    margin-top: 20px;
    padding: 20px;
    background: #f8fafc;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    position: relative;
    overflow: hidden;
}

.tool-image-edit .bottom-preview-canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 480px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    background: #ffffff;
    border-radius: 4px;
    overflow: hidden;
}

.tool-image-edit #bottom-preview-canvas {
    max-width: 100%;
    max-height: 460px;
    display: block;
    object-fit: contain;
}

.tool-image-edit .bottom-preview-guide {
    position: absolute;
    bottom: 12px;
    left: 16px;
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* --------------------------------------------------------------------------
   3. 우측 [이미지 설정] 사이드바 컴포넌트 (스크린샷 1, 2, 4번 100% 일치)
   -------------------------------------------------------------------------- */
.height-fit-box {
    border: 1.5px solid #c7d2fe;
    background: #fdfdfe;
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.height-fit-box .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
}

.height-fit-box .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #8b5cf6;
}

.height-fit-subtext {
    font-size: 11px;
    color: var(--text-muted);
}

.setting-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* 테두리 색상 선택 박스 */
.color-picker-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #ffffff;
}

.color-picker-box input[type="color"] {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 0;
}

.color-picker-box span {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 워터마크 파일 선택 행 */
.watermark-file-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.watermark-file-display {
    flex: 1;
    padding: 7px 10px;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fafbfc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-file-search {
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.btn-file-search:hover {
    background: var(--bg-muted);
}

.btn-delete-logo {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    width: fit-content;
}

.btn-delete-logo:hover {
    background: var(--bg-muted);
    color: var(--color-danger);
}

/* 3x3 9방향 워터마크 위치 버튼 그리드 */
.wm-pos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 6px;
}

.wm-pos-btn {
    padding: 8px 4px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.15s;
    user-select: none;
}

.wm-pos-btn .pos-icon {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.wm-pos-btn:hover {
    background: var(--bg-muted);
    border-color: #cbd5e1;
}

.wm-pos-btn.active {
    border: 2px solid #8b5cf6;
    background: #f5f3ff;
    color: #6d28d9;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   4. 더블클릭 시 열리는 [사진 정밀 편집] 팝업 모달 (스크린샷 3번 100% 일치)
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn 0.2s ease-out;
}

.modal-window {
    background: #ffffff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 95vw;
    max-width: 1240px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 모달 헤더 (스크린샷 3번) */
.modal-top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
}

.modal-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-main-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
}

.modal-file-name {
    font-size: 11.5px;
    color: var(--text-muted);
}

.btn-modal-close-round {
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-modal-close-round:hover {
    border-color: #8b5cf6;
    color: #6d28d9;
    background: #f5f3ff;
}

/* 모달 상단 10대 도구 툴바 (스크린샷 3번) */
.modal-tools-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.modal-tool-btn {
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 600;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-tool-btn:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.modal-tool-btn.active {
    border: 1.5px solid #8b5cf6;
    color: #6d28d9;
    background: #f5f3ff;
    font-weight: 700;
}

/* 모달 본문 (중앙 캔버스 + 우측 패널) */
.modal-main-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 280px;
    overflow: hidden;
}

.modal-canvas-area {
    background-color: #f1f3f9;
    background-image: 
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: auto;
    position: relative;
    user-select: none;
}

.modal-canvas-container {
    position: relative;
    display: inline-block;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    background: #ffffff;
}

#editor-canvas {
    display: block;
    max-width: 100%;
    max-height: 520px;
}

/* 자르기 점선 박스 (스크린샷 3번 보라색 점선) */
.modal-crop-box {
    position: absolute;
    border: 2px dashed #8b5cf6;
    background: rgba(139, 92, 246, 0.08);
    cursor: move;
    box-sizing: border-box;
    display: none;
    z-index: 10;
}

.modal-crop-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ffffff;
    border: 2px solid #8b5cf6;
    border-radius: 1px;
}

.modal-crop-handle.tl { top: -4px; left: -4px; cursor: nwse-resize; }
.modal-crop-handle.tr { top: -4px; right: -4px; cursor: nesw-resize; }
.modal-crop-handle.bl { bottom: -4px; left: -4px; cursor: nesw-resize; }
.modal-crop-handle.br { bottom: -4px; right: -4px; cursor: nwse-resize; }

/* 우측 사이드바 탭 (스크린샷 3번) */
.modal-side-panel {
    background: #ffffff;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.modal-tab-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 10px 14px;
    gap: 6px;
    border-bottom: 1px solid var(--border-color);
    background: #fafbfc;
}

.modal-tab-btn {
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.modal-tab-btn.active {
    background: #ede9fe;
    color: #6d28d9;
    border-color: #8b5cf6;
}

.modal-tab-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-info-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel-info-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-info-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

.btn-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.btn-modal-action {
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.15s;
}

.btn-modal-action:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.dim-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* 모달 하단 푸터 바 (스크린샷 3번) */
.modal-bottom-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    border-top: 1px solid var(--border-color);
    background: #fafbfc;
    gap: 16px;
}

.modal-footer-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-footer-center {
    flex: 1;
    font-size: 11.5px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-modal-footer {
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-secondary);
}

.btn-modal-footer:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.btn-modal-footer.btn-apply {
    background: #8b5cf6;
    border-color: #8b5cf6;
    color: #ffffff;
    font-weight: 700;
}

.btn-modal-footer.btn-apply:hover {
    background: #7c3aed;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}
