@charset "utf-8";
@import url('style.css');

/* ===== Character Interaction - Write Styles ===== */

.ci-write-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== 프로필 소스 선택 ===== */
.ci-profile-source-section {
    border: 2px dashed var(--btn-accent-bg, #667eea);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.ci-profile-source-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ci-profile-options {
    display: flex;
    gap: 16px;
}

.ci-profile-option {
    flex: 1;
    cursor: pointer;
}

.ci-profile-option input[type="radio"] {
    display: none;
}

.ci-profile-option .ci-option-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: var(--ci-bg);
    border: 2px solid var(--ci-border);
    border-radius: var(--ci-radius-lg);
    transition: all 0.3s ease;
    text-align: center;
}

.ci-profile-option .ci-option-box i {
    font-size: 28px;
    color: var(--ci-text-muted);
    transition: all 0.3s ease;
}

.ci-profile-option .ci-option-box strong {
    font-size: 14px;
    color: var(--ci-text);
}

.ci-profile-option .ci-option-box small {
    font-size: 12px;
    color: var(--ci-text-muted);
}

.ci-profile-option input[type="radio"]:checked + .ci-option-box {
    border-color: var(--btn-accent-bg, #667eea);
    background: rgba(102, 126, 234, 0.1);
}

.ci-profile-option input[type="radio"]:checked + .ci-option-box i {
    color: var(--btn-accent-bg, #667eea);
}

.ci-profile-option:hover .ci-option-box {
    border-color: var(--btn-accent-bg, #667eea);
}

.ci-profile-select-wrap {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px;
    background: var(--ci-bg);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
}

.ci-profile-select-wrap .ci-label {
    margin-bottom: 6px;
}

.ci-profile-select-wrap .ci-select {
    flex: 1;
}

.ci-btn-load-profile {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--btn-accent-bg, #667eea);
    color: var(--btn-accent-text, #fff);
    border: none;
    border-radius: var(--ci-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.ci-btn-load-profile:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .ci-profile-options {
        flex-direction: column;
    }

    .ci-profile-select-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .ci-profile-select-wrap > div {
        width: 100%;
    }

    .ci-btn-load-profile {
        width: 100%;
        justify-content: center;
    }
}

/* Section */
.ci-section {
    background: var(--ci-bg);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.ci-section-title {
    /* margin: 0 0 20px; */
    font-size: 16px;
    font-weight: 700;
    color: var(--ci-text);
    padding-bottom: 12px;
    /* border-bottom: 1px solid var(--ci-border); */
    display: flex;
    align-items: center;
}

.ci-section-title::before {
    content: '✦';
    margin-right: 5px;
}

/* Form Elements */
.ci-form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

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

.ci-form-group.half { flex: 1; }
.ci-form-group.third { flex: 1; }

.ci-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ci-text);
}

.ci-label .required {
    color: var(--error-color);
}

/* Color Picker */
.ci-color-picker {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ci-color-input {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
    cursor: pointer;
}

.ci-color-picker .color-text {
    width: 90px;
}

/* Upload Grid */
.ci-upload-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.ci-upload-box {
    border: 1px dashed var(--ci-border);
    border-radius: var(--ci-radius);
    padding: 16px;
    text-align: center;
}

.ci-upload-header {
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ci-text);
}

.ci-upload-header i {
    margin-right: 6px;
    color: var(--ci-text-muted);
}

.ci-file-input {
    display: none;
}

.ci-file-label:hover {
    border-color: var(--btn-accent-bg);
    color: var(--btn-accent-bg);
}

.ci-url-inputs {
    margin-top: 12px;
}

.ci-url-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.ci-url-input {
    flex: 1;
    font-size: 12px;
    padding: 8px;
}

.ci-btn-add-url,
.ci-btn-remove-url {
    width: 32px;
    height: 32px;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
    background: var(--ci-bg);
    cursor: pointer;
    font-size: 12px;
}

.ci-btn-add-url:hover { border-color: var(--success-color); color: var(--success-color); }
.ci-btn-remove-url:hover { border-color: var(--error-color); color: var(--error-color); }

/* Preview */
.ci-preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.ci-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--ci-radius);
    overflow: hidden;
    border: 1px solid var(--ci-border);
    cursor: grab;
    transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
}

.ci-preview-item:active {
    cursor: grabbing;
}

.ci-preview-item.dragging {
    opacity: 0.5;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 100;
}

.ci-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ci-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--error-color);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
}

.ci-preview-new-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    padding: 1px 4px;
    background: var(--success-color);
    color: #fff;
    font-size: 8px;
    border-radius: 2px;
}

