/* 엔트리 스프라이트 선택 모달 - Entry.org 공식 UI 기반 */
/* 교육/연구 목적 사용 - Original: https://playentry.org */

.sprite-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.sprite-modal-overlay.show {
    display: flex;
}

.sprite-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
    overflow: hidden;
}

/* 모달 헤더 */
.sprite-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.sprite-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.sprite-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sprite-modal-close:hover {
    background: #e5e7eb;
    color: #374151;
}

/* 모달 바디 */
.sprite-modal-body {
    display: flex;
    flex: 1;
    min-height: 500px;
    max-height: calc(90vh - 140px);
}

/* 사이드바 (카테고리) */
.sprite-sidebar {
    width: 200px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.sprite-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    background: white;
}

.sprite-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.sprite-search:focus {
    outline: none;
    border-color: #4f86ec;
    box-shadow: 0 0 0 3px rgba(79, 134, 236, 0.1);
}

.sprite-categories {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sprite-category {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 2px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
    transition: all 0.2s ease;
    user-select: none;
}

.sprite-category:hover {
    background: #e2e8f0;
    color: #1f2937;
}

.sprite-category.active {
    background: #4f86ec;
    color: white;
}

.sprite-category-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* 메인 콘텐츠 영역 */
.sprite-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.sprite-content-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: between;
    align-items: center;
}

.sprite-content-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.sprite-count {
    font-size: 14px;
    color: #6b7280;
    margin-left: auto;
}

/* 스프라이트 그리드 */
.sprite-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.sprite-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.sprite-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
    position: relative;
}

.sprite-card:hover {
    border-color: #4f86ec;
    background: #f0f4ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 134, 236, 0.15);
}

.sprite-card.selected {
    border-color: #4f86ec;
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(79, 134, 236, 0.1);
}

.sprite-card.selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: #4f86ec;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.sprite-thumbnail {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 8px;
    border-radius: 4px;
}

.sprite-name {
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    text-align: center;
    line-height: 1.3;
    word-break: keep-all;
}

/* 빈 상태 */
.sprite-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #9ca3af;
}

.sprite-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.sprite-empty-text {
    font-size: 16px;
    font-weight: 500;
}

/* 모달 푸터 */
.sprite-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.sprite-credit {
    font-size: 12px;
    color: #6b7280;
}

.sprite-credit a {
    color: #4f86ec;
    text-decoration: none;
}

.sprite-credit a:hover {
    text-decoration: underline;
}

.sprite-modal-actions {
    display: flex;
    gap: 12px;
}

.sprite-btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid;
    transition: all 0.2s ease;
}

.sprite-btn-secondary {
    background: white;
    color: #6b7280;
    border-color: #d1d5db;
}

.sprite-btn-secondary:hover {
    background: #f9fafb;
    color: #374151;
    border-color: #9ca3af;
}

.sprite-btn-primary {
    background: #4f86ec;
    color: white;
    border-color: #4f86ec;
}

.sprite-btn-primary:hover {
    background: #3b72d9;
    border-color: #3b72d9;
}

.sprite-btn-primary:disabled {
    background: #d1d5db;
    color: #9ca3af;
    border-color: #d1d5db;
    cursor: not-allowed;
}

/* 애니메이션 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .sprite-modal {
        width: 95%;
        max-height: 95vh;
    }
    
    .sprite-modal-body {
        flex-direction: column;
    }
    
    .sprite-sidebar {
        width: 100%;
        max-height: 120px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .sprite-categories {
        display: flex;
        overflow-x: auto;
        padding: 8px;
        gap: 4px;
    }
    
    .sprite-category {
        white-space: nowrap;
        margin: 0;
        min-width: max-content;
    }
    
    .sprite-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .sprite-card {
        padding: 12px 8px;
    }
    
    .sprite-thumbnail {
        width: 48px;
        height: 48px;
    }
}