/**
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * ⚡ APC System - Modal Stylesheet
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * 📁 파일명: /www/_acc/css/modal.css
 * 📌 버전: v1.9
 * 📅 작성일: 2025-12-25
 * 📝 설명: ★ 모바일 footer 버튼 정렬, Copy 버튼 단색
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 */

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * Modal Overlay - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.modal-overlay {
    display: none;
    position: fixed; 
    z-index: 9999;
    top: 0;
    left: 0; 
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    justify-content: center; 
    align-items: center;
    padding: 40px; 
    box-sizing: border-box;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * Modal Content - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.modal-content {
    background: var(--modal-bg);
    width: 100%; 
    max-width: 1100px; 
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    /* ★★★ [v2.8] 탭 시스템용 flex 레이아웃 ★★★ */
    display: flex;
    flex-direction: column;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * Modal Body - 데스크톱 레이아웃
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.modal-body { 
    display: grid;
    grid-template-columns: 460px 1fr;
    height: auto;
    max-height: 90vh;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * Modal Left - 이미지 영역 - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.modal-left {
    width: 460px;
    min-width: 460px;
    flex-shrink: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 30px;
    box-sizing: border-box;
    overflow-y: auto;
}

.img-container { 
    width: 400px;
    height: 600px;
    min-width: 400px;
    min-height: 600px;
    flex-shrink: 0;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    overflow: hidden;
    border-radius: 12px;
    background: var(--border);
}

.img-container img { 
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

/* 이미지 편집 영역 - ★ CSS 변수 적용 */
.edit-image-section {
    display: flex;
    flex-direction: row;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: var(--banana-medium);
    border-radius: 8px;
    align-items: center;
    box-sizing: border-box;
}

.edit-image-section .edit-input {
    flex: 1;
    margin-top: 0;
    min-width: 0;
}

.edit-image-section .btn-sm {
    flex-shrink: 0;
    padding: 8px 12px;
    white-space: nowrap;
    background: var(--banana-dark);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.edit-image-section .btn-sm:hover {
    background: #b45309;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * Modal Right - 정보 영역 - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.modal-right {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}

/* 헤더 영역 - 고정 */
.modal-right-header {
    flex-shrink: 0;
    padding: 25px 25px 15px 25px;
    border-bottom: 1px solid var(--banana-border);
    background: transparent;
}

/* 프롬프트 영역 - 스크롤 */
.modal-right-body {
    flex: 0 0 auto;
    max-height: 40vh;
    overflow-y: auto;
    padding: 15px 25px;
    display: flex;
    flex-direction: column;
    background: transparent;
}

/* 버튼 영역 - 하단 고정 */
.modal-right-footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    background: transparent;
    border-top: 1px solid var(--banana-border);
}

/* Copy 버튼을 오른쪽 끝으로 */
.modal-right-footer .copy-btn-main {
    margin-left: auto;
}

/* 버튼 공통 텍스트 */
.btn-text {
    margin-left: 6px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * Modal 공통 요소 스타일 - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 12px 0;
    line-height: 1.4;
    word-break: break-word;
}

.header-top-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

/* 관리 버튼 */
.admin-controls { 
    display: flex; 
    flex-direction: row;
    gap: 8px; 
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.2s;
    opacity: 0.5;
    color: var(--text);
}

.icon-btn:hover {
    opacity: 1;
}

.delete-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.edit-btn:hover {
    background: var(--banana-medium);
    color: var(--banana-dark);
}

.user-text h2 { 
    margin: 0; 
    font-size: 1.4rem; 
    color: var(--primary);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * Tags - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.tags-display-area {
    display: flex; 
    flex-direction: row;
    gap: 8px; 
    flex-wrap: wrap; 
    margin-top: 10px;
}

.tag-pill {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-badge { 
    background: var(--banana-medium);
    color: var(--banana-dark);
    border: 1px solid var(--banana-border); 
}

.hash-tag { 
    background: var(--banana-light);
    color: var(--banana-text);
    border: 1px solid var(--banana-border);
    font-size: 0.85rem; 
    text-transform: none;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * Edit Inputs - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.edit-select {
    padding: 8px 12px;
    border: 1px solid var(--banana-border);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--banana-text);
    background: var(--banana-medium);
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.edit-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.edit-input {
    width: 100%;
    padding: 8px;
    margin-top: 10px;
    border: 1px solid var(--banana-border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: monospace;
    box-sizing: border-box;
    background: var(--surface);
    color: var(--text);
}

.edit-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.edit-textarea {
    width: 100%;
    height: 100%;
    min-height: 200px;
    padding: 10px;
    border: 1px solid var(--banana-border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: monospace;
    line-height: 1.5;
    resize: none;
    box-sizing: border-box;
    background: var(--surface);
    color: var(--text);
}

.edit-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.save-btn {
    background: #10b981;
    color: white;
}

.save-btn:hover {
    background: #059669;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * 프롬프트 영역 - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 모달 프롬프트 줄바꿈 유지 (강제 적용) */
#modalPrompt {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--prompt-text);
}

.section-label { 
    display: block; 
    font-size: 0.8rem; 
    font-weight: 700; 
    color: var(--banana-dark);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.prompt-text-area {
    background: var(--prompt-bg);
    border: 1px solid var(--prompt-border);
    border-radius: 8px; 
    padding: 15px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    max-height: 150px;  /* ★ 모바일용 높이 제한 */
}

.prompt-text-area p {
    margin: 0; 
    white-space: pre-wrap !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--prompt-text);
    word-break: break-word;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * 액션 버튼 - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.action-btn {
    padding: 10px 14px; 
    border-radius: 10px; 
    font-weight: 600; 
    font-size: 0.9rem; 
    cursor: pointer; 
    border: none; 
    display: inline-flex;
    align-items: center; 
    justify-content: center; 
    gap: 6px; 
    transition: all 0.2s;
    white-space: nowrap;
}

.link-btn {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--btn-secondary-border);
}

.link-btn:hover {
    background: var(--banana-border);
    color: #78350f;
}

/* ★ [A-6] 다크모드에서 link-btn 호버 */
[data-theme="dark"] .link-btn:hover {
    background: var(--banana-medium);
    color: var(--banana-text);
}

.copy-btn-main {
    background: #FF6B35;
    color: white;
    border: none;
}

.copy-btn-main:hover { 
    background: #e55a2b;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3); 
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * [A-4] 모달 메타정보 패널 - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.modal-meta-panel {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    padding: 12px 15px;
    background: var(--meta-bg);
    border-radius: 10px;
    border: 1px solid var(--meta-border);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.meta-icon {
    font-size: 1rem;
}

.meta-label {
    font-size: 0.75rem;
    color: var(--banana-text);
    font-weight: 500;
}

.meta-value {
    font-size: 0.85rem;
    color: var(--banana-dark);
    font-weight: 700;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * [A-5] 다운로드 버튼 - ★ CSS 변수 적용
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.download-btn {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--btn-secondary-border);
}

.download-btn:hover {
    background: var(--banana-border);
    color: #78350f;
}

/* ★ [A-6] 다크모드에서 download-btn 호버 */
[data-theme="dark"] .download-btn:hover {
    background: var(--banana-medium);
    color: var(--banana-text);
}

/* ★★★ X 링크 버튼 (download-btn과 동일) ★★★ */
.x-link-btn {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--btn-secondary-border);
    text-decoration: none;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.x-link-btn:hover {
    background: var(--banana-border);
    color: #78350f;
}

[data-theme="dark"] .x-link-btn:hover {
    background: var(--banana-medium);
    color: var(--banana-text);
}

/* ★★★ Copy 버튼 단색 주황색 ★★★ */
.modal-right-footer .copy-btn {
    background: #FF6B35;
    color: white;
    border: none;
}

.modal-right-footer .copy-btn:hover {
    background: #e55a2b;
}

/* ★★★ 모달 푸터 버튼 높이 통일 ★★★ */
.modal-right-footer .action-btn {
    padding: 10px 16px;
    min-height: 42px;
    box-sizing: border-box;
}
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ★★★ [v2.8] 모달 탭 시스템 ★★★ */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* 탭 헤더 */
.modal-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #fffbeb;
    border-bottom: 2px solid #fde68a;
    border-radius: 16px 16px 0 0;
}

.tab-header-left {
    display: flex;
    gap: 8px;
}

/* 탭 버튼 */
.modal-tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-tab-btn:hover {
    background: var(--banana-light, #fef3c7);
    color: var(--primary, #FF6B35);
}

.modal-tab-btn.active {
    background: var(--primary, #FF6B35);
    color: white;
}

.modal-tab-btn i {
    font-size: 1rem;
}

/* 크레딧 표시 */
.credit-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--banana-dark, #92400e);
}

.credit-display i {
    color: #f59e0b;
}

.credit-amount {
    font-weight: 700;
}

.credit-label {
    color: var(--text-secondary, #6b7280);
    font-weight: 500;
}

/* 탭 콘텐츠 */
.modal-tab-content {
    display: none;
}

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

/* Generate iframe 컨테이너 */
.generate-iframe-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 180px);
    min-height: 500px;
    background: var(--surface, #fffbeb);
}

.generate-iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0 0 16px 16px;
}

/* Generate 로딩 오버레이 */
.generate-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--surface, #fffbeb);
    z-index: 10;
}

.generate-loading.hidden {
    display: none;
}

.generate-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border, #fde68a);
    border-top-color: var(--primary, #FF6B35);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.generate-loading p {
    margin-top: 12px;
    color: var(--text-secondary, #6b7280);
    font-size: 0.9rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ★★★ 다크모드 대응 ★★★ */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

[data-theme="dark"] .modal-tab-header {
    background: var(--surface, #1e293b);
    border-bottom-color: var(--border, #475569);
}

[data-theme="dark"] .modal-tab-btn:hover {
    background: var(--banana-light, #374151);
}

[data-theme="dark"] .credit-display {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    color: var(--banana-text, #fcd34d);
}

[data-theme="dark"] .generate-iframe-container,
[data-theme="dark"] .generate-loading {
    background: var(--surface, #1e293b);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ★★★ 모바일 반응형 ★★★ */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

@media (max-width: 768px) {
    /* ★★★ 모바일 모달 - 외부 클릭 영역 확보 ★★★ */
    .modal-overlay {
        padding: 20px;
    }
    
    .modal-content {
        max-height: 85vh;
        border-radius: 12px;
    }
    
    .modal-tab-header {
        padding: 10px 12px;
    }
    
    .modal-tab-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .modal-tab-btn span {
        display: none;
    }
    
    .modal-tab-btn i {
        font-size: 1.1rem;
    }
    
    .credit-display {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .credit-label {
        display: none;
    }
    
    .generate-iframe-container {
        height: calc(100vh - 120px);
        min-height: 400px;
    }
    
    /* ★★★ 모바일 footer 버튼 한 줄 정렬 ★★★ */
    .modal-right-footer {
        padding: 10px 15px;
        gap: 6px;
        flex-wrap: nowrap;
    }
    
    .modal-right-footer .action-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
        min-width: 0;
        flex-shrink: 1;
    }
    
    .modal-right-footer .x-link-btn {
        max-width: 80px;
    }
    
    .modal-right-footer .copy-btn-main {
        padding: 8px 12px;
    }
}