/* URL 미리보기 */
.ci-preview-item.url-preview .ci-preview-new-badge {
    background: var(--info-color, #17a2b8);
}

.ci-preview-item.url-preview.error {
    border-color: var(--danger-color, #dc3545);
    background: rgba(220, 53, 69, 0.1);
}

.ci-preview-item.url-preview.error img {
    opacity: 0.5;
    filter: grayscale(1);
}

/* Editor */
.ci-editor-wrap {
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
    overflow: hidden;
}

.ci-editor {
    min-height: 200px;
    border: none;
    border-radius: 0;
}

/* Tabs Editor */
.ci-tabs-editor {
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
    overflow: hidden;
}

.ci-tab-nav {
    display: flex;
    background: var(--gray-100, #f5f5f5);
    border-bottom: 1px solid var(--ci-border);
}

.ci-tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--ci-text-muted);
    cursor: pointer;
    transition: var(--ci-transition);
}

.ci-tab-btn:hover {
    color: var(--ci-text);
}

.ci-tab-btn.active {
    color: var(--btn-accent-text, #333);
    border-bottom-color: var(--btn-accent-text, #333);
    background: var(--btn-accent-bg);
}

/* 동적 탭 추가/삭제 버튼 */
.ci-tab-btn .ci-tab-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    font-size: 10px;
    color: var(--ci-text-muted);
    border-radius: 50%;
    opacity: 0;
    transition: var(--ci-transition);
}

.ci-tab-btn:hover .ci-tab-remove {
    opacity: 1;
}

.ci-tab-btn .ci-tab-remove:hover {
    background: var(--error-color);
    color: #fff;
}

.ci-tab-btn.ci-tab-add {
    flex: 0;
    min-width: 44px;
    color: var(--ci-text-muted);
    border-bottom: 2px solid transparent;
    background: transparent;
}

.ci-tab-btn.ci-tab-add:hover {
    color: var(--success-color);
    background: rgba(39, 174, 96, 0.1);
}

.ci-tab-contents {
}

.ci-tab-content {
    display: none;
}

.ci-tab-content.active {
    display: block;
}

.ci-tab-content .ra0-editor-wrapper {
    border-radius: 0px;
}

/* Stats */
.ci-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.ci-stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ci-stat-label {
    min-width: 80px;
    font-size: 13px;
    color: var(--ci-text);
}

.ci-stat-bar {
    flex: 1;
    height: 8px;
    background: var(--gray-200, #eee);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.ci-stat-fill {
    height: 100%;
    background: var(--primary-color, #667eea);
    border-radius: 4px;
}

.ci-stat-value {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Custom Stats */
.ci-custom-stats {
    margin-bottom: 12px;
}

.ci-custom-stat-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.ci-custom-stat-row .stat-name {
    flex: 2;
}

.ci-custom-stat-row .stat-value {
    width: 100px;
}

.ci-btn-remove-stat, .ci-btn-add-stat {
    padding: 8px 16px;
    border: 0;
    border-radius: var(--btn-primary-radius);
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: 13px;
    cursor: pointer;
}

.ci-btn-remove-stat {
    width: 40px;
    padding: 8px;
}

.ci-btn-remove-stat:hover { border-color: var(--error-color); color: var(--error-color); }
.ci-btn-add-stat:hover { border-color: var(--success-color); color: var(--success-color); }

/* Relations */
.ci-relation-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.ci-relation-search-wrap { flex: 1; position: relative; }
.ci-relation-search-wrap .relation-search { width: 100%; box-sizing: border-box; }
.ci-relation-row .relation-type { width: 120px; }
.ci-relation-row .relation-desc { flex: 2; }

.ci-relation-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--ci-bg, #fff);
    border: 1px solid var(--ci-border, #e0e0e0);
    border-radius: 0 0 var(--ci-radius, 8px) var(--ci-radius, 8px);
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.ci-relation-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ci-text, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ci-relation-dropdown-item:hover {
    background: var(--btn-primary-bg, #f0f0f0);
    color: var(--btn-primary-text, #333);
}

.ci-relation-dropdown-empty {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--ci-text-muted, #888);
}

.ci-btn-remove-relation,
.ci-btn-add-relation {
    padding: 8px 16px;
    border: 0;
    border-radius: var(--btn-primary-radius);
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: 13px;
    cursor: pointer;
}

.ci-btn-remove-relation {
    width: 40px;
    padding: 8px;
}

.ci-btn-remove-relation:hover { border-color: var(--error-color); color: var(--error-color); }
.ci-btn-add-relation:hover { border-color: var(--success-color); color: var(--success-color); }

/* iframe 탭 */
.ci-iframe-tabs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ci-iframe-tab-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ci-iframe-tab-row .iframe-tab-title { width: 120px; }
.ci-iframe-tab-row .iframe-tab-type { width: 100px; }
.ci-iframe-tab-row .iframe-tab-board,
.ci-iframe-tab-row .iframe-tab-content,
.ci-iframe-tab-row .iframe-tab-url { flex: 1; }

.ci-btn-add-iframe-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    margin-top: 10px;
    background: transparent;
    border: 1px dashed var(--ci-border);
    border-radius: var(--ci-radius);
    color: var(--ci-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.ci-btn-remove-iframe-tab {
    width: 40px;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
    color: var(--ci-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.ci-btn-remove-iframe-tab:hover { border-color: var(--error-color); color: var(--error-color); }
.ci-btn-add-iframe-tab:hover { border-color: var(--success-color); color: var(--success-color); }

/* Submit */
.ci-submit-area {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 24px 0;
}

.ci-btn-submit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 40px;
    background: var(--btn-primary-bg, #333);
    color: var(--btn-primary-text, #fff);
    border: none;
    border-radius: var(--ci-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.ci-btn-submit:hover {
    opacity: 0.9;
}

.ci-btn-cancel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 30px;
    background: var(--ci-bg);
    color: var(--ci-text);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
    font-size: 15px;
    text-decoration: none;
}

.ci-btn-cancel:hover {
    border-color: var(--ci-text-muted);
}

/* ===== 파일 첨부 영역 ===== */
.ci-dropzone {
    border: 2px dashed var(--ci-border);
    border-radius: var(--ci-radius);
    text-align: center;
    background: var(--ci-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    padding: 30px 20px;
}

.ci-dropzone:hover {
    border-color: var(--btn-accent-bg);
    background: rgba(0,0,0,0.02);
}

.ci-dropzone.dragover {
    border-color: var(--success-color);
    background: rgba(39, 174, 96, 0.05);
    transform: scale(1.01);
}

.ci-dz-message i {
    font-size: 36px;
    color: var(--ci-text-muted);
    display: block;
    margin-bottom: 10px;
}

.ci-dz-message p {
    font-size: 14px;
    color: var(--ci-text);
    margin: 0 0 5px 0;
    font-weight: 500;
}

.ci-dz-note {
    font-size: 12px;
    color: var(--ci-text-muted);
}

/* 파일 미리보기 그리드 */
.ci-file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 10px;
}

/* 파일 카드 */
.ci-file-card {
    position: relative;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius);
    background: var(--ci-bg);
    transition: all 0.2s ease;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
}

.ci-file-card:hover {
    border-color: var(--btn-accent-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ci-file-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ci-file-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100, #f5f5f5);
}

.ci-file-icon i {
    font-size: 32px;
    color: var(--ci-text-muted);
}

/* 파일 라벨 */
.ci-file-label {
    padding: 2px 6px;
    color: var(--content-font-color);
    font-size: 10px;
    font-weight: 600;
    border-radius: 3px;
    font-family: monospace;
}

/* 삭제 버튼 */
.ci-file-card .ci-btn-remove-file {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    z-index: 2;
    font-size: 10px;
}

.ci-file-card:hover .ci-btn-remove-file {
    opacity: 1;
}

.ci-file-card .ci-btn-remove-file:hover {
    background: rgba(220, 38, 38, 1);
    transform: scale(1.1);
}

/* 플레이스홀더 배지 (에디터 내) */
.image-placeholder {
    display: inline-block;
    padding: 2px 8px;
    background: var(--btn-accent-bg, #667eea);
    color: var(--btn-accent-text, #fff);
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    font-family: monospace;
    cursor: default;
    user-select: none;
    vertical-align: middle;
    margin: 0 2px;
}

/* ===== 연동된 캐릭터 정보 표시 ===== */
.ci-linked-char-section {
    border: 2px solid var(--btn-accent-bg, #667eea);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
}

.ci-linked-char-section .ci-section-title {
    color: var(--btn-accent-bg, #667eea);
}

.ci-linked-char-section .ci-section-title::before {
    content: none;
}

.ci-linked-char-section .ci-section-title i {
    margin-right: 8px;
}

.ci-linked-char-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ci-linked-char-info .ci-char-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--ci-text);
}

.ci-linked-char-info .ci-char-id {
    font-size: 12px;
    color: var(--ci-text-muted);
}

.ci-linked-char-info .ci-help-text {
    flex-basis: 100%;
    margin-top: 4px;
}

/* ===== 체크박스 스타일 ===== */
.ci-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.ci-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--ci-accent, #667eea);
    cursor: pointer;
}

.ci-checkbox-label span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    color: var(--ci-text);
}

.ci-checkbox-label span i {
    color: var(--ci-text-muted);
}

.ci-checkbox-label input[type="checkbox"]:checked + span {
    color: var(--ci-accent, #667eea);
}

.ci-checkbox-label input[type="checkbox"]:checked + span i {
    color: var(--ci-accent, #667eea);
}

/* Responsive */
@media (max-width: 768px) {
    .ci-form-row { flex-direction: column; gap: 0; }
    .ci-upload-grid { grid-template-columns: 1fr 1fr; }
    .ci-stat-grid { grid-template-columns: 1fr; }
    .ci-relation-row { flex-wrap: wrap; }
    .ci-relation-search-wrap,
    .ci-relation-row .relation-type,
    .ci-relation-row .relation-desc { flex: none; width: 100%; }

    .ci-iframe-tab-row { flex-wrap: wrap; }
    .ci-iframe-tab-row .iframe-tab-title { flex: none; width: calc(50% - 5px); }
    .ci-iframe-tab-row .iframe-tab-type { flex: none; width: calc(50% - 25px); }
    .ci-iframe-tab-row .iframe-tab-board,
    .ci-iframe-tab-row .iframe-tab-content,
    .ci-iframe-tab-row .iframe-tab-url { flex: none; width: 100%; }
}